-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Purity checking should also accept $TMP, $TMPDIR and $TEMP, $TEMPDIR #97597
Conversation
2254685
to
8ab5d80
Compare
A quick thought: if we go for such a long positive list, wouldn't it be easier to just reject |
I agree with the more clean. If you have a specific list of acceptable paths, an exact whitelist seems like a better filter than an approximate blacklist to me. It is unfortunate that a temporary location is a bit messy, but [nix-shell:~]$ env | egrep 'T[^=]*MP[^=]*='
...
TMP=/run/user/1000
TMPDIR=/run/user/1000
TEMPDIR=/run/user/1000
TEMP=/run/user/1000 In the original patch I just did |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good to me. The conflict is due to the previous version of this getting reverted.
I believe this can be merged to staging
without further testing. This new version "breaks" only a subset of badPath
invocations in comparison to the previous version which turned out not to be that bad (was in master
and release-20.09
for some time).
this not only gives us a "hint" of test coverage, but also proves the fix from NixOS#97597 allows import of theano from within a sandboxed build
(modified cherry pick of commit 4a9dba6) some tricks are required to make this work because NixOS#93560 and NixOS#97597 didn't make it into this branch, but this example shows what is required to import theano from within a nix build environment on this branch.
Motivation for this change
@FRidh @jtojnar @matthewbauer @vcunat @pbogdan have to submit a new pull request for an update to #93560 as it was accepted (and hence closed) but later reverted.
The details again are, the
badPath
routine used by the various compiler paths to check purity is hard coded to reject any paths that lie outside of$NIX_STORE
,$NIX_BUILD_TOP
, and/tmp
.In build environments, however,
/tmp
is frequently overriden by settings the$TMP
,$TMPDIR
, and$TEMP
environment variables, so I submitted a pull request #93560 to make the system use $TMP, if set, instead of/tmp
.This broke packages that were hardcoded to use
/tmp
(e.g.,mktemp /tmp/FOOXXXX
). In retrospect, the patch was also somewhat lacking as it should technically should also have accept$TMPDIR
and$TEMP
in addition to$TMP
. This is an updated pull request that accepts all of$NIX_STORE
,$NIX_BUILD_TOP
,/tmp
,$TMP
,$TMPDIR
, and$TEMP
.Being strictly more accepting than the previous one, this one should not causes any failures.
Things done
I have verified the above GNU helloworld (see above) compiles correctly in the above example once this change is made. This is actually quite extensive as change the
badPath
routine does result in a fairly significant rebuild of dependencies.sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)