|
| 1 | +{ |
| 2 | + inputs = { |
| 3 | + nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05"; |
| 4 | + home-manager = { |
| 5 | + url = "github:nix-community/home-manager/release-23.05"; |
| 6 | + inputs.nixpkgs.follows = "nixpkgs"; |
| 7 | + }; |
| 8 | + }; |
| 9 | + |
| 10 | + outputs = { self, nixpkgs, home-manager }: |
| 11 | + let |
| 12 | + mkHost = hostName: system: |
| 13 | + (({ my-config, zfs-root, pkgs, system, ... }: |
| 14 | + nixpkgs.lib.nixosSystem { |
| 15 | + inherit system; |
| 16 | + modules = [ |
| 17 | + # Module 0: zfs-root and my-config |
| 18 | + ./modules |
| 19 | + |
| 20 | + # Module 1: host-specific config, if exist |
| 21 | + (if (builtins.pathExists |
| 22 | + ./hosts/${hostName}/configuration.nix) then |
| 23 | + (import ./hosts/${hostName}/configuration.nix { inherit pkgs; }) |
| 24 | + else |
| 25 | + { }) |
| 26 | + |
| 27 | + # Module 2: entry point |
| 28 | + (({ my-config, zfs-root, pkgs, lib, ... }: { |
| 29 | + inherit my-config zfs-root; |
| 30 | + system.configurationRevision = if (self ? rev) then |
| 31 | + self.rev |
| 32 | + else |
| 33 | + throw "refuse to build: git tree is dirty"; |
| 34 | + system.stateVersion = "23.05"; |
| 35 | + imports = [ |
| 36 | + "${nixpkgs}/nixos/modules/installer/scan/not-detected.nix" |
| 37 | + # "${nixpkgs}/nixos/modules/profiles/hardened.nix" |
| 38 | + # "${nixpkgs}/nixos/modules/profiles/qemu-guest.nix" |
| 39 | + ]; |
| 40 | + }) { |
| 41 | + inherit my-config zfs-root pkgs; |
| 42 | + lib = nixpkgs.lib; |
| 43 | + }) |
| 44 | + |
| 45 | + # Module 3: home-manager |
| 46 | + home-manager.nixosModules.home-manager |
| 47 | + { |
| 48 | + home-manager.useGlobalPkgs = true; |
| 49 | + home-manager.useUserPackages = true; |
| 50 | + } |
| 51 | + |
| 52 | + # Module 4: config shared by all hosts |
| 53 | + (import ./configuration.nix { inherit pkgs; }) |
| 54 | + ]; |
| 55 | + }) |
| 56 | + |
| 57 | + # configuration input |
| 58 | + (import ./hosts/${hostName} { |
| 59 | + system = system; |
| 60 | + pkgs = nixpkgs.legacyPackages.${system}; |
| 61 | + })); |
| 62 | + in { |
| 63 | + nixosConfigurations = { |
| 64 | + exampleHost = mkHost "exampleHost" "x86_64-linux"; |
| 65 | + }; |
| 66 | + }; |
| 67 | +} |
0 commit comments