Rework persisthome

* Use new data dir for persisted homes (~/.local/share/jail.nix/home
  instead of ~/.local/share/jails)
* Rename `persisthome` -> `persist-home` (with deprecation warning when
  using the old name)
This commit is contained in:
Alex David 2025-05-11 15:10:06 -07:00
commit d84314ffc7
2 changed files with 13 additions and 3 deletions

View file

@ -78,8 +78,17 @@ in rec {
path
(pkgs.writeText "jail-write-text-${lib.strings.sanitizeDerivationName (escape path)}" contents);
persisthome = name: compose [
persist-home = name: compose [
(add-runtime "mkdir -p ${helpers.dataDirSubPath "home/${name}"}")
(rw-bind (noescape (helpers.dataDirSubPath "home/${name}")) (noescape "~"))
];
############################################
# deprecated
persisthome = name: helpers.deprecatedCombinator
"persisthome is deprecated, use persist-home instead. When doing so, rename ~/.local/share/jails/${name} to ${helpers.dataDirSubPath "home/${name}"}"
(compose [
(add-runtime "mkdir -p ~/.local/share/jails/${lib.escapeShellArg name}")
(rw-bind (noescape "~/.local/share/jails/${lib.escapeShellArg name}") (noescape "~"))
];
]);
}

View file

@ -8,6 +8,7 @@
noescape = value: { raw = value; };
dataDir = "~/.local/share/jail.nix";
dataDirSubPath = subPath: "${dataDir}/${escape subPath}";
deprecatedCombinator = message: combinator: lib.warn "jail ${name}: ${message}" combinator;
};
combinators = import ./combinators.nix {