Unstable store hash when using subdirectory as a flake input #586
Labels
No labels
Affects/CppNix
Affects/Nightly
Affects/Only nightly
Affects/Stable
Area/build-packaging
Area/cli
Area/evaluator
Area/fetching
Area/flakes
Area/language
Area/lix ci
Area/nix-eval-jobs
Area/profiles
Area/protocol
Area/releng
Area/remote-builds
Area/repl
Area/repl/debugger
Area/store
bug
Context
contributors
Context
drive-by
Context
maintainers
Context
RFD
crash 💥
Cross Compilation
devx
docs
Downstream Dependents
E/easy
E/hard
E/help wanted
E/reproducible
E/requires rearchitecture
imported
Language/Bash
Language/C++
Language/NixLang
Language/Python
Language/Rust
Needs Langver
OS/Linux
OS/macOS
performance
regression
release-blocker
stability
Status
blocked
Status
invalid
Status
postponed
Status
wontfix
testing
testing/flakey
Topic/Large Scale Installations
ux
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lix-project/lix#586
Loading…
Add table
Add a link
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?
Describe the bug
UPDATE: The subtree is irrelevant. See followup comment.
If you use a git subtree path as a flake input, the flake input gets updated with a different store hash every time you run any flake command.
Steps To Reproduce
Create a local git repo
foo
with a bareflake.nix
file.$ mkdir foo && cd foo
flake.nix
$ nix flake lock && git init && git add . && git commit -m 'Initial commit'
Create another local git repo with a
flake.nix
that containsfoo
as a subtree$ mkdir ../bar && cd ../bar
$ cp ../foo/flake.nix .
$ nix flake lock && git init && git add . && git commit -m 'Initial commit'
$ git remote add foo-local /path/to/foo/
$ git subtree add --prefix=foo foo-local main
foo
toflake.nix
Run
nix flake lock
to add the new input toflake.lock
Run
nix flake lock
again and see that the flake input forfoo
gets updated despite no changes having been made since the lastnix flake lock
run.Note that the store hash changes, but the
narHash
stays the same.Expected behavior
The lock file should not be updated when the subtree has not been changed.
nix --version
outputAdditional context
The reason for doing this is to use as an input a flake that has no central repository.
Hmmm. That's super weird that the paths are changing while maintaining the same nar hash (i think those should be output-addressed store paths so that ought to be impossible). I think the immediate fix to your issue here is possibly using a git input type (but I'm not sure; subdirectory flakes are incredibly broken and I forget the one syntax that actually works).
I'm also wondering to what extent the git repo being created after locking the flake has any influence (probably not, but maybe?).
This should get tested on 2.18 to see if it's a regression also.
Tested against Nix 2.18 from nixpkgs and the same thing happens, so not a regression in Lix.
Tried again with Lix (same version as in original report) but locking the flake after creating the initial git commit, and got the same issue.
I could not figure out a
git
input type that would work with a subdirectory path.I did some more monkeying around, and found that the issue has nothing to do with subtrees. If you have a subdirectory flake in the same repo, you get the same unstable-store-hash issue.
Same contents of each
flake.nix
files as in the original issue description. The flake inputfoo
in the flakebar
is updated every time you run anynix flake
command, even if you change nothing.Unstable store hash when using git subtree as a flake inputto Unstable store hash when using subdirectory as a flake inputhttps://discourse.nixos.org/t/get-nix-flake-to-include-git-submodule/30324/18
The answer appears to be
"git+file:foo"
. This also works with submodules.