summaryrefslogtreecommitdiff
path: root/lib/deploy.nix
diff options
context:
space:
mode:
authorstuebinm2021-03-03 00:51:39 +0100
committerstuebinm2021-03-03 00:51:39 +0100
commitd96fbd63510048bf56d3d600a65f7983096c1bb1 (patch)
tree192afecb97bcdb829e1461bebc283cc86fb99586 /lib/deploy.nix
migrating config
This deploy logic is primarily based on hxchn's deploy lib [1], with some slight modifications to make it work with my setup. Everything seems to work fine for now. However, I am unsure about the usage of niv — the config doesn't seem to gain much from it, apart from (some) additional complexity. [1] https://gitlab.com/hexchen/nixfiles
Diffstat (limited to 'lib/deploy.nix')
-rw-r--r--lib/deploy.nix23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/deploy.nix b/lib/deploy.nix
new file mode 100644
index 0000000..1b8d1f2
--- /dev/null
+++ b/lib/deploy.nix
@@ -0,0 +1,23 @@
+{ pkgs, hosts, groups }:
+
+with pkgs.lib;
+
+(
+ mapAttrs (name: hosts: pkgs.writeScript "deploy-group-${name}" ''
+ #!${pkgs.runtimeShell}
+ export PATH=
+ ${concatMapStrings (host: ''
+ echo "deploying ${host.config.networking.hostName}..."
+ ${host.config.system.build.deployScript} $1 &
+ PID_LIST+=" $!"
+ '') hosts}
+ # FIXME: remove jobs from PIDLIST once they finish
+ trap "kill $PID_LIST" SIGINT
+ wait $PID_LIST
+ '') groups
+) // (
+ mapAttrs
+ (name: host: host.config.system.build.deployScript)
+ (filterAttrs (_: host: host.config.hexchen.deploy.enable) hosts)
+)
+