about summary refs log tree commit diff
path: root/modules/nixos/common/ark.nix
blob: 3a1205049c9b388cbfbbeed3effe34bbf4a58717 (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
{
  config,
  inputs,
  lib,
  ...
}:
with lib; let
  cfg = config.nixfiles.modules.ark;
in {
  imports = [
    (mkAliasOptionModule ["ark"] ["nixfiles" "modules" "ark"])
    inputs.impermanence.nixosModules.impermanence
  ];

  options.nixfiles.modules.ark = let
    mkListOfAnythingOption = mkOption {
      type = with types; listOf anything; # Assumed to be matching with the upstream type.
      default = [];
    };
  in {
    enable = mkEnableOption "persistent storage support via impermanence";

    path = mkOption {
      type = types.str;
      default = "/ark";
    };

    directories = mkListOfAnythingOption;
    files = mkListOfAnythingOption;
    # hm = {
    #   directories = mkListOfAnythingOption;
    #   files = mkListOfAnythingOption;
    # };
  };

  config = mkIf cfg.enable {
    environment.persistence.${cfg.path} = {
      hideMounts = true;
      enableDebugging = false;
      inherit (cfg) directories files;
    };

    # NOTE We can't reliably[1] use this, so for the time being, this will stay
    # commented out. Probably forever.
    #
    # [1]: https://github.com/nix-community/impermanence/issues/18
    #
    # hm = {
    #   imports = [inputs.impermanence.nixosModules.home-manager.impermanence];
    #   home.persistence."${cfg.path}/${config.my.home}" = {
    #     allowOther = false;
    #     inherit (cfg.hm) directories files;
    #   };
    # };
  };
}

Consider giving Nix/NixOS a try! <3