From d84314ffc7b0836b94478b4524099efadf051d81 Mon Sep 17 00:00:00 2001 From: Alex David Date: Sun, 11 May 2025 15:10:06 -0700 Subject: [PATCH] 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) --- combinators.nix | 15 ++++++++++++--- lib.nix | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/combinators.nix b/combinators.nix index e2ddb92..b773579 100644 --- a/combinators.nix +++ b/combinators.nix @@ -78,8 +78,17 @@ in rec { path (pkgs.writeText "jail-write-text-${lib.strings.sanitizeDerivationName (escape path)}" contents); - persisthome = name: compose [ - (add-runtime "mkdir -p ~/.local/share/jails/${lib.escapeShellArg name}") - (rw-bind (noescape "~/.local/share/jails/${lib.escapeShellArg name}") (noescape "~")) + 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 "~")) + ]); } diff --git a/lib.nix b/lib.nix index 6c82a9d..ec6dadc 100644 --- a/lib.nix +++ b/lib.nix @@ -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 {