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

Allow overriding flake.lock file location via command-line #5673

Closed
knedlsepp opened this issue Nov 27, 2021 · 5 comments
Closed

Allow overriding flake.lock file location via command-line #5673

knedlsepp opened this issue Nov 27, 2021 · 5 comments
Labels

Comments

@knedlsepp
Copy link
Member

knedlsepp commented Nov 27, 2021

Is your feature request related to a problem? Please describe.

I'd like to propose allowing to override the flake.lock location to ease continuous integration of nix flakes (with hydra in mind).

I'm currently using hydra to do CI for my (not-yet-flakes) nix-based projects, which offers the functionality to pull in the most recent versions of a jobset's inputs and then build some derivations that are derived from these. I've got some jobsets set up that always build my projects against the "bleeding edge" versions of some other project, which I do however pin down to some known good version for development using a poor-man's-flake.lock.

With flakes this would change a little. The jobset maps to a flake and the jobsets inputs are hard-coded inside the flake's flake.lock. One currently cannot override these locked inputs from hydra. (The nix CLI does however already offer a way to override individual inputs explicitly via --override-input)
This implies that to recreate the previously mentioned feature of fetching the latest versions of multiple inputs, one would have to set up a separate service that regularly updates and commits the flake.lock file.

Describe the solution you'd like
I'd like to be able to both produce and consume a flake.lock file to/from an (out-of-tree) location.
Thus the hydra (or other CI) workflow could be done in the following way:

  • Create a fresh flake.lock outside of the repo via nix flake lock --recreate-lock-file --lock-file=/path/to/flake.lock
  • Build the flake via nix build --lock-file=/path/to/flake.lock
  • For reproducibility store the flake.lock for the evaluation and offer it for download (Maybe with a link like: nix build --lock-file=https://hydra.nixos.org/eval/12345/flake.lock .)

Describe alternatives you've considered

  • Set up a service that continuously updates and commits a flake's lockfile and configure Hydra to use that
  • Set up an old-style jobset via a default.nix that somehow uses builtins.getFlake and overrides the inputs manually.
  • Use another CI service and update the lock-file as the first step before using nix build
@colemickens
Copy link
Member

This would be extremely useful. I have a wrapper script that passes through flake input overrides, but there's not a good way for me to "pass those" through into a tmux/zellij script. However, if this feature existed, I could easily apply the overrides at the "top" with this env var set, and then any child scripts would "just do the right thing".

big +1 for me, this would be useful for lots of scenarios and hopefully wouldn't be too hard to support?

@colemickens
Copy link
Member

I'm hacking on something: https://github.com/colemickens/nix/tree/flakes-flake-lock-loc-env-var. I think it sorta works?

@lheckemann
Copy link
Member

@ElvishJerricco and I have implemented this with two options (one for the lock file to reference, one for the new lock file to write) in #8042.

@colemickens
Copy link
Member

Fantastic, I've come back around to wanting this again! Thanks @lheckemann !

@knedlsepp
Copy link
Member Author

Closing this as #8042 was merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants