nix flake check --no-build fails on flake dependencies #587

Open
opened 2024-11-28 10:29:51 +00:00 by jzbor · 1 comment

Describe the bug

nix flake check --no-build fails if flake dependencies used during evaluation are not present in the store.

Steps To Reproduce

  1. Clone https://github.com/jzbor/nix-parcels
  2. Run nix flake check --no-build

Expected behavior

--no-build should avoid building actual derivations, but should fetch flake dependencies if required.

nix --version output

nix (Lix, like Nix) 2.91.1

Additional context

My goal is to implement different steps for evaluation checks and build checks in CI. If anyone knows of a simple workaround to fetch required dependencies before the check let me know.

## Describe the bug `nix flake check --no-build` fails if flake dependencies used during evaluation are not present in the store. ## Steps To Reproduce 1. Clone https://github.com/jzbor/nix-parcels 2. Run `nix flake check --no-build` ## Expected behavior `--no-build` should avoid building actual derivations, but should fetch flake dependencies if required. ## `nix --version` output ``` nix (Lix, like Nix) 2.91.1 ``` ## Additional context My goal is to implement different steps for evaluation checks and build checks in CI. If anyone knows of a simple workaround to fetch *required* dependencies before the check let me know.
Author

So I checked the source code, and this simple change in lix/nix/flake.cc did the trick:

diff --git a/lix/nix/flake.cc b/lix/nix/flake.cc
index 18383247f..72b274468 100644
--- a/lix/nix/flake.cc
+++ b/lix/nix/flake.cc
@@ -353,11 +353,6 @@ struct CmdFlakeCheck : FlakeCommand
 
     void run(nix::ref<nix::Store> store) override
     {
-        if (!build) {
-            settings.readOnlyMode = true;
-            evalSettings.enableImportFromDerivation.setDefault(false);
-        }
-
         auto state = getEvalState();
 
         lockFlags.applyNixConfig = true;

Now I am not sure what the intention of this code was, but it does not make sense for me to not build any derivations during check, including flake dependencies.
--no-build still avoids building check dependencies as intendeded (see line 803)

So I checked the source code, and this simple change in [lix/nix/flake.cc](https://git.lix.systems/lix-project/lix/src/commit/2e5780ebc848f3b021f11dd94533b0b68362d989/lix/nix/flake.cc#L357) did the trick: ```diff diff --git a/lix/nix/flake.cc b/lix/nix/flake.cc index 18383247f..72b274468 100644 --- a/lix/nix/flake.cc +++ b/lix/nix/flake.cc @@ -353,11 +353,6 @@ struct CmdFlakeCheck : FlakeCommand void run(nix::ref<nix::Store> store) override { - if (!build) { - settings.readOnlyMode = true; - evalSettings.enableImportFromDerivation.setDefault(false); - } - auto state = getEvalState(); lockFlags.applyNixConfig = true; ``` Now I am not sure what the intention of this code was, but it does not make sense for me to not build *any* derivations during check, including flake dependencies. `--no-build` still avoids building check dependencies as intendeded (see [line 803](https://git.lix.systems/lix-project/lix/src/commit/2e5780ebc848f3b021f11dd94533b0b68362d989/lix/nix/flake.cc#L803))
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#587
No description provided.