I don’t understand why args sequence matter / where my errors is caused from
in bash shell variables get defined
and should be handed over to the shell.nix file ( e.g. via --argstr
)
- here it should be any dir path ( like pwd)
the var pathDir
only works if there are no other args
- or if
pathDir
is on the first position
Why that?
testPkgNix="bash" ; pathDir="$(pwd)" ;
echo $pathDir
nix-shell Nix_args.nix --pure --show-trace
nix-shell Nix_args.nix --pure --argstr pathDir ${pathDir} --show-trace # ok
nix-shell Nix_args.nix --pure --argstr testPkg ${testPkgNix} --argstr pathDir ${pathDir} --show-trace # issue # should warn that testPkg is no parameter in the script
nix-shell Nix_args.nix --pure --argstr testPkgNix ${testPkgNix} --argstr pathDir ${pathDir} --show-trace # issue # should work
nix-shell Nix_args.nix --pure --argstr pathDir ${pathDir} --argstr testPkg ${testPkgNix} --show-trace # ok # # should warn that testPkg is no parameter in the script
nix-shell Nix_args.nix --pure --argstr pathDir ${pathDir} --argstr testPkgNix ${testPkgNix} --show-trace # ok #
{ testPkgNix ? "zsh", pathDir ? "/home/" , ...}:
let
pkgs = import <nixpkgs> {} ;
in
pkgs.mkShell {
name="devEnv";
buildInputs = [
pkgs.bash
pkgs.which
];
shellHook = ''
echo "Path ${pathDir}"
echo "pkgs ${testPkgNix}"
'';
}