aboutsummaryrefslogtreecommitdiff
path: root/snowfall/modules/home/impermanence/default.nix
blob: c1d1a2d8e258371414cbaac9a996f78b99e99ab9 (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
47
48
49
50
51
{ options, config, lib, namespace, inputs, host, ... }:

with lib; with lib.${namespace}; let
  cfg = config.${namespace}.impermanence;
  hosts = [ "c-pc" ];
in {
  imports = [
    inputs.impermanence.nixosModules.home-manager.impermanence
  ];

  options.${namespace}.impermanence = with types; {
    skeleton = mkOption {
      type = bool;
      default = true;
    };

    location = mkOption {
      type = str;
      default = "/persist/home";
    };

    secure = {
      location = mkOption {
        type = str;
        default = "/persist/secure/home";
      };
    };
  };

  config = {
    home.persistence.${cfg.location} = {
      enable = builtins.elem host hosts;
      allowOther = true;

      directories = mkIf cfg.skeleton [
        "Downloads"
        "Documents"
        "Pictures"
        "Videos"
        "Music"
        "Games"
        "Persist"
      ];
    };

    home.persistence.${cfg.secure.location} = {
      enable = builtins.elem host hosts;
      allowOther = false;
    };
  };
}