{ config, inputs, lib, ... }: let cfg = config.nixfiles.modules.ark; in { imports = [ inputs.impermanence.nixosModules.impermanence (lib.mkAliasOptionModule [ "ark" ] [ "nixfiles" "modules" "ark" ] ) ]; options.nixfiles.modules.ark = let mkListOfAnythingOption = lib.mkOption { type = with lib.types; listOf anything; # Assumed to be matching with the upstream type. default = [ ]; }; in { enable = lib.mkEnableOption "persistent storage support via impermanence"; path = lib.mkOption { type = lib.types.str; default = "/ark"; }; directories = mkListOfAnythingOption; files = mkListOfAnythingOption; # hm = { # directories = mkListOfAnythingOption; # files = mkListOfAnythingOption; # }; }; config = lib.mkIf cfg.enable { environment.persistence.${cfg.path} = { hideMounts = true; enableDebugging = false; enableWarnings = 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; # }; # }; }; }