Rework flake.nix to use extendModules.
This commit is contained in:
@@ -69,41 +69,52 @@
|
|||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
nixosConfigs = builtins.mapAttrs (
|
baseConfig = nixpkgs.lib.nixosSystem {
|
||||||
hostname: nodeConfig: format:
|
specialArgs = {
|
||||||
nixpkgs.lib.nixosSystem {
|
inherit self nix_builder;
|
||||||
specialArgs = {
|
|
||||||
inherit self nix_builder;
|
|
||||||
|
|
||||||
this_nixos_config = self.nixosConfigurations."${hostname}";
|
all_nixos_configs = self.nixosConfigurations;
|
||||||
|
};
|
||||||
all_nixos_configs = self.nixosConfigurations;
|
modules = [
|
||||||
};
|
impermanence.nixosModules.impermanence
|
||||||
|
lanzaboote.nixosModules.lanzaboote
|
||||||
|
disko.nixosModules.disko
|
||||||
|
./configuration.nix
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
nixpkgs.overlays = [
|
||||||
|
(final: prev: {
|
||||||
|
# stable = nixpkgs-stable.legacyPackages."${prev.stdenv.hostPlatform.system}";
|
||||||
|
unoptimized = import nixpkgs {
|
||||||
|
system = prev.stdenv.hostPlatform.system;
|
||||||
|
hostPlatform.gcc.arch = "default";
|
||||||
|
hostPlatform.gcc.tune = "default";
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
toplevelConfigs = builtins.mapAttrs (
|
||||||
|
hostname: nodeConfig:
|
||||||
|
baseConfig.extendModules {
|
||||||
modules = [
|
modules = [
|
||||||
impermanence.nixosModules.impermanence
|
|
||||||
lanzaboote.nixosModules.lanzaboote
|
|
||||||
disko.nixosModules.disko
|
|
||||||
./configuration.nix
|
|
||||||
(./. + "/hosts/${hostname}")
|
(./. + "/hosts/${hostname}")
|
||||||
(./. + "/formats/${format}.nix")
|
|
||||||
{
|
{
|
||||||
config = {
|
config = {
|
||||||
nixpkgs.hostPlatform.system = nodeConfig.system;
|
nixpkgs.hostPlatform.system = nodeConfig.system;
|
||||||
nixpkgs.overlays = [
|
|
||||||
(final: prev: {
|
|
||||||
# stable = nixpkgs-stable.legacyPackages."${prev.stdenv.hostPlatform.system}";
|
|
||||||
unoptimized = import nixpkgs {
|
|
||||||
system = prev.stdenv.hostPlatform.system;
|
|
||||||
hostPlatform.gcc.arch = "default";
|
|
||||||
hostPlatform.gcc.tune = "default";
|
|
||||||
};
|
|
||||||
})
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
specialArgs.this_nixos_config = self.nixosConfigurations."${hostname}";
|
||||||
}
|
}
|
||||||
) nodes;
|
) nodes;
|
||||||
|
specialFormats =
|
||||||
|
nixosConfig: format:
|
||||||
|
nixosConfig.extendModules {
|
||||||
|
modules = [ (./. + "/formats/${format}.nix") ];
|
||||||
|
};
|
||||||
installerConfig =
|
installerConfig =
|
||||||
hostname: nodeConfig:
|
hostname: nodeConfig:
|
||||||
nixpkgs.lib.nixosSystem {
|
nixpkgs.lib.nixosSystem {
|
||||||
@@ -117,18 +128,24 @@
|
|||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
nixosConfigurations = (builtins.mapAttrs (name: value: value "toplevel") nixosConfigs);
|
nixosConfigurations = toplevelConfigs;
|
||||||
}
|
}
|
||||||
// {
|
// {
|
||||||
packages = (
|
packages = (
|
||||||
forAllSystems (
|
forAllSystems (
|
||||||
system:
|
system:
|
||||||
(builtins.mapAttrs (hostname: nodeConfig: {
|
let
|
||||||
iso = (nixosConfigs."${hostname}" "iso").config.system.build.isoImage;
|
machines = (
|
||||||
vm_iso = (nixosConfigs."${hostname}" "vm_iso").config.system.build.isoImage;
|
builtins.mapAttrs (hostname: nodeConfig: {
|
||||||
sd = (nixosConfigs."${hostname}" "sd").config.system.build.sdImage;
|
iso = (specialFormats self.nixosConfigurations."${hostname}" "iso").config.system.build.isoImage;
|
||||||
installer = (installerConfig hostname nodes."${hostname}").config.system.build.isoImage;
|
vm_iso =
|
||||||
}) (nixpkgs.lib.attrsets.filterAttrs (hostname: nodeConfig: nodeConfig.system == system) nodes))
|
(specialFormats self.nixosConfigurations."${hostname}" "vm_iso").config.system.build.isoImage;
|
||||||
|
sd = (specialFormats self.nixosConfigurations."${hostname}" "sd").config.system.build.sdImage;
|
||||||
|
installer = (installerConfig hostname nodes."${hostname}").config.system.build.isoImage;
|
||||||
|
}) (nixpkgs.lib.attrsets.filterAttrs (hostname: nodeConfig: nodeConfig.system == system) nodes)
|
||||||
|
);
|
||||||
|
in
|
||||||
|
machines
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user