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

flake: add private inputs & defer locking #164

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

flake: add private inputs & defer locking #164

wants to merge 3 commits into from

Conversation

nrdxp
Copy link
Contributor

@nrdxp nrdxp commented Jul 10, 2022

Includes our fork of the official nix registry:
https://github.com/input-output-hk/flake-registry/commits/iog

Here is a PoC of a scheme that allows for defining private flake inputs that do not propagate to the consuming flake, for easily management of dependencies without the overhead of cluttering everybodies flake.lock. Inputs that are defined in the top-level flake.nix should be expected to be defered to the consumer for locking, and preferably the consuming cluster should have our registry set in the nixConfig to keep values consistent and bumps explicit.

This is only the first step, but if we do this consistently throughout our projects, it will solve a majority of the lock related problems we've had so far while giving us a much easier path for updating dependencies on the cluster level. For example, it's been a pain in the past to update ssh keys from ops-lib, because we first had to bump the bitte dep and then again bump bitte on the cluster. Now that locking is deferred to the cluster flake will simply update ops-lib whenever a user requests an update to it, without having to channel through bitte at or define any special semantics.

This also gives us a reasonable path to avoid massive lock files that impose heavy costs: NixOS/nix#6626

For the sake of not breaking too many things, I have kept the API the same, that is, public inputs and private inputs are combined at the top of the flake.nix so minimal code changes to the rest of the codebase are needed. Once we stdize we may be able to break this up a bit if desired.

@manveru
Copy link
Collaborator

manveru commented Jul 10, 2022

Generally in favor of this. I see problems with not committing lock files, unless we rely on direnv with --no-write-lock-file (we may already do that?), and even then figuring out exactly which version of what input you use might become tedious.
The registry would have to be way more specific than it is now for this to work.

@nrdxp
Copy link
Contributor Author

nrdxp commented Jul 10, 2022

Well we would commit a lock file on the consuming cluster flake, just not on the upstreams to make them easier to update from the registry. if NixOS/nix#6550 were to be merged at some point, it wouldn't be necessary, but without that functionality, not commiting a lock on bitte is the only way for the consuming flake to easily control and update bitte's inputs (assuming they are all registry inputs, and not direct references).

But yeah, some fine tuning of the registry will definitely be necessary. Thankfully it's easy to modify the json registry with the nix cli if you just pass nix registry --registry path/to/our-registry.json.

@nrdxp
Copy link
Contributor Author

nrdxp commented Aug 26, 2022

Added some addtional, more specific pins to the registry, and gave this idea a testrun in a smaller project as a poc here:
input-output-hk/devshell-capsules#7

Inputs can now be declared without propagating to a consumers lock file
by adding inputs to the flake in the private sub directory.

The inputs defined here can be managed just like other flake inputs.

The narHash in the main flake.nix for the private inputs must be
updated anytime the private flake is touched.
@nrdxp nrdxp changed the title flake: add nixConfig section flake: add private inputs & defer locking Aug 26, 2022
@nrdxp nrdxp changed the base branch from develop to master August 26, 2022 21:47
@nrdxp
Copy link
Contributor Author

nrdxp commented Aug 26, 2022

ping @manveru, @blaggacao when you have time to look at this, I've implemented the majority of the idea, that can be safetly consumed by clusters, so long as they define our registry.

In order to get the most out of it, we'll have to do something similar for most of our other projects, but on the plus side, it's really not too difficult to do so.

@@ -5,6 +5,7 @@
.std

# nixos/nix
flake.lock
Copy link
Contributor

@gytis-ivaskevicius gytis-ivaskevicius Aug 29, 2022

Choose a reason for hiding this comment

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

Unfortunately, this does not do much. nix by default force adds the lock file

@blaggacao
Copy link
Contributor

blaggacao commented Aug 29, 2022

@nrdxp can you create separate PRs; one per motivation?

These are unfamiliar patterns, we should scrutinize and field one at a time...

... probably starting with private inputs that won't then propagate to downstream consumers' lock files, anymore. This is relatively straight forward and will help bring lock file sizes down, but also needs for full effect its std correspondence in Cardano World via: divnix/std#111

As for the registry, I'd like to better understand what abstract root problem a registry would solve and what undesired side-effects this might have. But we can discuss this on the respective PR.

There is also a third consideration: bitte iteslf is a private input to the bitteProfiles organelles, so why would we care at all, in here? (And not stop propagation in function of wether the bitteProfiles-organelle is of interest via divnix/blank)

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.

4 participants