Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@zhaofengli
Copy link
Owner

@zhaofengli zhaofengli commented Oct 7, 2024

This PR adds support for evaluating flakes directly using nix eval to make pure evaluation work with Nix 2.21+. Fixes #202.

Been procrastinating on this for a long time, but with NixOS 24.11 releasing soon carrying Nix 2.24 as the default, it's finally time to do it.

This is based on the existing experimental support for the colmenaHive output. Instead of using the eval.nix bundled with the Colmena executable against the "raw" colmena output, the colmenaHive output contains the "prepared" hive.

Usage

Your flake needs to depend on Colmena as an input and expose a new colmenaHive output containing the result of colmena.lib.makeHive:

 {
   inputs = {
+    # ADDED: Colmena input
+    colmena.url = "github:zhaofengli/colmena";

     # ... Rest of configuration ...
   };
   outputs = { self, colmena, ... }: {
+    # ADDED: New colmenaHive output
+    colmenaHive = colmena.lib.makeHive self.outputs.colmena;

     # Your existing colmena output
     colmena = {
       # ... Rest of configuration ...
     };
   };
 }

Then, add --experimental-flake-eval to colmena invocations.

Current Limitations

The following isn't supported with --experimental-flake-eval:

  • colmena eval --instantiate
  • --evaluator streaming

@numkem
Copy link

numkem commented Oct 21, 2024

Unstable got updated last week with nix 2.24 wich means this branch is now pretty much required to use flakes. I've been using it myself and haven't found issues.

@stv0g
Copy link

stv0g commented Oct 21, 2024

I've been using it myself and haven't found issues.

Me too.

@zhaofengli zhaofengli force-pushed the direct-flake-eval branch 12 times, most recently from 588e36d to e651b72 Compare November 7, 2024 22:02
@zhaofengli zhaofengli marked this pull request as ready for review November 7, 2024 22:25
@zhaofengli zhaofengli merged commit 2c95c17 into main Nov 7, 2024
32 checks passed
Comment on lines +14 to +15
applyFlags = "--evaluator ${evaluator} ${extraApplyFlags}"
+ lib.optionalString (!pure) "--impure";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break when extraApplyFlags is used, and !pure since the concatenation doesn't include a space.
Using a list seems worth it!

Just noticed that when updating my nixpkgs and trying to fix :)

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.

bug: cannot apply without --impure

4 participants