You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, this flake will produce a non-empty flake.lock file that basically duplicates the information already included in the URL. Committing only flake.nix to a git repository and then trying to use it with something like nix run github:myself/uses-foo#hello will fail, complain about the missing flake.lock and ask the user to use --no-write-lock-file or --no-update-lock-file.
A similar thing (but with an extra layer of indirection) happens with the common "override an empty dependency flake" pattern. In this pattern, some flake doesn't define one of its inputs (or defines it to point to an empty dummy flake):
nix run github:myself/uses-bar#hello --override-flake bar 'github:nixos/nixpkgs/a395950650818e22403fafaadccb42cb40cb5852?narHash=sha256-kBBoeXhOlTIje7S1lku1k+euf9GcpL8eGZkI66yLeBw='
and (in the first case)
nix registry add bar 'github:nixos/nixpkgs/a395950650818e22403fafaadccb42cb40cb5852?narHash=sha256-kBBoeXhOlTIje7S1lku1k+euf9GcpL8eGZkI66yLeBw='
nix run github:myself/uses-bar#hello
to work without requiring --no-write-lock-file. Note, that this is already (kind of) the case, but only when bar is replaced with the follows mechanism from another flake:
So, AFAIK, we currently have 3 mechanisms for "replacing" a flake:
--override-flake
registry
follows
and only follows works without --no-write-lock-file.
Describe the solution you'd like
When a flake input url is already specific enough, don't add it to the lock file
"specific enough" probably means "includes a narHash"
(I would personally prefer if just providing a specific rev would be enough, but this is up for discussion)
I would be okay, if this would be a per-input opt-in behaviour (something like inputs.bar.unlocked = true;)
This would include the urls derived from follows, --override-flake and registries
Describe alternatives you've considered
The only alternatives I see are:
Don't use flakes at all. Unfortunately, "classic" nix doesn't provide a standardized/idiomatic way to organize nix code.
Run everything with --no-write-lock-file. Unfortunately, this is either really cumbersome (if you manually add this option to each command) or really error-prone (if you declare an alias that automatically includes --no-write-lock-file or something to that effect).
Is your feature request related to a problem? Please describe.
Consider the following flake (note the
narHash
in theurl
):Currently, this flake will produce a non-empty
flake.lock
file that basically duplicates the information already included in the URL. Committing onlyflake.nix
to a git repository and then trying to use it with something likenix run github:myself/uses-foo#hello
will fail, complain about the missingflake.lock
and ask the user to use--no-write-lock-file
or--no-update-lock-file
.A similar thing (but with an extra layer of indirection) happens with the common "override an empty dependency flake" pattern. In this pattern, some flake doesn't define one of its inputs (or defines it to point to an empty dummy flake):
Given this, I would expect
nix run github:myself/uses-bar#hello --override-flake bar 'github:nixos/nixpkgs/a395950650818e22403fafaadccb42cb40cb5852?narHash=sha256-kBBoeXhOlTIje7S1lku1k+euf9GcpL8eGZkI66yLeBw='
and (in the first case)
nix registry add bar 'github:nixos/nixpkgs/a395950650818e22403fafaadccb42cb40cb5852?narHash=sha256-kBBoeXhOlTIje7S1lku1k+euf9GcpL8eGZkI66yLeBw=' nix run github:myself/uses-bar#hello
to work without requiring
--no-write-lock-file
. Note, that this is already (kind of) the case, but only whenbar
is replaced with thefollows
mechanism from another flake:So, AFAIK, we currently have 3 mechanisms for "replacing" a flake:
--override-flake
follows
and only
follows
works without--no-write-lock-file
.Describe the solution you'd like
When a flake input
url
is already specific enough, don't add it to the lock filenarHash
"(I would personally prefer if just providing a specific
rev
would be enough, but this is up for discussion)inputs.bar.unlocked = true;
)url
s derived fromfollows
,--override-flake
and registriesDescribe alternatives you've considered
The only alternatives I see are:
--no-write-lock-file
. Unfortunately, this is either really cumbersome (if you manually add this option to each command) or really error-prone (if you declare an alias that automatically includes--no-write-lock-file
or something to that effect).Priorities
Add 👍 to issues you find important.
The text was updated successfully, but these errors were encountered: