{ config, lib, ... }: let cfg = config.vhack.persist; in { options.vhack.persist = { enable = lib.mkEnableOption "impermanence"; directories = lib.mkOption { description = "The list of directories to persist"; type = lib.types.listOf (lib.types.coercedTo lib.types.str (d: {directory = d;}) (lib.types.attrsOf lib.types.anything)); }; }; config = lib.mkIf cfg.enable { environment.persistence."/srv" = { hideMounts = true; directories = [ "/etc/nixos" ] ++ cfg.directories; files = [ "/etc/machine-id" ]; }; }; }