-
Notifications
You must be signed in to change notification settings - Fork 4
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
Interactive Idempotent Nix-Build #4
Comments
A second problem with using There is a PR addressing this: |
Examples of using https://github.com/coq/coq/blob/42774708bafe48aefe411fab4ca4d75407f9d1d6/default.nix#L69-L74 And someone created a nix module that can simulate the usage of the |
Figured this out and I documented this in several major language demos in Gist and in Matrix AI repositories. |
The reason why
nix-build
by itself doesn't have idempotent builds is because it relies onsrc = ./.;
which has several problems.First any change to the source directory will create a different input directory.
When
nix-instantiate
converts thedefault.nix
open expression into a closed expression indrv
form, then it will also encode the contents of the./.
. (The transformation from open expression to closed expression is itself interesting). Also this is a consequence of the design of Nix where the hashes of the outputs are not based on the outputs themselves but based on the input expressions.So every time
nix-build
builds with./result
symlink pointing to a different place, then you get a different source state!You can observe idempotency by doing:
nix-build --no-out-link
ornix-store --realise $(nix-instantiate)
.To actually get idempotent builds, we need to have some way of ignoring generated files inside our
src
. Basically using things likefilterSource
andcleanSource
.There is an issue addressing this problem: NixOS/nix#885
The text was updated successfully, but these errors were encountered: