summaryrefslogtreecommitdiff
path: root/lib/deploy.nix
blob: 1b8d1f20979534be520ff5bac5cb809bfd39b820 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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)
)