about summary refs log tree commit diff
path: root/modules/persistence.nix
blob: 4c11588de00277561f74d6adafc099d0c32d2162 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{ config, inputs, lib, ... }:


with lib;
let
  cfg = config.modules.persistence;
in
{
  imports = [
    inputs.impermanence.nixosModules.impermanence
  ];

  options.modules.persistence = {
    enable = mkEnableOption "impermanence persistence";

    storagePath = lib.mkOption {
      type = types.path;
      description = ''
        The path to persistent storage where the real
        files and directories should be stored.
      '';
    };

    directories = mkOption {
      type = types.listOf types.str;
    };
  };

  config = mkIf cfg.enable {
    fileSystems.${cfg.storagePath}.neededForBoot = true;

    environment.persistence.${cfg.storagePath}.directories = cfg.directories;

    services.openssh.hostKeys = [
      {
        path = "${cfg.storagePath}/ssh/ssh_host_ed25519_key";
        type = "ed25519";
      }
      {
        path = "${cfg.storagePath}/ssh/ssh_host_rsa_key";
        type = "rsa";
        bits = 4096;
      }
    ];
  };
}