Skip to content

allow private flake inputs #7028

Description

@nrdxp

Is your feature request related to a problem? Please describe.
The current flake inputs spec seems to me to conflate two different concerns.

  1. It provides a way for the author to declare a user modifiable (via follows, registry, etc) API for the inputs to the flake
  2. It provides a convenient shorthand to the user, from having to constantly update hashes manually

I fear the allure of convenience of the second point is causing noise in the first. For example, there are a lot of projects where I see a flake being imported simply to work with a single output, or even no output at all, but just call import on it to evaluate the Nix expression, or even just pulling a project source repo via flake inputs.

In addition, there may be a situation where the author has not properly consider the implication of a user writing their own follows and doing so may break their flake, or cause a cache miss, etc.

I feel it would be better to provide a clean split here. Inputs that the author genuinely wishes for the user to be able to override should propagate to consuming lock files, these could be considered public flake inputs. Inputs that are not meant to be modified in any way would then be considered private, they would not be overriable or exposed to the consumer, and they would not propagate to their lock. They can, however, still use follows themselves.

Describe the solution you'd like
Inputs could be considered private by default, and we simply place a new attribute public = true for inputs we wish to be public. In addition, for clarity, public inputs should have to be genuine flakes (no flake = false). This could be combined with subflakes to keep things manageable.

Describe alternatives you've considered
I wrote a bit of a hacky solution to this problem in a work PR whereby I keep a flake for private inputs in a subdirectory. I then call that flake with call-flake.nix manually to avoid appending any of these inputs to the top-level lock file.

We have also begun exploring a similar workflow for divnix/std#111

Additional context
#6626 (this will become an issue for large mono-repos, e.g. if we ever flakify nixpkgs)
#6353 (could be considered an alternative implementation for the same idea)

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureFeature request or proposalflakes

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions