flake: simplify the machine declartion helpers

This commit is contained in:
2022-05-23 17:15:38 -07:00
parent 3066490c61
commit b4ab1d332b

View File

@@ -75,13 +75,14 @@
nixosConfigurations = builtins.mapAttrs (name: value: value.nixosConfiguration) self.machines; nixosConfigurations = builtins.mapAttrs (name: value: value.nixosConfiguration) self.machines;
imgs = builtins.mapAttrs (name: value: value.img) self.machines; imgs = builtins.mapAttrs (name: value: value.img) self.machines;
decl-machine = { system, extraModules }: (nixpkgs.lib.nixosSystem { decl-machine = { name, system, extraModules ? [] }: (nixpkgs.lib.nixosSystem {
inherit system; inherit system;
pkgs = self.genpkgs."${system}".pkgs; pkgs = self.genpkgs."${system}".pkgs;
specialArgs = { inherit home-manager; inherit nurpkgs; }; specialArgs = { inherit home-manager; inherit nurpkgs; };
modules = [ modules = [
./configuration.nix ./configuration.nix
./modules ./modules
./machines/${name}
] ++ extraModules; ] ++ extraModules;
}); });
@@ -90,18 +91,15 @@
# run `btrfs-convert --uuid copy <device>` # run `btrfs-convert --uuid copy <device>`
# boot, checkout this flake into /etc/nixos AND UPDATE THE UUIDS IT REFERENCES. # boot, checkout this flake into /etc/nixos AND UPDATE THE UUIDS IT REFERENCES.
# then `nixos-rebuild ...` # then `nixos-rebuild ...`
decl-img = { system, extraModules }: ( decl-img = { name, system, extraModules ? [] }: (
(self.decl-machine { inherit system; extraModules = extraModules ++ [./image.nix]; }) (self.decl-machine { inherit name; inherit system; extraModules = extraModules ++ [./image.nix]; })
.config.system.build.raw .config.system.build.raw
); );
decl-bootable-machine = { name, system }: ( decl-bootable-machine = { name, system }: {
let extraModules = [ ./machines/${name} ]; nixosConfiguration = self.decl-machine { inherit name; inherit system; };
in { img = self.decl-img { inherit name; inherit system; };
nixosConfiguration = self.decl-machine { inherit system; inherit extraModules; }; };
img = self.decl-img { inherit system; inherit extraModules; };
}
);
# apply all our package overlays, but to all platforms possible. # apply all our package overlays, but to all platforms possible.
# genpkgs = nixpkgs.lib.genAttrs nixpkgs.lib.platforms.all (system: # genpkgs = nixpkgs.lib.genAttrs nixpkgs.lib.platforms.all (system: