From 99010959c90b59d8d37069f69ff98cc1a5ff3a2f Mon Sep 17 00:00:00 2001 From: Soispha Peetz Date: Sat, 31 Oct 2026 10:28:04 +0100 Subject: {modules/impermanence,common/vhack}: Rework and move always on config to common --- modules/by-name/im/impermanence/module.nix | 50 +++++++++++++++++++++++++----- modules/common/vhack/default.nix | 9 ++++++ 2 files changed, 51 insertions(+), 8 deletions(-) (limited to 'modules') diff --git a/modules/by-name/im/impermanence/module.nix b/modules/by-name/im/impermanence/module.nix index 1c916e2..0fbd742 100644 --- a/modules/by-name/im/impermanence/module.nix +++ b/modules/by-name/im/impermanence/module.nix @@ -1,27 +1,61 @@ { config, lib, + 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 "impermanence"; + enable = lib.mkEnableOption "persisting directories and files with 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)); + 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 = [ + modules.impermanence.nixosModules.impermanence + ]; + config = lib.mkIf cfg.enable { environment.persistence."/srv" = { hideMounts = true; - directories = - [ - "/etc/nixos" - ] - ++ cfg.directories; + inherit (cfg) directories; + + users = userDirectories; + files = [ "/etc/machine-id" ]; diff --git a/modules/common/vhack/default.nix b/modules/common/vhack/default.nix index 0b8b060..9189a28 100644 --- a/modules/common/vhack/default.nix +++ b/modules/common/vhack/default.nix @@ -18,4 +18,13 @@ } ]; }; + + vhack.persist = { + enable = true; + + directories = [ + "/etc/nixos" + "/var/lib/systemd" + ]; + }; } -- cgit v1.3.1