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

  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