diff --git a/README.md b/README.md index ffad2569..51065103 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,5 @@ # My NixOS configs -TODO: add directory structure info and enforce it - - - [x] every root folder in the repo represents a flake output except inputs - - [x] every root folder only has an optional `default.nix` and subfolders for each - of its attrs - - [x] if there is non nix code, it will be in a `config` folder - - [x] every module should not do anything if imported - - [x] all nix files that represent a module should be `default.nix` (a nix file - which is imported directly can be called anything alongside `default.nix`) - - [ ] redo docs - ## AGS You might find it weird that most of my config is written in TypeScript. @@ -27,10 +16,22 @@ in TypeScript because it's the scripting language I am most comfortable with. ### General -This repo is the complete configuration of machines I own, -running NixOS or Nix. Its structure is based on a flake's +This repo is the complete configuration of machines I own running NixOS or Nix +and any other related smaller projects exposed by a Nix Flake. + +Its main directory structure is based on a flake's [outputs](https://wiki.nixos.org/wiki/Flakes#Output_schema). +I try to follow a few rules to better organise my Nix code: + + - Every main subdirectory only has an optional `default.nix` and subfolders for each + of its attributes. + - Inside a subdirectory, if there is non nix code, it will be in a `config` folder. + - Every module should not do anything if imported. An enable option should be toggled + for it to have any effect. + - Any nix file that represents a module should be named `default.nix` (a nix file + which is imported directly can be called anything else alongside `default.nix`) + ### Flake Location This git repo will always be located at `$FLAKE` (`config.environment.variables.FLAKE`) @@ -47,43 +48,22 @@ echo "$FLAKE" # /home/matt/.nix sudo ln -sf /home/matt/.nix /etc/nixos ``` -### Flake Outputs +### Subdirectories -| Output | Description | -| ---------------------------------- | ----------- | -| `nixosConfigurations` | [devices](https://git.nelim.org/matt1432/nixos-configs/src/branch/master/devices)' + ISO's configurations | -| `nixOnDroidConfigurations.default` | [Nix-On-Droid](https://git.nelim.org/matt1432/nixos-configs/src/branch/master/devices/android)'s configuration | -| `packages` | Some custom [packages](https://git.nelim.org/matt1432/nixos-configs/src/branch/master/packages) not available in nixpkgs or modified from it | -| `scopedPackages` | Some custom [package scopes](https://git.nelim.org/matt1432/nixos-configs/src/branch/master/scopedPackages) not available in nixpkgs or modified from it | -| `apps` | Scripts ran from the flake defined [here](https://git.nelim.org/matt1432/nixos-configs/src/branch/master/apps) | -| `homeManagerModules` | [Modules](https://git.nelim.org/matt1432/nixos-configs/src/branch/master/homeManagerModules) made for home-manager | -| `homeManagerModules` | [Modules](https://git.nelim.org/matt1432/nixos-configs/src/branch/master/modules) made for NixOS systems | -| `formatter` | I format nix code with [alejandra](https://github.com/kamadorueda/alejandra) | -| `devShells.default` | A dev shell to build an ISO from the live-image nixosConfiguration | -| `devShells.ags` | A dev shell to have a NodeJS env when I enter my AGS's config directory | - -### Flake Inputs - -To allow use of the full nix language for my inputs, I use [genflake](https://github.com/jorsn/flakegen). -Therefore, the flake I edit is located at `./outputs.nix`. - -I also prefer using a more descriptive format for my inputs like so: - -```nix -nixpkgs = { - type = "github"; - owner = "NixOS"; - repo = "nixpkgs"; - - # Branch name - ref = "nixos-unstable"; - - # Pin this input to a specific commit - rev = "842d9d80cfd4560648c785f8a4e6f3b096790e19"; -}; -``` - -to make it more clear what is what in the flake URI +| Output / Directory | Description | +| -------------------- | ----------- | +| `apps` | [Misc scripts ran from the flake](./apps) | +| `configurations` | [device, ISO and nix-on-droid configurations](./configurations) | +| `devShells` | [Development shells for a bunch of projects and languages](./devShells) | +| `homeManagerModules` | [Modules made for home-manager](./homeManagerModules) | +| `inputs` | [Pre-evaluated flake inputs](./inputs) | +| `lib` | [Custom Nix functions made easily available](./lib) | +| `modules` | [Modules made for NixOS systems](./modules) | +| `nixFastChecks` | [Attribute set of derivations exposed by this flake](./nixFastChecks) | +| `overlays` | [Nixpkgs overlays](./overlays) | +| `packages` | [Some custom packages not available in nixpkgs or modified from it](./packages) | +| `results` | Directory where I neatly keep my result symlinks from `nixFastChecks` | +| `scopedPackages` | [Some custom package scopes not available in nixpkgs or modified from it](./scopedPackages) | ### Secrets @@ -117,6 +97,4 @@ and this shell command: nix eval --json --file ./.sops.nix | remarshal --if json --of yaml > .sops.yaml ``` -TLDR: I -**[hate](https://ruudvanasseldonk.com/2023/01/11/the-yaml-document-from-hell)** -YAML +TLDR: I **[hate](https://ruudvanasseldonk.com/2023/01/11/the-yaml-document-from-hell)** YAML diff --git a/inputs/README.md b/inputs/README.md new file mode 100644 index 00000000..ccd5f2a4 --- /dev/null +++ b/inputs/README.md @@ -0,0 +1,22 @@ +# Inputs + +To allow use of the full nix language for my inputs, I use [genflake](https://github.com/jorsn/flakegen). +Therefore, the flake I edit is located at `$FLAKE/_outputs.nix`. + +I also prefer using a more descriptive format for my inputs like so: + +```nix +nixpkgs = { + type = "github"; + owner = "NixOS"; + repo = "nixpkgs"; + + # Branch name + ref = "nixos-unstable"; + + # Pin this input to a specific commit + rev = "842d9d80cfd4560648c785f8a4e6f3b096790e19"; +}; +``` + +to make it more clear what is what in the flake URI diff --git a/inputs/default.nix b/inputs/default.nix index 5ae12c6a..f6c8b6e0 100644 --- a/inputs/default.nix +++ b/inputs/default.nix @@ -1,4 +1,3 @@ -# TODO: add README let inherit (import ./lib.nix) mkInput mkHyprDep mkSrc; inherit (builtins) listToAttrs map removeAttrs; diff --git a/justfile b/justfile index 82769b27..d446ffba 100644 --- a/justfile +++ b/justfile @@ -1,7 +1,7 @@ default: @just --list -docs args: +docs: nix run "$FLAKE"#gen-docs genflake: diff --git a/lib/README.md b/lib/README.md new file mode 100644 index 00000000..5f809ae1 --- /dev/null +++ b/lib/README.md @@ -0,0 +1,11 @@ +# Lib + +This directory contains Nix functions separated by what type or program they are associated with. + +| Attribute Set | Description | +| ------------- | ------------------------------------------------------------------------------------------------ | +| `attrs` | [Misc functions dealing with attribute sets](./attrs) | +| `flake` | [Helper functions for top level flake outputs](./flake) | +| `hypr` | [Helper functions to configure hyprland in a cleaner way](./hypr) | +| `pkgs` | [Misc functions dealing with packages](./pkgs) | +| `strings` | [Misc functions dealing with strings](./strings) | diff --git a/lib/default.nix b/lib/default.nix index 7d4e94e0..6e459e00 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,4 +1,3 @@ -# TODO: add README and document functions { perSystem, inputs,