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

Don't use read-only mode for nix build --dry-run #3782

Closed
wants to merge 1 commit into from

Conversation

madjar
Copy link
Member

@madjar madjar commented Jul 3, 2020

In dry run mode, new derivations can't be create, so running the command on anything that has not been evaluated before results in an error message of the form don't know how to build these paths (may be caused by read-only store access).

For comparison, the classical nix-build --dry-run doesn't use read-only mode.

Closes #1795

@dtzWill
Copy link
Member

dtzWill commented Jul 16, 2020

cc 94eb5fa, which does not mention the impact as including this but (untested) looks like maybe it was motivated by this sort of issue? Regardless maybe this can be fixed while visiting that logic, if it hasn't already been addressed? 😇

(if there are known issues in the way, please share as maybe someone can fix them ^_^)

@madjar
Copy link
Member Author

madjar commented Jul 22, 2020

94eb5fa doesn't fix the issue, so I rebased on top of it and updated the patch.

I'm guessing this is ready for review.

@madjar
Copy link
Member Author

madjar commented Aug 24, 2020

@edolstra Would you be interested in merging that? It would enable a few workflows, including https://github.com/Mic92/nix-build-uncached for flakes.

@zimbatm
Copy link
Member

zimbatm commented Aug 24, 2020

Note that the current version works fine if the repo doesn't use IFD.

@madjar
Copy link
Member Author

madjar commented Aug 27, 2020

@zimbatm I'm not sure that's true. I have here a repo without IFD, and I still get the issue (because nix build --dry-run won't create the .drv files).

You can reproduce with nix build --dry-run nixpkgs#hello.

@stale
Copy link

stale bot commented Feb 23, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Feb 23, 2021
In dry run mode, new derivations can't be create, so running the command on anything that has not been evaluated before results in an error message of the form `don't know how to build these paths (may be caused by read-only store access)`.

For comparison, the classical `nix-build --dry-run` doesn't use read-only mode.

Closes NixOS#1795
@madjar
Copy link
Member Author

madjar commented Feb 24, 2021

Hey folks!

I just rebased this PR on top of master.

Reminder of what this PR does

So, right now, running nix build --dry-run on a derivation that is not already in the store will say "don't know how to build these paths (may be caused by read-only store access):", which is not super helpful.

This PR changes the realisation mode for --dry-run from Nothing to Derivation. As a result, the derivation will get instantiated.

I believe it's good to change the behaviour of --dry-run instead of introducing a new flag, because that is the behaviour of the classical nix-build command, and because I'm not sure that a command that only returns a usable result if some other command has been run before is a use case.

@thufschmitt
Copy link
Member

I think you can remove the Realise::Nothing enum member altogether as it's never used anymore (It was used in only two places, #4541 removed one and you remove the other)

@anka-213
Copy link

Could we also introduce a new flag that never builds anything for those who want to preserve the current behaviour (if anyone does)?
Or even better, one that says what --dry-run would build, but that is definitely out of scope for this pull request.

@Ma27
Copy link
Member

Ma27 commented Aug 13, 2021

In case anybody needs a version compatible with the latest master: https://gist.github.com/Ma27/4337efe6be1e3858b0209ad1c9cbdcfe

(cc @edolstra would be awesome if this could be merged, though)

@edolstra
Copy link
Member

edolstra commented Sep 2, 2021

@madjar @Ma27 Thanks, applied!

@edolstra edolstra closed this Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'nix build --dry-run' fails on new derivations, acts like readOnlyMode
7 participants