yep, more dotfiles
1# mrnossiom's NixOS and Home Manager configuration 2 3# Options 4 5```nix 6{ 7 local.flags = { 8 onlyCached = true; # bool; dictate if you are to compile pkgs or use cache 9 }; 10 11 local.fragment."<name>".enable = true; # bool; dictate whether to enable a fragment 12} 13``` 14 15# Structure 16 17- `apps`: Scripts serving dotfiles purposes 18- `assets`: Media or files that don't fit in Nix files 19- `home-manager`: Home Manager specific 20 - `fragments`: Home Manager configuration fragments 21 - `options`: Home Manager configuration flags 22 - `profiles`: Base Home Manager configurations to build upon (e.g. `desktop`, `minimal`) 23- `lib`: Additional custom lib and flake helpers 24- `modules`: modules that fill a missing feature of NixOS or Home Manager 25- `nixos`: NixOS related config 26 - `hardware/<hostname>.nix`: Device-specific settings like settings generated by `nixos-generate-config` 27 - `layout/<layout>.nix`: `Disko` disk layouts used by `managedDiskLayout` (e.g `luks-btrfs`) 28 - `fragments`: Opinionated NixOS configuration fragments 29 - `profiles/<profile>.nix`: Base system configurations to build upon (e.g. `laptop`, `installer`) 30- `overlays`: Just plain Nix overlays 31- `pkgs`: Custom packages either not eligible or missing from repositories 32- `secrets`: `agenix` encrypted secrets 33- `templates`: Quickstart files for different languages 34 35# Quick snippets and guides for myself 36 37## Add a new module 38 39- Copy template and replace `<name>` with module name 40 41 ```nix 42 { config 43 , lib 44 , ... }: 45 46 let 47 cfg = config.local.fragment.<name>; 48 in 49 { 50 options.local.fragment."<name>".enable = lib.mkEnableOption '' 51 <name> related 52 53 Depends on: 54 - [<Condition>] <dependency>: <reason> 55 - ... 56 ''; 57 58 config = lib.mkIf cfg.enable { 59 assertions = [ 60 { assertion = config."<dependency>"; message = "<name> module depends on <dependency>"; } 61 ]; 62 63 # put the rest of the config down below 64 }; 65 } 66 ``` 67 68- Add the newly created file to Git. 69 70- Add the new module to the import list in `<type>/fragments/default.nix`. 71 72- Activate the module in the wanted profile. 73 74## Bootstrap lightweight home-manager config 75 76``` 77nix run nixpkgs#home-manager -- switch --flake .#lightweight 78``` 79 80## Add a new device 81 82- Rekey secrets with device root ssh key, and create a session age key. 83 84## Make a backup 85 86Pull up your favorite ArchaicBakup disc 87 88- Set environnement variables 89 90 `RESTIC_REPOSITORY`: `/run/media/user/discname/` 91 `RESTIC_PASSWORD_FILE`: ? 92 93- Initialize repository 94 95 ```bash 96 restic init --repo /srv/restic-repo 97 ``` 98 99## Deploy server 100 101```bash 102nixos-anywhere --flake .#weird-row-server user@ip 103 104nixos-rebuild switch \ 105 --flake .#weird-row-server \ 106 --target-host 2a01:4f8:c2c:76d2::1 \ 107 --use-remote-sudo 108``` 109 110--- 111 112Milo Moisson © 2023-2025