jrrom’s NixOS configuration.
Note that * means it produces both nixosModules and homeModules.
| Path | Produces | Holds |
|---|---|---|
modules/base | *.base & flake helpers | Every machine |
modules/desktop | *.desktop | Screen stuff |
modules/server | nixosModules.server & nixosModules.selfHosted | Server stuff |
modules/infra | terraform config | Self explanatory |
modules/users/{name} | *.{name} | One person |
modules/hosts/{host} | nixosConfigurations.{host} | One machine |
secrets/{host} | SOPS secrets | One file per host |
- Note that files named
_{fileName}are not pulled in automatically and are manually imported. - Note that the Tailscale key needs to be regenerated every 90 days, so probably regenerate it before installing a new device!
- Is it about one person (identity, personal apps, autostart)? →
users/<name>.nix - Is it about one machine (hardware, disks, hostId, time zone)? →
hosts/<host>/ - Does every machine need it? →
base/ - Does every machine with a screen need it? →
desktop/ - Does every headless machine need it or web service? →
server/ - None of these → it’s a new module: make a new folder (rule 9).
- The folder names the module (except in base). Every file in
modules/{module}adds toflake.nixosModules.{module}and/orflake.homeModules.{module}. Never define a module named after the file. - Constants are for values shared between files or used in
config.org. - One file per topic, not per option.
- Each nixosModule pulls in their own other half (homeModule), the hosts should list only NixOS modules.
home-manager.sharedModules = [ self.homeModules.desktop ];- Each file has the same shape
{ inputs, self, config, lib, ... }: # only the arguments you use
let
c = config.constants; # only if you use constants
in
{
flake.nixosModules.<aspect> = { pkgs, ... }: {
...
};
flake.homeModules.<aspect> = { config, pkgs, ... }: {
...
};
}- New module
- Make
modules/{module}/{module}.nix, add it to the hosts who want it. - New user
- Refer to
users/gamer.nix, add{name}-{password}to the hosts’ SOPS file, and the host modules. - New host
- make
modules/hosts/<host>/<host>.nix+_hardware.nix(fromnixos-generate-config) +_disk.nix. Name thenixosConfigurationsattribute after the hostName. Addsecrets/<hostName>.yamland a creation rule in.sops.yaml.