4 Commits

Author SHA1 Message Date
Tom Alexander
f3e78d5226 Add a "wip" target in nix_builder for testing updates. 2026-11-12 13:56:38 -05:00
Tom Alexander
9ffa43acbb Eliminate this_nixos_config as a specialArg. 2026-11-12 13:49:48 -05:00
Tom Alexander
d8690ad2df Eliminate all_nixos_configs. 2026-11-12 13:46:00 -05:00
Tom Alexander
9665025e13 Rework flake.nix to use extendModules. 2026-11-12 13:42:37 -05:00
5 changed files with 72 additions and 38 deletions

View File

@@ -69,41 +69,49 @@
system = "x86_64-linux";
};
};
nixosConfigs = builtins.mapAttrs (
hostname: nodeConfig: format:
nixpkgs.lib.nixosSystem {
specialArgs = {
inherit self nix_builder;
this_nixos_config = self.nixosConfigurations."${hostname}";
all_nixos_configs = self.nixosConfigurations;
};
baseConfig = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit self nix_builder;
};
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 = [
impermanence.nixosModules.impermanence
lanzaboote.nixosModules.lanzaboote
disko.nixosModules.disko
./configuration.nix
(./. + "/hosts/${hostname}")
(./. + "/formats/${format}.nix")
{
config = {
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";
};
})
];
};
}
];
}
) nodes;
specialFormats =
nixosConfig: format:
nixosConfig.extendModules {
modules = [ (./. + "/formats/${format}.nix") ];
};
installerConfig =
hostname: nodeConfig:
nixpkgs.lib.nixosSystem {
@@ -117,18 +125,32 @@
};
in
{
nixosConfigurations = (builtins.mapAttrs (name: value: value "toplevel") nixosConfigs);
nixosConfigurations = toplevelConfigs;
}
// {
packages = (
forAllSystems (
system:
(builtins.mapAttrs (hostname: nodeConfig: {
iso = (nixosConfigs."${hostname}" "iso").config.system.build.isoImage;
vm_iso = (nixosConfigs."${hostname}" "vm_iso").config.system.build.isoImage;
sd = (nixosConfigs."${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))
let
machines = (
builtins.mapAttrs (hostname: nodeConfig: {
iso = (specialFormats self.nixosConfigurations."${hostname}" "iso").config.system.build.isoImage;
vm_iso =
(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
// {
wip = nixpkgs.legacyPackages."${system}".symlinkJoin {
name = "wip";
paths = [ self.nixosConfigurations."odo".config.system.build.toplevel ];
};
}
)
)
);
};

View File

@@ -3,7 +3,6 @@
lib,
pkgs,
self,
this_nixos_config,
...
}:
@@ -50,6 +49,9 @@
# ++ flakeOutPaths;
# closureInfo = pkgs.closureInfo { rootPaths = dependencies; };
# in
let
this_nixos_config = self.nixosConfigurations."${config.networking.hostName}";
in
{
imports = [ ];

View File

@@ -1,8 +1,8 @@
{
config,
lib,
all_nixos_configs,
pkgs,
self,
...
}:
@@ -76,14 +76,14 @@ let
sshUser = "nixworker";
sshKey = "/persist/manual/ssh/root/keys/id_ed25519";
maxJobs = 1;
supportedFeatures = all_nixos_configs."${hostname}".config.me.optimizations.system_features;
supportedFeatures = self.nixosConfigurations."${hostname}".config.me.optimizations.system_features;
protocol = "ssh-ng";
}
static_host_configs."${hostname}"
config.me.distributed_build.machines."${hostname}".additional_config
]
))
) (builtins.attrNames all_nixos_configs)
) (builtins.attrNames self.nixosConfigurations)
);
substituters_list = (
map (
@@ -92,7 +92,7 @@ let
config.me.distributed_build.machines."${hostname}".enable_substituter
&& config.me.distributed_build.machines."${hostname}".substituter_url != null
) (config.me.distributed_build.machines."${hostname}".substituter_url))
) (builtins.attrNames all_nixos_configs)
) (builtins.attrNames self.nixosConfigurations)
);
has_any_substituters = substituters_list != [ ];
in
@@ -107,7 +107,9 @@ in
description = "Whether we want to use multiple machines to perform a nixos-rebuild.";
};
distributed_build.machines = lib.mapAttrs (name: value: make_machine_config name) all_nixos_configs;
distributed_build.machines = lib.mapAttrs (
name: value: make_machine_config name
) self.nixosConfigurations;
};
config = lib.mkIf config.me.distributed_build.enable (

View File

@@ -80,6 +80,7 @@ in
systemd.services."build-cache" =
let
enabled_targets = [
"wip"
"odo"
"odo_update"
"odowork"

View File

@@ -1,5 +1,12 @@
output_directory = "/home/nixworker/persist/nix_builder"
[[targets]]
name = "wip"
repo = "https://code.fizz.buzz/talexander/machine_setup.git"
branch = "wip"
path = "nix/configuration"
attr = "wip"
[[targets]]
name = "odo"
repo = "https://code.fizz.buzz/talexander/machine_setup.git"