[Nix#9456] Non-flake file input records recursive hash in flake.lock
but using flat hash in store path (mismatched hash mode) #95
Labels
No labels
Area/build-packaging
Area/evaluator
Area/flakes
Area/profiles
Area/remote-builds
Area/repl
Area/store
bug
Cross Compilation
devx
docs
Downstream Dependents
E/easy
E/hard
E/help wanted
E/reproducible
E/requires rearchitecture
imported
Needs Langver
OS/Linux
OS/macOS
performance
regression
release-blocker
RFD
stability
Status
blocked
Status
invalid
Status
postponed
Status
wontfix
testing
ux
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lix-project/lix#95
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Upstream-Issue: NixOS/nix#9456
Describe the bug
As in the title.
Steps To Reproduce
Given this
flake.nix
:Run
nix eval .#foo
gives/nix/store/z3ra5xqj5ac87ccs5r3604afi13ar1rj-source
. The generatedflake.lock
is:Note that the evaluated
some-file.outPath
and the lockednarHash
are using different hash mode. The former is a path to flat content hash FOD, while the latter is a recursive NAR hash. This can be verified by:Mismatched hash modes caused various effects:
flake.lock
alone, unlike other recursive hashed inputs.~/.config/nix/fetcher-cache-v1.sqlite
) is invalidated, there's no way to evaluate the flake, even though the input/nix/store/z3ra5xqj5ac87ccs5r3604afi13ar1rj-source
is intact. Because you cannot calculate the store path itself!This can be observed by
rm ~/.config/nix/fetcher-cache-v1.sqlite*; echo >>flake.nix; nix eval .#foo
. The input is downloaded and locked, but is still refetched every time.ValidPath
.hash
column (narHash) is not indexed. So it's practically impossible to get store path given nar hash of a flat hash FOD without a full table scan.nil
, see the link below) unable to check the existence of flake input, because Nix itself cannot either.Expected behavior
Possible solutions are:
narHash
) insideflake.lock
for inputs whose type="file".storePath
for all inputs inflake.lock
.Personally I prefer solution (2). It also provides a cheap way to get locked dependency paths without
nix flake archive
which currently dumps the full flake directory.nix-env --version
outputnix (Nix) 2.18.1
Additional context
Observed in https://github.com/oxalica/nil/issues/113, thanks to @MathiasSven.
May be related: #9303.
Priorities
Add 👍 to issues you find important.