about summary refs log tree commit diff stats
path: root/modules/by-name/im/impermanence/module.nix
blob: 9c28934630f55e37b77397c88c980e134a0e8e86 (plain) (blame)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{
  config,
  lib,
  ...
}: let
  cfg = config.soispha.impermanence;
in {
  options.soispha.impermanence = {
    enable = lib.mkEnableOption "persisting directories and files with impermanence";

    directories = lib.mkOption {
      type = lib.types.listOf (lib.types.either lib.types.str (lib.types.submodule {
        options = {
          directory = lib.mkOption {
            type = lib.types.str;
          };
          mode = lib.mkOption {
            type = lib.types.str;
          };
        };
      }));
      description = "The directories to persist";
    };
  };

  config = lib.mkIf cfg.enable {
    environment.persistence = {
      "/srv" = {
        hideMounts = true;
        inherit (cfg) directories;

        users.soispha = {
          directories = [
            # TODO: These should all be moved to their respective modules <2024-12-08>
            ".local/share"

            ".local/state/nvim"
            ".local/state/mpv"
            ".local/state/wireplumber"

            ".config/Signal"
            ".config/Element"
            ".config/iamb/profiles"

            ".cache"
            ".mozilla"

            "media"
            "repos"
            "school"
          ];
        };

        files = [
          "/etc/machine-id"
        ];
      };
    };
  };
}