flake.nix: add support for remote builders
This commit is contained in:
parent
b403a4413c
commit
0aef44118f
71
flake.nix
71
flake.nix
|
@ -31,8 +31,19 @@
|
|||
# Generate a small script for copying this flake to the
|
||||
# remote machine and bulding and switching there.
|
||||
# Can be run with nix run c3d2#deploy-…
|
||||
name: host:
|
||||
{ name
|
||||
, host ? "${name}.hq.c3d2.de"
|
||||
# remote builders to pass
|
||||
, builders ? null
|
||||
}:
|
||||
let target = "root@${host}";
|
||||
rebuildArg =
|
||||
"--flake ${self}#${name}" +
|
||||
(if builders != null
|
||||
then " --builders \"" +
|
||||
builtins.concatStringsSep " " builders +
|
||||
"\""
|
||||
else "");
|
||||
in pkgs.writeScriptBin "${name}-nixos-rebuild" ''
|
||||
#!${pkgs.runtimeShell}
|
||||
set -ev
|
||||
|
@ -40,9 +51,9 @@
|
|||
nix-copy-closure --to ${target} ${self}
|
||||
if [ "$1" = "--flakify" ]; then
|
||||
shift
|
||||
exec ssh -t ${target} "nix-shell -p nixFlakes -p git --command \"_NIXOS_REBUILD_REEXEC=1 nixos-rebuild --flake ${self}#${name} \"$@"
|
||||
exec ssh -t ${target} "nix-shell -p nixFlakes -p git --command '_NIXOS_REBUILD_REEXEC=1 nixos-rebuild ${rebuildArg} '$@"
|
||||
else
|
||||
exec ssh -t ${target} nixos-rebuild --flake ${self}#${name} $@
|
||||
exec ssh -t ${target} nixos-rebuild ${rebuildArg} $@
|
||||
fi
|
||||
'';
|
||||
mkWake = name:
|
||||
|
@ -55,31 +66,61 @@
|
|||
in {
|
||||
inherit (pkgs) bmxd;
|
||||
|
||||
dhcp-nixos-rebuild = mkDeploy "dhcp" hostRegistry.hosts.dhcp.ip4;
|
||||
dhcp-nixos-rebuild = mkDeploy {
|
||||
name = "dhcp";
|
||||
host = hostRegistry.hosts.dhcp.ip4;
|
||||
};
|
||||
|
||||
glotzbert-nixos-rebuild = mkDeploy "glotzbert" "glotzbert.hq.c3d2.de";
|
||||
glotzbert-nixos-rebuild = mkDeploy { name = "glotzbert"; };
|
||||
glotzbert-wake = mkWake "glotzbert";
|
||||
|
||||
pulsebert-nixos-rebuild = mkDeploy "pulsebert" "pulsebert.hq.c3d2.de";
|
||||
pulsebert-nixos-rebuild = mkDeploy {
|
||||
name = "pulsebert";
|
||||
builders = [ "ssh://client@172.22.99.110" ];
|
||||
};
|
||||
pulsebert-wake = mkWake "pulsebert";
|
||||
|
||||
yggdrasil-nixos-rebuild = mkDeploy "yggdrasil" "172.20.72.62";
|
||||
yggdrasil-nixos-rebuild = mkDeploy {
|
||||
name = "yggdrasil";
|
||||
host = "172.20.72.62";
|
||||
};
|
||||
|
||||
freifunk-nixos-rebuild = mkDeploy "freifunk" "freifunk.core.zentralwerk.org";
|
||||
freifunk-nixos-rebuild = mkDeploy {
|
||||
name = "freifunk";
|
||||
host = "freifunk.core.zentralwerk.org";
|
||||
};
|
||||
|
||||
matemat-nixos-rebuild = mkDeploy "matemat" hostRegistry.hosts.matemat.ip4;
|
||||
matemat-nixos-rebuild = mkDeploy {
|
||||
name = "matemat";
|
||||
};
|
||||
|
||||
scrape-nixos-rebuild = mkDeploy "scrape" hostRegistry.hosts.scrape.ip4;
|
||||
scrape-nixos-rebuild = mkDeploy {
|
||||
name = "scrape";
|
||||
host = hostRegistry.hosts.scrape.ip4;
|
||||
};
|
||||
|
||||
dn42-nixos-rebuild = mkDeploy "dn42" hostRegistry.hosts.dn42.ip4;
|
||||
dn42-nixos-rebuild = mkDeploy {
|
||||
name = "dn42";
|
||||
};
|
||||
|
||||
grafana-nixos-rebuild = mkDeploy "grafana" "grafana.hq.c3d2.de";
|
||||
grafana-nixos-rebuild = mkDeploy {
|
||||
name = "grafana";
|
||||
};
|
||||
|
||||
hydra-nixos-rebuild = mkDeploy "hydra" hostRegistry.hosts.hydra.ip4;
|
||||
hydra-nixos-rebuild = mkDeploy {
|
||||
name = "hydra";
|
||||
host = hostRegistry.hosts.hydra.ip4;
|
||||
};
|
||||
|
||||
mucbot-nixos-rebuild = mkDeploy "mucbot" hostRegistry.hosts.mucbot.ip4;
|
||||
mucbot-nixos-rebuild = mkDeploy {
|
||||
name = "mucbot";
|
||||
host = hostRegistry.hosts.mucbot.ip4;
|
||||
};
|
||||
|
||||
kibana-nixos-rebuild = mkDeploy "kibana" hostRegistry.hosts.kibana.ip4;
|
||||
kibana-nixos-rebuild = mkDeploy {
|
||||
name = "kibana";
|
||||
host = hostRegistry.hosts.kibana.ip4;
|
||||
};
|
||||
});
|
||||
|
||||
nixosConfigurations = let
|
||||
|
|
Loading…
Reference in New Issue
Block a user