-
Notifications
You must be signed in to change notification settings - Fork 99
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
nix flake check
fails on crane due to IFD
#612
Comments
Hi @korfuri thanks for the report!
This is actually running all of Could you provide a(n ideally minimal) reproduction of your flake that I can test with? |
Apologies for the delayed response. The easiest way I can reproduce is simply:
It seems that literally any use of a crane-built package in a flake will trigger this when flake-checking without building (unless the necessary artifacts were built previously and not gc'd). |
Thank you for the instructions, I was able to reproduce the issue after running It seems like the problem boils down to using Changing that line to just I'm going to close this as I don't think there is anything we can do here in the general sense (I'd prefer to keep the examples using |
Thanks for digging into this! I'm bringing that up with Lanzaboote since in my case they're the user of Crane and the ones bringing the IFD into my configs. It's unfortunate but after some digging on my own side, it seems completely unavoidable: nixpkgs's Maybe documenting this behavior in Crane's API reference would be useful? I guess most people don't really care about IFDs but for the few of us that are impacted this may save us some time. Thanks! |
Before this commit, we use cranelib.cleanCargoSource[1] to filter files in the ./rust/uefi directory. This prevents some rebuilds when files that do not contribute to the build are changed (e.g. a README). However, this causes lanzaboote's flake.nix to contain an IFD[2]. This seems to be unavoidable when using cleanCargoSource[3]. Why this is useful anyway: Since `nix flake check` must check all outputs of the given flake, it's not possible to split a flake check across multiple builder machines. This means that `nix flake check` without `--no-build` can only work if the builder machine has support to build for all architectures present in that flake's `nixosConfigurations` output. This is achievable with binfmt emulation, but excruciatingly slow, especially for use-cases like "run nix flake check in CI". In practice this means that a flake containing nixosConfiguration outputs with different `system` attributes can generally only be `nix flake check`'d with `--no-build`. See [4] for a long discussion on this. Unfortunately, this affects flakes using Lanzaboote transitively. So any flake containing Lanzaboote-enabled nixosConfigurations (like mine[5]) are not be able to use `nix flake check --no-build`. This commit corrects this by removing the IFD. This can be tested with: $ nix store gc # to ensure IFD paths are not cached $ nix flake check --no-build github:nix-community/lanzaboote # fails $ nix store gc $ nix flake check --no-build github:korfuri/lanzaboote # succeeds [1] https://crane.dev/API.html#cranelibfiltercargosources [2] https://nix.dev/manual/nix/2.22/language/import-from-derivation [3] ipetkov/crane#612 [4] NixOS/nix#4265 [5] https://gitlab.com/korfuri/infra/-/blob/77635232eb65e877d8b79eb98f6264381231c20c/flake.nix
Reopening since I remembered that |
Still able to repro the issue, I think this check needs to be done more lazily: crane/lib/crateNameFromCargoToml.nix Line 23 in a3f0c63
|
Tried testing this again today and wasn't able to reproduce so it might have been a hiccup with my testing setup (constantly having to gc is not very fun). Going to close this out for now but we can investigate further as needed |
I can confirm that for Lanzaboote it seems to work: Note that |
Describe the bug
crane's
flake.nix
uses an IFD in the form of heinputFromLock
function, with this import. This causesnix flake check
to fail in some instances, if the check happens without this derivation having been built.This causes any flake depending on crane to fail flake checks as well.
In my case I'm hitting this because I want to run
nix flake check
in the CI of my homelab flake that contains multiple nixosConfigurations. I don't want to build all these configurations when I'm just running CI, that would be a ton of compute for each change, so I'm running with--no-build
(I also need this as I have machines with various architectures, but my CI runners can't build for all these archs). I use https://github.com/nix-community/lanzaboote which depends on crane, and so mynix flake checks
are failing.I don't understand the Rust ecosystem well enough, but it seems this pattern is only used to import a specific version of
rust-overlay
. Couid this instead be done without an IFD, by depending on it as a regular flake input?Reproduction
The text was updated successfully, but these errors were encountered: