blob: dbe697b1b31b903be83854b942ddf20e8b71946b [file] [log] [blame]
Sergiusz Bazanskic78cc132020-02-02 22:31:53 +01001self: super:
2
3let
4 machines = (import ./defs-machines.nix);
5 configurations = builtins.listToAttrs (map (machine: {
6 name = machine.fqdn;
7 value = super.nixos ({ config, pkgs, ... }: {
8 networking.hostName = machine.name;
9 imports = [
10 ./module-base.nix
11 ./module-kubernetes.nix
12 ];
13 });
14 }) machines);
15
16 scriptForMachine = machine: let
17 configuration = configurations."${machine.fqdn}";
18 in ''
19 set -e
20 remote=root@${machine.fqdn}
21 echo "Configuration for ${machine.fqdn} is ${configuration.toplevel}"
22 nix copy --no-check-sigs -s --to ssh://$remote ${configuration.toplevel}
23 ssh $remote ${configuration.toplevel}/bin/switch-to-configuration $1
24 '';
25
26 machineProvisioners = builtins.listToAttrs (map (machine: {
27 name = "provision-${machine.name}";
28 value = super.writeScriptBin "provision-${machine.name}" (scriptForMachine machine);
29 }) machines);
30in
31{
32 provision = ({
33 provision = super.writeScriptBin "provision"
34 (
35 ''
36 echo "Available provisioniers:"
37 '' + (builtins.concatStringsSep "\n" (map (machine: "echo ' provision-${machine.name}'") machines))
38 );
39 }) // machineProvisioners;
40}