Skip to content
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

Closed
CMCDragonkai opened this issue Jul 12, 2018 · 3 comments
Closed

Interactive Idempotent Nix-Build #4

CMCDragonkai opened this issue Jul 12, 2018 · 3 comments

Comments

@CMCDragonkai
Copy link
Member

CMCDragonkai commented Jul 12, 2018

The reason why nix-build by itself doesn't have idempotent builds is because it relies on src = ./.; which has several problems.

First any change to the source directory will create a different input directory.

When nix-instantiate converts the default.nix open expression into a closed expression in drv 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 or nix-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 like filterSource and cleanSource.

There is an issue addressing this problem: NixOS/nix#885

@CMCDragonkai CMCDragonkai changed the title Idempotent Nix-Build Interactive Idempotent Nix-Build Jul 12, 2018
@CMCDragonkai
Copy link
Member Author

A second problem with using src = ./.; is if the directory contains large files. This can cause an out-of-memory problem.

There is a PR addressing this:

@CMCDragonkai
Copy link
Member Author

CMCDragonkai commented Jul 12, 2018

@CMCDragonkai
Copy link
Member Author

Figured this out and I documented this in several major language demos in Gist and in Matrix AI repositories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant