Impure derivations do not work with flakes #389
Labels
No labels
Area/build-packaging
Area/cli
Area/evaluator
Area/fetching
Area/flakes
Area/language
Area/profiles
Area/protocol
Area/releng
Area/remote-builds
Area/repl
Area/store
bug
crash 💥
Cross Compilation
devx
docs
Downstream Dependents
E/easy
E/hard
E/help wanted
E/reproducible
E/requires rearchitecture
imported
Needs Langver
OS/Linux
OS/macOS
performance
regression
release-blocker
RFD
stability
Status
blocked
Status
invalid
Status
postponed
Status
wontfix
testing
testing/flakey
ux
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lix-project/lix#389
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Describe the bug
With the impure-derivations feature, derivations with __impure = true; are supposed to be able to do impure things such as accessing the global environment, regardless of whether nix is invoked with --impure or not. However, when the derivation is a package output of a flake, this doesn't work and instead gives a purity error.
Steps To Reproduce
nix build
.Expected behavior
The derivation would build successfully.
nix --version
outputnix (Lix, like Nix) 2.90.0-lixpre20240527-0b91a4b
Additional context
Building with
--impure
makes it work.It is very likely that what's happening is that certain builtins are removed and others are given different behavior, as a global property at invocation time.
I'm not honestly certain, with lazy evaluation and all, how this could possibly work even without flakes. My attempt to create a minimal test to see how it works without flakes resulted instead in #388, so maybe impure derivations just don't work at all? Hmm hmm.
Files
flake.nix
package.nix
This is working as intended.
builtins.readFile
is run client side, and is affected by--impure
, and that is the error you are seeing.Impure derivations are another thing entirely unrelated to
--impure
: they are derivations that are rebuilt every time and have network access. They're like a less evil version of__noChroot
input-addressed derivations, as I understand it.The intended use case is that you have an impure derivation somewhere in your build process for scuffed garbage, and then you have content-addressed dependents that prevent anything below it being rebuilt, providing early cutoff (see Build Systems à la Carte by Peyton-Jones).
oh. huh. interesting... so the two concepts of pure evaluation are different. drat :) but that makes sense.