我来自这里https://github.com/NixOS/nixpkgs/issues/28816,我正在寻找一种方法来将不纯的env变量传递给nix-build
在本地构建应该会有所帮助,但我无法使该示例正常工作,有人可以帮助我吗--option builders ''
,并将当前用户添加到trusted-users
并没有帮助
code=`<<'EOF'
with import <nixpkgs> {};
stdenv.mkDerivation {
name="impure";
phases=["buildPhase"];
impureEnvVars=["IMPURE"];
buildPhase=''
env | grep IMPURE
if [ -z $IMPURE ]; then
echo "Error"
exit 1
fi
echo "foo" > $out
'';
}
EOF`
export IMPURE=iop; nix-build --option builders "" --option trusted-users $USER -E "$code"
结果
$ code=`<<'EOF'
with import <nixpkgs> {};
stdenv.mkDerivation {
name="impure";
phases=["buildPhase"];
impureEnvVars=["IMPURE"];
buildPhase=''
env | grep IMPURE
if [ -z $IMPURE ]; then
echo "Error"
exit 1
fi
echo "foo" > $out
'';
}
EOF`
export IMPURE=iop; nix-build --option builders "" --option trusted-users $USER -E "$code"
these derivations will be built:
/nix/store/dvsl63bq4qmlrs79wbxvc3vrbxzw6xad-impure.drv
building '/nix/store/dvsl63bq4qmlrs79wbxvc3vrbxzw6xad-impure.drv'...
building
impureEnvVars=IMPURE
buildPhase=env | grep IMPURE
if [ -z $IMPURE ]; then
Error
builder for '/nix/store/dvsl63bq4qmlrs79wbxvc3vrbxzw6xad-impure.drv' failed with exit code 1
error: build of '/nix/store/dvsl63bq4qmlrs79wbxvc3vrbxzw6xad-impure.drv' failed