about summary refs log tree commit diff stats
path: root/modules/by-name/im/impermanence/module.nix
blob: 513a91b73010e3e7c0ffc54824ab8d40fa054127 (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
{
  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.str;
      description = "The directories to persist";
    };
  };

  config = lib.mkIf cfg.enable {
    # needed for the hm impermanence config
    programs.fuse.userAllowOther = true;

    environment.persistence = {
      "/srv" = {
        hideMounts = true;
        inherit (cfg) directories;
        files = [
          "/etc/machine-id"
        ];
      };
    };
  };
}