diff --git a/README.md b/README.md index 8cdeab5..89a383b 100644 --- a/README.md +++ b/README.md @@ -1 +1,32 @@ -# My NixOS Configuration +# Nix Configurations + +Repository structure: + +- **host/** + One subdirectory per NixOS host, each containing its host-specific configuration. + +- **mod/** + NixOS modules. + - **mod/common/**: Modules enabled by default on all hosts. + - **mod/desktop/**: Modules enabled on desktop hosts (i.e. hosts with `hd.desktop.enable = true`). + +- **home/** + Home Manager modules. Home Manager is integrated into the system configuration via the `home` option defined in `mod/desktop/default.nix`. + +- **bin/** + Helper scripts for generating parts of the configuration. + +- **dotfiles/** + Raw configuration files deployed using Home Manager. + +- **devshells/** + Nix development shells. + +- **pki/** + Certificates used by the configuration. + +- **secrets/** + Age-encrypted secrets managed and deployed via agenix. + +- **var/** + Shared constants and values used across the configuration. diff --git a/flake.nix b/flake.nix index 87d2c79..a2d9d06 100644 --- a/flake.nix +++ b/flake.nix @@ -62,53 +62,27 @@ ; secrets = lib'.walk-dir ./secrets; }; - overlays = _: { - nixpkgs.overlays = [ - vscode-extensions.overlays.default - colmena.overlay - ]; - }; + + mkDesktop = + host: + nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = specialArgs // { + inherit host; + }; + modules = [ + (./host + "/${host}") + ./home + ./mod + ]; + }; in { nixosConfigurations = { - "solo" = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = specialArgs // { - host = "solo"; - }; - modules = [ - ./host/solo - ./home - ./mod - overlays - ]; - }; - - "c2" = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = specialArgs // { - host = "c2"; - }; - modules = [ - ./host/c2 - ./home - ./mod - overlays - ]; - }; - - "fw" = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = specialArgs // { - host = "fw"; - }; - modules = [ - ./host/fw - ./home - ./mod - overlays - ]; - }; + # if you add a host, make sure to add it to var/default.nix as well + "solo" = mkDesktop "solo"; + "c2" = mkDesktop "c2"; + "fw" = mkDesktop "fw"; }; colmenaHive = colmena.lib.makeHive { @@ -126,7 +100,6 @@ imports = [ ./host/roam ./mod - overlays ]; }; }; diff --git a/mod/common/default.nix b/mod/common/default.nix index fe17135..72c6d87 100644 --- a/mod/common/default.nix +++ b/mod/common/default.nix @@ -59,6 +59,7 @@ with lib; inputs.agenix.nixosModules.default ./locale.nix ./nix.nix + ./overlays.nix ./security.nix ./shell.nix ./users.nix diff --git a/mod/common/overlays.nix b/mod/common/overlays.nix new file mode 100644 index 0000000..83a3175 --- /dev/null +++ b/mod/common/overlays.nix @@ -0,0 +1,7 @@ +{ inputs, ... }: +{ + nixpkgs.overlays = with inputs; [ + vscode-extensions.overlays.default + colmena.overlay + ]; +} diff --git a/mod/syncthing.nix b/mod/syncthing.nix index 69364d8..474d6c6 100644 --- a/mod/syncthing.nix +++ b/mod/syncthing.nix @@ -13,7 +13,7 @@ let is-server = this == "roam"; devices = lib.attrNames var.syncthing.all; - desktop-devices = (lib.intersectLists var.desktops devices); + desktop-devices = (lib.intersectLists var.nixos-desktops devices); folders = folders-all // (if config.hd.desktop.enable then folders-desktop else { }); diff --git a/var/default.nix b/var/default.nix index 252d05d..34bd26b 100644 --- a/var/default.nix +++ b/var/default.nix @@ -8,19 +8,23 @@ let var = outputs; }; load-var = x: import x inputs'; + # watch out for cycles outputs = rec { - "lan-dns" = load-var ./lan-dns.nix; - "ssh-keys" = load-var ./ssh-keys.nix; - "wg" = load-var ./wg.nix; - "syncthing" = load-var ./syncthing.nix; - desktops = [ + # We list the hosts here manually instead of getting them from the flake. + # This way, var can be used standalone + nixos-desktops = [ "c2" "fw" "solo" ]; - servers = [ "roam" ]; - clients = desktops ++ servers; + nixos-servers = [ "roam" ]; + nixos-hosts = nixos-desktops ++ nixos-servers; + + "lan-dns" = load-var ./lan-dns.nix; + "ssh-keys" = load-var ./ssh-keys.nix; + "wg" = load-var ./wg.nix; + "syncthing" = load-var ./syncthing.nix; }; in outputs