|
20 | 20 | done <$refs |
21 | 21 | ''; |
22 | 22 |
|
23 | | - mkTest = { name ? "", user ? "root", flakes ? true, isLocal ? true, deployArgs }: let |
| 23 | + mkTest = { name ? "", user ? "root", flakes ? true, isLocal ? true, sops ? false, deployArgs }: let |
24 | 24 | nodes = { |
25 | 25 | server = { nodes, ... }: { |
26 | 26 | imports = [ |
27 | | - ./server.nix |
| 27 | + (import ./server.nix { inherit pkgs sops; }) |
28 | 28 | (import ./common.nix { inherit inputs pkgs flakes; }) |
29 | 29 | ]; |
30 | 30 | virtualisation.additionalPaths = lib.optionals (!isLocal) [ |
|
36 | 36 | }; |
37 | 37 | client = { nodes, ... }: { |
38 | 38 | imports = [ (import ./common.nix { inherit inputs pkgs flakes; }) ]; |
39 | | - environment.systemPackages = [ pkgs.deploy-rs.deploy-rs ]; |
| 39 | + environment.systemPackages = [ pkgs.deploy-rs.deploy-rs ] ++ lib.optionals sops [ pkgs.sops ]; |
40 | 40 | # nix evaluation takes a lot of memory, especially in non-flake usage |
41 | 41 | virtualisation.memorySize = lib.mkForce 4096; |
42 | 42 | virtualisation.additionalPaths = lib.optionals isLocal [ |
|
61 | 61 |
|
62 | 62 | enable-flakes.url = "${builtins.toFile "use-flakes" (if flakes then "true" else "false")}"; |
63 | 63 | enable-flakes.flake = false; |
| 64 | + enable-sops.url = "${builtins.toFile "use-sops" (if sops then "true" else "false")}"; |
| 65 | + enable-sops.flake = false; |
64 | 66 | ''; |
65 | 67 |
|
66 | 68 | flake = builtins.toFile "flake.nix" |
|
97 | 99 | client.succeed("cp ${./server.nix} ./server.nix") |
98 | 100 | client.succeed("cp ${./common.nix} ./common.nix") |
99 | 101 | client.succeed("cp ${serverNetworkJSON} ./network.json") |
| 102 | +
|
| 103 | + # Prepare sops keys |
| 104 | + client.succeed("cp ${./sops/.sops.yaml} ./.sops.yaml") |
| 105 | + client.succeed("cp ${./sops/password.yaml} ./password.yaml") |
| 106 | + # this is where sops looks for private keys |
| 107 | + client.succeed("mkdir -p /root/.config/sops/age/") |
| 108 | + client.succeed("cp ${./sops/age_private.txt} /root/.config/sops/age/keys.txt") |
| 109 | +
|
100 | 110 | client.succeed("nix --extra-experimental-features flakes flake lock") |
101 | 111 |
|
102 | 112 | # Setup SSH key |
|
173 | 183 | flakes = true; |
174 | 184 | deployArgs = "--file . --targets server"; |
175 | 185 | }; |
| 186 | + sops = mkTest { |
| 187 | + name = "sops"; |
| 188 | + sops = true; |
| 189 | + deployArgs = "-s .#server --sudo-file ./password.yaml --sudo-secret deploy"; |
| 190 | + }; |
176 | 191 | } |
0 commit comments