hydra icon indicating copy to clipboard operation
hydra copied to clipboard

Support for flake jobsets with no lock file

Open b-bondurant opened this issue 3 years ago • 1 comments

Is your feature request related to a problem? Please describe. It's entirely possible that I'm going about things the wrong way or my use case isn't what was intended, but here goes.

I use hydra for CI, and with legacy packages it was easy to pull the latest version of the repositories I want to build by having them as jobset inputs (in the declarative spec file) with no revision specified (defaulting to HEAD). With flakes, I don't see a clear way to do that without continuously pushing updates to the lock file.

Describe the solution you'd like I've managed to hack together something that seems to work by modifying the lock flags to ignore the existing lock file:

diff --git a/src/hydra-eval-jobs/hydra-eval-jobs.cc b/src/hydra-eval-jobs/hydra-eval-jobs.cc
index acffe1d1..97947642 100644
--- a/src/hydra-eval-jobs/hydra-eval-jobs.cc
+++ b/src/hydra-eval-jobs/hydra-eval-jobs.cc
@@ -105,9 +105,11 @@ static void worker(
 
         auto lockedFlake = lockFlake(state, flakeRef,
             LockFlags {
-                .updateLockFile = false,
-                .useRegistries = false,
-                .allowMutable = false,
+                .recreateLockFile = true,
+               .writeLockFile = false,
+               .useRegistries = false,
+               .applyNixConfig = true,
+                .allowMutable = true,
             });
 
         callFlake(state, lockedFlake, *vFlake);

However, a lock file still has to exist, otherwise this call fails.

I'm sure you don't want to hard-code the flags as I have, but some configuration file options would be much appreciated.

Also, you may have noticed the above applyNixConfig flag -- that's not relevant for the lock file, but an option to enable that would also be appreciated. I have it enabled here because there seemed to be no other way to configure the allowed-uris for restricted eval mode.

Describe alternatives you've considered Open to any alternatives.

Additional context I have flakes in each of the repositories/packages I want to build, and then a flake for my hydra jobset that takes those package flakes as inputs and outputs the appropriate hydraJobs. There are also a few random dependencies that aren't flakes, hence my need for allowed-uris.

Running Hydra on Ubuntu 20.04, patch was made and verified to work for my situation on the current (at time of posting) head of master.

b-bondurant avatar Feb 18 '22 21:02 b-bondurant

@pnmadelaine and I are having a quite similar problem, solved by patching hydra-eval-jobs.cc in almost the same way you are doing @b-bondurant.

In our case, we want Hydra to build a flake whose lockfile might lack an input (e.g. someone pinned an input in flake.nix without running nix flake lock afterward). So instead of setting recreateLockFile to true, we set updateLockFile to true. We also needed to add --no-write-lock-file to nix invocations, just as @t184256 seems to be doing in https://discourse.nixos.org/t/how-to-build-unlocked-flakes-on-hydra/15437.

That would be great to have an official way of doing those sorts of things with Hydra :)

W95Psp avatar May 04 '22 15:05 W95Psp