aboutsummaryrefslogtreecommitdiff
path: root/infra/modules/base/secrets.nix
blob: 3f81ea7e62e8f51836e46ca447b395c6928791f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{ inputs, ... }:
{
  flake.modules.nixos.base =
    { config, lib, ... }:
    {
      imports = [ inputs.sops-nix.nixosModules.sops ];

      sops = {
        defaultSopsFile = ./secrets.yaml;
        # Cannot use `/etc/host/` directly because then it will not load
        # the secrets that are marked `neededForUsers` correctly.
        age.sshKeyPaths = [ "${config.infra.persist.dir}/etc/ssh/ssh_host_ed25519_key" ];
      };

      virtualisation.vmVariant = {
        # Use the age key from the host (my development machine) to decrypt
        # in the VMs.
        #
        # TODO: Rework this to use the host SSH key instead.
        virtualisation.sharedDirectories.host-age = {
          source = "/home/vkcku/.config/sops/age";
          target = "/run/sops/age";
        };

        sops.age.keyFile = lib.mkForce "/run/sops/age/keys.txt";
      };
    };
}