Compare commits
No commits in common. "11ae1097de717fb03d2b39838f3d81abfc75e276" and "06ca3a547c78b17565d421c22fd3e5be7b493941" have entirely different histories.
11ae1097de
...
06ca3a547c
|
@ -169,7 +169,7 @@
|
||||||
# file = ./secrets/${hostname}.yaml;
|
# file = ./secrets/${hostname}.yaml;
|
||||||
# exists = builtins.pathExists file;
|
# exists = builtins.pathExists file;
|
||||||
# yaml = lib.removeAttrs (lib.importYAML file) ["sops"];
|
# yaml = lib.removeAttrs (lib.importYAML file) ["sops"];
|
||||||
# secrets = lib.attrNames yaml; # TODO: recurse
|
# secrets = lib.attrNames yaml;
|
||||||
#in
|
#in
|
||||||
# if !exists then {} else lib.mkMerge (lib.forEach secrets (secret:
|
# if !exists then {} else lib.mkMerge (lib.forEach secrets (secret:
|
||||||
# lib.mkIf (config.sops.secrets ? secret) {
|
# lib.mkIf (config.sops.secrets ? secret) {
|
||||||
|
|
|
@ -5,10 +5,6 @@
|
||||||
boot.loader.efi.canTouchEfiVariables = true;
|
boot.loader.efi.canTouchEfiVariables = true;
|
||||||
boot.loader.efi.efiSysMountPoint = "/boot/efi";
|
boot.loader.efi.efiSysMountPoint = "/boot/efi";
|
||||||
|
|
||||||
boot.binfmt.emulatedSystems = [
|
|
||||||
"aarch64-linux"
|
|
||||||
];
|
|
||||||
|
|
||||||
services.nfs.server.enable = false; # TODO: remove?
|
services.nfs.server.enable = false; # TODO: remove?
|
||||||
|
|
||||||
imports = [
|
imports = [
|
||||||
|
|
|
@ -11,11 +11,11 @@
|
||||||
# buildMachine.protocol
|
# buildMachine.protocol
|
||||||
# ssh.listenUser
|
# ssh.listenUser
|
||||||
# ssh.listenPort
|
# ssh.listenPort
|
||||||
# ssh.listenPublicKey # cat /etc/ssh/ssh_host_ed25519_key.pub || ssh-keyscan {{fqdn}}
|
# ssh.listenPublicKey # cat /etc/ssh/ssh_host_ed25519_key.pub || ssh-keyscan {{fqdn}}
|
||||||
# ssh.proxyJump # optional hostname
|
# ssh.userPublicKey # sudo ssh-keygen -t ed25519 && sudo cat /root/.ssh/id_ed25519.pub
|
||||||
|
# ssh.proxyJump # optional hostname
|
||||||
|
# ssh.userPrivateKey # optional IdentityFile to use
|
||||||
# ssh.connectTimeout
|
# ssh.connectTimeout
|
||||||
# ssh.userPrivateKey # optional IdentityFile to use
|
|
||||||
# ssh.userPublicKey # sudo ssh-keygen -t ed25519 && sudo cat /root/.ssh/id_ed25519.pub
|
|
||||||
|
|
||||||
|
|
||||||
# buildMachine.supportedFeatures:
|
# buildMachine.supportedFeatures:
|
||||||
|
@ -32,8 +32,8 @@ buildMachine.speedFactor = 1
|
||||||
buildMachine.supportedFeatures = []
|
buildMachine.supportedFeatures = []
|
||||||
buildMachine.mandatoryFeatures = []
|
buildMachine.mandatoryFeatures = []
|
||||||
buildMachine.protocol = "ssh" # "ssh-ng"
|
buildMachine.protocol = "ssh" # "ssh-ng"
|
||||||
# ssh.listenUser = "pbsds" # TODO: change
|
ssh.listenUser = "pbsds" # TODO: change
|
||||||
ssh.listenUser = "nixbld-remote"
|
# ssh.listenUser = "nixbld-remote"
|
||||||
ssh.listenPort = 22
|
ssh.listenPort = 22
|
||||||
ssh.connectTimeout = 3
|
ssh.connectTimeout = 3
|
||||||
|
|
||||||
|
@ -41,7 +41,6 @@ ssh.connectTimeout = 3
|
||||||
# headless: one job per 4 threads and 8GB RAM
|
# headless: one job per 4 threads and 8GB RAM
|
||||||
# graphical: one job
|
# graphical: one job
|
||||||
|
|
||||||
|
|
||||||
["bolle.pbsds.net"]
|
["bolle.pbsds.net"]
|
||||||
buildMachine.systems = ["x86_64-linux", "i686-linux", "riscv64-linux"]
|
buildMachine.systems = ["x86_64-linux", "i686-linux", "riscv64-linux"]
|
||||||
buildMachine.maxJobs = 3 # 12 threads 32GB
|
buildMachine.maxJobs = 3 # 12 threads 32GB
|
||||||
|
@ -52,7 +51,6 @@ ssh.proxyJump = "isvegg.pvv.ntnu.no"
|
||||||
|
|
||||||
["eple.pbsds.net"] # r9 290x
|
["eple.pbsds.net"] # r9 290x
|
||||||
aliases = [ "eple.tail9aac63.ts.net" ]
|
aliases = [ "eple.tail9aac63.ts.net" ]
|
||||||
buildMachine.systems = ["x86_64-linux", "i686-linux", "aarch64-linux"]
|
|
||||||
buildMachine.maxJobs = 3 # 12 threads 32GB
|
buildMachine.maxJobs = 3 # 12 threads 32GB
|
||||||
buildMachine.speedFactor = 3 # i7-5820K
|
buildMachine.speedFactor = 3 # i7-5820K
|
||||||
buildMachine.supportedFeatures = ["kvm", "big-parallel", "nixos-test"]
|
buildMachine.supportedFeatures = ["kvm", "big-parallel", "nixos-test"]
|
||||||
|
@ -110,7 +108,6 @@ ssh.listenPort = 2222
|
||||||
ssh.listenPublicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILD7+tE6rm742fz+nqa3+zlglMuzCzOQlc0OSJssvgVL"
|
ssh.listenPublicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILD7+tE6rm742fz+nqa3+zlglMuzCzOQlc0OSJssvgVL"
|
||||||
ssh.userPublicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJVohqGMKp/UEZtb71RSBBXOEGX4o3lN5GYBlP7HEKbs root@brumlebasse"
|
ssh.userPublicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJVohqGMKp/UEZtb71RSBBXOEGX4o3lN5GYBlP7HEKbs root@brumlebasse"
|
||||||
|
|
||||||
|
|
||||||
["isvegg.pvv.ntnu.no"]
|
["isvegg.pvv.ntnu.no"]
|
||||||
# buildMachine.maxJobs = 1 # 4 threads 16GB
|
# buildMachine.maxJobs = 1 # 4 threads 16GB
|
||||||
buildMachine.speedFactor = 1 # i5-3570
|
buildMachine.speedFactor = 1 # i5-3570
|
||||||
|
|
|
@ -4,15 +4,8 @@
|
||||||
# TODO: https://exozy.me/about
|
# TODO: https://exozy.me/about
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (builtins)
|
inherit (builtins) map fromTOML readFile elem attrNames attrValues;
|
||||||
map
|
inherit (lib) mkIf;
|
||||||
fromTOML
|
|
||||||
toString
|
|
||||||
readFile
|
|
||||||
elem
|
|
||||||
attrNames
|
|
||||||
attrValues
|
|
||||||
;
|
|
||||||
|
|
||||||
known-hosts = let
|
known-hosts = let
|
||||||
known-hosts' = lib.importTOML ../hosts/known-hosts.toml; # TODO: eww
|
known-hosts' = lib.importTOML ../hosts/known-hosts.toml; # TODO: eww
|
||||||
|
@ -20,13 +13,14 @@ let
|
||||||
lib.pipe known-hosts' [
|
lib.pipe known-hosts' [
|
||||||
(lib.flip lib.removeAttrs ["__default__"])
|
(lib.flip lib.removeAttrs ["__default__"])
|
||||||
(lib.mapAttrs (fqdn: host:
|
(lib.mapAttrs (fqdn: host:
|
||||||
lib.recursiveUpdate (known-hosts'."__default__" or {}) host
|
lib.recursiveUpdate (
|
||||||
|
(known-hosts'."__default__" or {})
|
||||||
|
// { isAlias = false; }
|
||||||
|
) host
|
||||||
))
|
))
|
||||||
(lib.mapAttrsToList (fqdn: host:
|
(lib.mapAttrsToList (fqdn: host: let
|
||||||
let
|
|
||||||
allHostnames = [ fqdn ] ++ host.aliases;
|
allHostnames = [ fqdn ] ++ host.aliases;
|
||||||
in
|
in lib.forEach allHostnames (alias:
|
||||||
lib.forEach allHostnames (alias:
|
|
||||||
lib.nameValuePair
|
lib.nameValuePair
|
||||||
alias
|
alias
|
||||||
(host // {
|
(host // {
|
||||||
|
@ -41,8 +35,8 @@ let
|
||||||
hostNames = attrNames known-hosts;
|
hostNames = attrNames known-hosts;
|
||||||
thisHost = known-hosts.${config.networking.fqdn};
|
thisHost = known-hosts.${config.networking.fqdn};
|
||||||
thisHostIsBuilder = thisHost.buildMachine.maxJobs > 0;
|
thisHostIsBuilder = thisHost.buildMachine.maxJobs > 0;
|
||||||
thisHostIsBuildee = thisHost.ssh ? userPublicKey;
|
thisHostIsHopHost = builtins.elem config.networking.fqdn (lib.forEach (attrValues known-hosts) (host: host.ssh.proxyJump or null));
|
||||||
thisHostIsHopHost = elem config.networking.fqdn (lib.forEach (attrValues known-hosts) (host: host.ssh.proxyJump or null));
|
thisHostIsConsumer = thisHost.ssh ? userPublicKey;
|
||||||
|
|
||||||
mkRemoteConfig = fqdn: let
|
mkRemoteConfig = fqdn: let
|
||||||
thatHost = known-hosts.${fqdn};
|
thatHost = known-hosts.${fqdn};
|
||||||
|
@ -52,11 +46,11 @@ let
|
||||||
sshUser = thatHost.ssh.listenUser;
|
sshUser = thatHost.ssh.listenUser;
|
||||||
};
|
};
|
||||||
thatHostIsBuilder = thatHost.buildMachine.maxJobs > 0;
|
thatHostIsBuilder = thatHost.buildMachine.maxJobs > 0;
|
||||||
thatHostIsBuildee = thatHost.ssh ? userPublicKey && thisHostIsBuilder;
|
thatHostIsConsumer = thatHost.ssh ? userPublicKey && thisHostIsBuilder;
|
||||||
thatHostIsThis = elem config.networking.fqdn ([ fqdn ] ++ thatHost.aliases);
|
thatHostIsThis = builtins.elem config.networking.fqdn ([ fqdn ] ++ thatHost.aliases);
|
||||||
in lib.mkIf (!thatHostIsThis) ( lib.mkMerge [
|
in mkIf (!thatHostIsThis) ( lib.mkMerge [
|
||||||
# out
|
# out
|
||||||
(lib.mkIf (thisHostIsBuildee && thatHostIsBuilder) {
|
(lib.mkIf (thisHostIsConsumer && thatHostIsBuilder) {
|
||||||
|
|
||||||
# TODO: Allow setting speedFactor for local builds, as local is currently fixed to 0
|
# TODO: Allow setting speedFactor for local builds, as local is currently fixed to 0
|
||||||
# https://github.com/NixOS/nix/issues/2457
|
# https://github.com/NixOS/nix/issues/2457
|
||||||
|
@ -68,17 +62,17 @@ let
|
||||||
|
|
||||||
})
|
})
|
||||||
# out or jump
|
# out or jump
|
||||||
(lib.mkIf (thisHostIsBuildee && thatHost.ssh ? listenPublicKey) {
|
(lib.mkIf (thisHostIsConsumer && thatHost.ssh ? listenPublicKey) {
|
||||||
programs.ssh.knownHosts.${fqdn}.publicKey = thatHost.ssh.listenPublicKey;
|
programs.ssh.knownHosts.${fqdn}.publicKey = thatHost.ssh.listenPublicKey;
|
||||||
# TODO: use nix.buildMachines.*.publicHostKey ?
|
# TODO: use nix.buildMachines.*.publicHostKey ?
|
||||||
|
|
||||||
# timeouts are great when remote is unresponsive. nix doesn't care, lix is way and tests each remote only once
|
# timeouts are great when remote is unresponsive. nix doesn't care, lix is way and tests each remote only once
|
||||||
programs.ssh.extraConfig = ''
|
programs.ssh.extraConfig = ''
|
||||||
Host ${fqdn}
|
Host ${fqdn}
|
||||||
ConnectTimeout ${toString thatHost.ssh.connectTimeout}
|
ConnectTimeout ${builtins.toString thatHost.ssh.connectTimeout}
|
||||||
Port ${toString thatHost.ssh.listenPort}
|
Port ${builtins.toString thatHost.ssh.listenPort}
|
||||||
${lib.optionalString (thatHost.ssh ? proxyJump) ''
|
${lib.optionalString (thatHost.ssh ? proxyJump) ''
|
||||||
ProxyJump ${thatJump.ssh.listenUser}@${thatHost.ssh.proxyJump}:${toString thatJump.ssh.listenPort}
|
ProxyJump ${thatJump.ssh.listenUser}@${thatHost.ssh.proxyJump}:${builtins.toString thatJump.ssh.listenPort}
|
||||||
''}
|
''}
|
||||||
${lib.optionalString (thatHost.ssh ? userPrivateKey) ''
|
${lib.optionalString (thatHost.ssh ? userPrivateKey) ''
|
||||||
IdentityFile ${thatHost.ssh.userPrivateKey}
|
IdentityFile ${thatHost.ssh.userPrivateKey}
|
||||||
|
@ -91,14 +85,14 @@ let
|
||||||
|
|
||||||
})
|
})
|
||||||
# in
|
# in
|
||||||
(lib.mkIf ((thisHostIsBuilder || thisHostIsHopHost) && thatHostIsBuildee) {
|
(mkIf ((thisHostIsBuilder || thisHostIsHopHost) && thatHostIsConsumer) {
|
||||||
users.users.${thisHost.ssh.listenUser} = {
|
users.users.${thisHost.ssh.listenUser} = {
|
||||||
isSystemUser = lib.mkDefault (!config.users.users.${thisHost.ssh.listenUser}.isNormalUser);
|
isSystemUser = lib.mkDefault (!config.users.users.${thisHost.ssh.listenUser}.isNormalUser);
|
||||||
openssh.authorizedKeys.keys = [ thatHost.ssh.userPublicKey ];
|
openssh.authorizedKeys.keys = [ thatHost.ssh.userPublicKey ];
|
||||||
group = lib.mkOptionDefault "nogroup";
|
group = lib.mkOptionDefault "nogroup";
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
(lib.mkIf (thisHostIsBuilder && thatHostIsBuildee) {
|
(mkIf (thisHostIsBuilder && thatHostIsConsumer) {
|
||||||
nix.settings.allowed-users = [ thisHost.ssh.listenUser ];
|
nix.settings.allowed-users = [ thisHost.ssh.listenUser ];
|
||||||
nix.settings.trusted-users = [ thisHost.ssh.listenUser ];
|
nix.settings.trusted-users = [ thisHost.ssh.listenUser ];
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue