-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Flakes: Re-locking necessary at each evaluation when import sub-flake by path #9339
Comments
This issue has been mentioned on NixOS Discourse. There might be relevant details there: |
When referring to a relative subflake, it seems there are a few related design issues:
There are use cases for each of these, but we use the same name for all of them, and the features and behavior is different. The initial design was more along the first, but then people want to use it via the second approach. Perhaps we try to clarify the various cases, give them names, define the expected behavior, and document the recommended way for users to achieve it. We may learn along the way that there is a way to unify them, or simplify the cases. Another way to talk about them:
|
For this, it might make sense to clarify what I actually wanted to achieve there: I was trying to re-configure nixpkgs to permit some insecure packages, and then ensure that my flake and the poetry2nix flake actually use this configuration instead of using their internal nixpkgs instance. nix-community/poetry2nix#1354 This was the only idea I came up with, and at least it seems possible within the flake semantics. |
…s a submodule locally The reason is that relative-path-flakes are broken: - https://discourse.nixos.org/t/flakes-re-locking-necessary-at-each-evaluation-when-import-sub-flake-by-path/34465 - NixOS/nix#9339
…s a submodule locally The reason is that relative-path-flakes are broken: - https://discourse.nixos.org/t/flakes-re-locking-necessary-at-each-evaluation-when-import-sub-flake-by-path/34465 - NixOS/nix#9339
Describe the bug
I have a flake dev-env that itself references a sub-flake
myNixpkgs
from the same local git repo by relative path.As the sub-flake input is also locked in the main
flake.lock
file, its path is recorded in there.Unfortunately I've discovered that each evaluation of the flake now changes the flake.lock file again.
Especially with
direnv
this is a no-go behaviour, as the flake is re-evaluated after each command run in the shell.The reason for this is quite clear: For pure evaluation, the whole git repo of the flake is copied to the nix store. Its out path there depends on the repo's content. So the following happens:
I mainly wonder whether I am holding this wrong and there is a better solution to this? Or is this still one of the cases why flakes are experimental and the issue about relative flake path references is still open? #3978
I'd be so bold to say that my approach is a rather obvious one, so even if there is a better approach, it is easy to do things the wrong way.
the
flake.nix
at the repo top-level:The sub-flake
flakeSupport/myNixpkgs/flake.nix
:Expected behavior
As long as the referenced sub-flake file does not change, the lock file shall not change as well and thus no re-evaluation or automatic re-locking shall be necessary.
nix-env --version
output: nix-env (Nix) 2.13.6Additional context
This issues has been initially discussed in the NixOS Discourse forum. We came to the conclusion that this behaviour can be seen as a Nix bug.
Possible workarounds are referencing the sub-flake either implicitly via
git+file:
or explicitly marking it as apath:
.This gives links to some other issues:
The general use case of referencing sub-flakes by path is discussed in #3978.
The actual interpretation of the path to the sub-flake is an important cause of the issue, as the plain relative path not explicitly marked as
path:
resolves to the full absoulte nix-store path of the flake's repo:url = "path:a/relative/path"
causes this path to still land as relative in the lock file, whileurl = "./a/relative/path/"
causes it to be converted into an absolute path at locking time – which can change and then result in a behaviour as I've described.But how does this fit the nix docs?
This problem is already discussed in #5836.
Priorities
Add 👍 to issues you find important.
The text was updated successfully, but these errors were encountered: