fix: eval error
This commit is contained in:
parent
2a1262df2f
commit
f761ede7ff
1 changed files with 31 additions and 34 deletions
|
|
@ -11,48 +11,46 @@
|
||||||
mkEnableOption
|
mkEnableOption
|
||||||
mkIf
|
mkIf
|
||||||
mapAttrsToList
|
mapAttrsToList
|
||||||
attrNames
|
|
||||||
map
|
|
||||||
concatLines
|
concatLines
|
||||||
mkOption
|
mkOption
|
||||||
types
|
types
|
||||||
;
|
;
|
||||||
cfg = config.our.buildMachines;
|
cfg = config.our.buildMachines;
|
||||||
|
|
||||||
others = filterAttrs (n: _v: n != config.networking.hostName) self.nixosConfigurations;
|
builders = filterAttrs (_n: v: v.config.our.buildMachines.enable) self.nixosConfigurations;
|
||||||
|
others = filterAttrs (n: _v: n != config.networking.hostName) builders;
|
||||||
|
|
||||||
mkBuilder = hostName: attrs: let
|
mkBuilder = hostName: attrs: let
|
||||||
config' = attrs.config;
|
config' = attrs.config;
|
||||||
cfg' = config'.our.buildMachines;
|
cfg' = config'.our.buildMachines;
|
||||||
pkgs' = attrs.pkgs;
|
pkgs' = attrs.pkgs;
|
||||||
in
|
in {
|
||||||
mkIf cfg'.enable {
|
# NOTE: https://github.com/NixOS/nix/issues/3177
|
||||||
# NOTE: https://github.com/NixOS/nix/issues/3177
|
hostName =
|
||||||
hostName =
|
if hostName == config.networking.hostName
|
||||||
if hostName == config.networking.hostName
|
then "local?root=/nix/store"
|
||||||
then "local?root=/nix/store"
|
else hostName;
|
||||||
else hostName;
|
sshUser =
|
||||||
sshUser =
|
if hostName == config.networking.hostName
|
||||||
if hostName == config.networking.hostName
|
then null
|
||||||
then null
|
else "remotebuild";
|
||||||
else "remotebuild";
|
# CPU architecture of the builder, and the operating system it runs.
|
||||||
# CPU architecture of the builder, and the operating system it runs.
|
# If your builder supports multiple architectures
|
||||||
# If your builder supports multiple architectures
|
# (e.g. search for "binfmt" for emulation),
|
||||||
# (e.g. search for "binfmt" for emulation),
|
systems = [pkgs'.system] ++ config'.boot.binfmt.emulatedSystems;
|
||||||
systems = [pkgs'.system] ++ config'.boot.binfmt.emulatedSystems;
|
# Nix custom ssh-variant that avoids lots of "trusted-users" settings pain
|
||||||
# Nix custom ssh-variant that avoids lots of "trusted-users" settings pain
|
protocol =
|
||||||
protocol =
|
if hostName == config.networking.hostName
|
||||||
if hostName == config.networking.hostName
|
then null
|
||||||
then null
|
else "ssh-ng";
|
||||||
else "ssh-ng";
|
# default is 1 but may keep the builder idle in between builds
|
||||||
# default is 1 but may keep the builder idle in between builds
|
maxJobs = 3;
|
||||||
maxJobs = 3;
|
speedFactor = 1;
|
||||||
speedFactor = 1;
|
supportedFeatures = cfg'.supportedFeatures;
|
||||||
supportedFeatures = cfg'.supportedFeatures;
|
mandatoryFeatures = [];
|
||||||
mandatoryFeatures = [];
|
};
|
||||||
};
|
|
||||||
|
|
||||||
buildMachines = mapAttrsToList mkBuilder self.nixosConfigurations;
|
buildMachines = mapAttrsToList mkBuilder builders;
|
||||||
|
|
||||||
remotebuildKeys =
|
remotebuildKeys =
|
||||||
mapAttrsToList (
|
mapAttrsToList (
|
||||||
|
|
@ -60,12 +58,11 @@
|
||||||
)
|
)
|
||||||
others;
|
others;
|
||||||
|
|
||||||
mkMatch = host: ''
|
mkMatch = hostName: _v: ''
|
||||||
Match User remotebuild Host ${host}
|
Match User remotebuild Host ${hostName}
|
||||||
IdentityFile ${config.clan.core.vars.generators.remotebuild.files."ssh.id_ed25519".path}
|
IdentityFile ${config.clan.core.vars.generators.remotebuild.files."ssh.id_ed25519".path}
|
||||||
'';
|
'';
|
||||||
othersName = attrNames others;
|
sshConfig = concatLines (mapAttrsToList mkMatch others);
|
||||||
sshConfig = concatLines (map mkMatch othersName);
|
|
||||||
in {
|
in {
|
||||||
options.our.buildMachines = {
|
options.our.buildMachines = {
|
||||||
enable = mkEnableOption "Use this machine as a remoteBuilder for others and vice versa.";
|
enable = mkEnableOption "Use this machine as a remoteBuilder for others and vice versa.";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue