aboutsummaryrefslogtreecommitdiff
path: root/modules/home/impermanence/default.nix
blob: 081946c63a2af9b99ddbcc7a514b4848ca5e27d6 (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
52
{ options, config, osConfig, lib, namespace, inputs, host, ... }:

with lib; with lib.${namespace}; let
  cfg = config.${namespace}.impermanence // {
    inherit (osConfig.${namespace}.system.impermanence.home) enable location secure;
  };
in {
  imports = [
    inputs.impermanence.nixosModules.home-manager.impermanence
  ];

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

    enable = mkOption { type = uniq bool; };
    location = mkOption { type = uniq str; };
    secure.location = mkOption { type = uniq str; };
  };

  config = {
    ${namespace}.impermanence = {
      inherit (cfg) enable location secure;
    };

    home.persistence.${cfg.location} = {
      enable = cfg.enable;
      allowOther = true;

      directories = mkIf cfg.skeleton [
        ".local/share/applications"
        ".local/bin"

        "Downloads"
        "Documents"
        "Pictures"
        "Videos"
        "Music"
        "Games"
        "Links"
        "Persist"
      ];
    };

    home.persistence.${cfg.secure.location} = {
      enable = cfg.enable;
      allowOther = false;
    };
  };
}