mirror of
https://github.com/NixOS/nix.git
synced 2024-11-22 06:42:28 +00:00
Merge pull request #11902 from roberth/fix-issue-11892
Fix issue #11892
This commit is contained in:
commit
6b0aceedc5
@ -340,13 +340,15 @@ static void main_nix_build(int argc, char * * argv)
|
|||||||
exprs = {state->parseStdin()};
|
exprs = {state->parseStdin()};
|
||||||
else
|
else
|
||||||
for (auto i : remainingArgs) {
|
for (auto i : remainingArgs) {
|
||||||
auto baseDir = inShebang && !packages ? absPath(dirOf(script)) : i;
|
if (fromArgs) {
|
||||||
|
auto shebangBaseDir = absPath(dirOf(script));
|
||||||
if (fromArgs)
|
|
||||||
exprs.push_back(state->parseExprFromString(
|
exprs.push_back(state->parseExprFromString(
|
||||||
std::move(i),
|
std::move(i),
|
||||||
(inShebang && compatibilitySettings.nixShellShebangArgumentsRelativeToScript) ? lookupFileArg(*state, baseDir) : state->rootPath(".")
|
(inShebang && compatibilitySettings.nixShellShebangArgumentsRelativeToScript)
|
||||||
|
? lookupFileArg(*state, shebangBaseDir)
|
||||||
|
: state->rootPath(".")
|
||||||
));
|
));
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
auto absolute = i;
|
auto absolute = i;
|
||||||
try {
|
try {
|
||||||
|
@ -167,6 +167,35 @@ EOF
|
|||||||
chmod a+x $TEST_ROOT/marco/polo/default.nix
|
chmod a+x $TEST_ROOT/marco/polo/default.nix
|
||||||
(cd $TEST_ROOT/marco && ./polo/default.nix | grepQuiet "Polo")
|
(cd $TEST_ROOT/marco && ./polo/default.nix | grepQuiet "Polo")
|
||||||
|
|
||||||
|
# https://github.com/NixOS/nix/issues/11892
|
||||||
|
mkdir $TEST_ROOT/issue-11892
|
||||||
|
cat >$TEST_ROOT/issue-11892/shebangscript <<EOF
|
||||||
|
#!$(type -P env) nix-shell
|
||||||
|
#! nix-shell -I nixpkgs=$shellDotNix
|
||||||
|
#! nix-shell -p 'callPackage (import ./my_package.nix) {}'
|
||||||
|
#! nix-shell -i bash
|
||||||
|
set -euxo pipefail
|
||||||
|
my_package
|
||||||
|
EOF
|
||||||
|
cat >$TEST_ROOT/issue-11892/my_package.nix <<EOF
|
||||||
|
{ stdenv, shell, ... }:
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
name = "my_package";
|
||||||
|
buildCommand = ''
|
||||||
|
mkdir -p \$out/bin
|
||||||
|
( echo "#!\${shell}"
|
||||||
|
echo "echo 'ok' 'baz11892'"
|
||||||
|
) > \$out/bin/my_package
|
||||||
|
cat \$out/bin/my_package
|
||||||
|
chmod a+x \$out/bin/my_package
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
chmod a+x $TEST_ROOT/issue-11892/shebangscript
|
||||||
|
$TEST_ROOT/issue-11892/shebangscript \
|
||||||
|
| tee /dev/stderr \
|
||||||
|
| grepQuiet "ok baz11892"
|
||||||
|
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
# Flake equivalents #
|
# Flake equivalents #
|
||||||
|
@ -37,7 +37,7 @@ let pkgs = rec {
|
|||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
ln -s ${setupSh} $out/setup
|
ln -s ${setupSh} $out/setup
|
||||||
'';
|
'';
|
||||||
};
|
} // { inherit mkDerivation; };
|
||||||
|
|
||||||
shellDrv = mkDerivation {
|
shellDrv = mkDerivation {
|
||||||
name = "shellDrv";
|
name = "shellDrv";
|
||||||
@ -94,5 +94,9 @@ let pkgs = rec {
|
|||||||
chmod a+rx $out/bin/ruby
|
chmod a+rx $out/bin/ruby
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
inherit (cfg) shell;
|
||||||
|
|
||||||
|
callPackage = f: args: f (pkgs // args);
|
||||||
|
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
}; in pkgs
|
}; in pkgs
|
||||||
|
Loading…
Reference in New Issue
Block a user