{ config, lib, extra_modules, ... }: let cfg = config.vhack.persist; userDirectories = lib.debug.traceValSeqN 2 (lib.mapAttrs (_: dirs: { directories = dirs; }) cfg.userDirectories); in { options.vhack.persist = { enable = lib.mkEnableOption "persisting directories and files with impermanence"; directories = lib.mkOption { type = lib.types.listOf (lib.types.either lib.types.str (lib.types.submodule { options = { directory = lib.mkOption { type = lib.types.str; }; mode = lib.mkOption { type = lib.types.str; }; }; })); description = "The directories to persist"; }; userDirectories = lib.mkOption { type = lib.attrsOf lib.types.listOf (lib.types.either lib.types.str (lib.types.submodule { options = { directory = lib.mkOption { type = lib.types.str; }; mode = lib.mkOption { type = lib.types.str; }; }; })); default = []; description = "The directories to persist, for each user."; }; }; imports = [ extra_modules.nixos.impermanence ]; config = lib.mkIf cfg.enable { environment.persistence."/srv" = { hideMounts = true; inherit (cfg) directories; users = userDirectories; files = [ "/etc/machine-id" ]; }; }; }