From 921b443cc993bb3f34c924479cc2703d04cd03b8 Mon Sep 17 00:00:00 2001 From: Alex David Date: Thu, 17 Jul 2025 20:22:17 -0700 Subject: [PATCH] Remove `which` in builtin passwd combinator This remove the requirement on `which` binary when running any jail. This was preventing jailed apps from running within nix sandbox without manually specifying `pkgs.which` as a build input. --- lib.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib.nix b/lib.nix index edf75d3..d183239 100644 --- a/lib.nix +++ b/lib.nix @@ -55,9 +55,10 @@ in { (add-runtime '' if [ ! -e ${helpers.dataDirSubPath "passwd"} ] || [ ! -e ${helpers.dataDirSubPath "group"} ]; then + NOLOGIN=${pkgs.shadow}/bin/nologin mkdir -p ${helpers.dataDir} - echo "root:x:0:0:System administrator:/root:$(which nologin)" > ${helpers.dataDirSubPath "passwd"} - echo "$(id -un):x:$(id -u):$(id -g)::$HOME:$(which nologin)" >> ${helpers.dataDirSubPath "passwd"} + echo "root:x:0:0:System administrator:/root:$NOLOGIN" > ${helpers.dataDirSubPath "passwd"} + echo "$(id -un):x:$(id -u):$(id -g)::$HOME:$NOLOGIN" >> ${helpers.dataDirSubPath "passwd"} echo "root:x:0:" > ${helpers.dataDirSubPath "group"} echo "$(id -gn):x:$(id -g):" >> ${helpers.dataDirSubPath "group"} fi