Expose sh in $PATH in the base combinator

Some software reasonably expects `sh` to exist in PATH. I think I
haven't run into this before since a lot of nixified software explicitly
declares its dependencies on bash, but I've run into a few where this
isn't the case.
This commit is contained in:
Alex David 2025-10-26 09:48:38 -07:00
commit b843338efa
2 changed files with 16 additions and 4 deletions

View file

@ -20,7 +20,7 @@ spec = parallel $ inTestM $ do
`shouldOutput` "Hello, world!\n"
it "sets a sane default path" $ do
defaultPath <- evalNixExpr [i| "${pkgs.coreutils}/bin" |]
defaultPath <- evalNixExpr [i| "${pkgs.coreutils}/bin:/bin" |]
[i| jail "test" (sh ''echo -n "$PATH"'') [] |]
`shouldOutput` defaultPath
@ -29,6 +29,10 @@ spec = parallel $ inTestM $ do
[i| jail "test" (sh ''echo -n "''${MY_ENV_VAR-unset}"'') [] |]
`shouldOutput` "unset"
it "provides `sh` in the default path" $ do
[i| jail "test" (sh ''sh -c "echo hello"'') [] |]
`shouldOutput` "hello\n"
describe "forwarding package overrides to the jailed derivation" $ do
-- This is a nix expression of a package that prints out the value of an
-- overridable `run`: