-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Basename of current directory goes into derivation for filterSource on ./. #1305
Comments
@edolstra what would be the implications of This would help with determinism for many Nix functions while keeping the UX. |
Well, |
That behaviour cause problems from time to time, due to the hash being prepended to the filename. I wonder how it would be if it produced /nix/store/...-builder.sh/builder.sh instead. It looks both ugly and pretty at the same time. Ugly because of the seemingly pointless duplicated name, and pretty because now the basename is the same inside and outside the Nix store. |
This adds to "a list of obstacles that makes hash dependent based on how the source is retrieved" in #904 |
Would anybody be opposed to changing |
@nh2 I don't think so. |
For drive-by readers, the pain created by this bug is explained in detail in @domenkozar's talk at NixCon 2017. |
Ugly workaround for now might be |
You can use |
Note: if you want to do something like To circumvent that use
will have the same hash as |
Can somebody provide in here an example of how We should proably also mention that in the manuals. |
Examples: {
src = builtins.path { name = "stack2nix"; path = ./.; };
} With filter: {
src = builtins.path {
name = "stack2nix";
path = ./.;
filter = path: type:
!(pkgs.lib.hasPrefix "." (baseNameOf path));
};
} |
this way, we get consistent store paths independent of wether we have the sources locally, or get them via `fetchGit`. See NixOS/nix#1305
this way, we get consistent store paths independent of wether we have the sources locally, or get them via `fetchGit`. See NixOS/nix#1305
This functionality is now available in nixpkgs master via
or to just rename an already cleaned source:
|
Currently, not providing `name` to `cleanSourceWith` will use the name of the imported directory. However, a common case is for this to be the top level of some repository. In that case, the name will be the name of the checkout on the current machine, which is not necessarily reproducible across different settings, and can lead to e.g. cache misses in CI. This is documented in the comment on `cleanSourceWith`, but this does not stop it being a subtle trap for users. There are different tradeoffs in each case: 1. If `cleanSourceWith` defaults to `"source"`, then we may end up with a user not knowing what directory a source store path corresponds to. However, it being called "unnamed" may give them a clue that there is a way for them to name it, and lead them to the definition of the function, which has a clear `name` parameter. 2. If `cleanSoureWith` defaults to the directory name, then a user may face occasional loss of caching, which is hard to notice, and hard to track down. Tracking it down likely requires use of more advanced tools like `nix-diff`, and reading the source of a lot of nix code. I think the downside of the status quo is worse. This is really another iteration of NixOS/nix#1305: that led to adding the `name` argument in the first place, this just makes us use a better default `name`.
Currently, not providing `name` to `cleanSourceWith` will use the name of the imported directory. However, a common case is for this to be the top level of some repository. In that case, the name will be the name of the checkout on the current machine, which is not necessarily reproducible across different settings, and can lead to e.g. cache misses in CI. This is documented in the comment on `cleanSourceWith`, but this does not stop it being a subtle trap for users. There are different tradeoffs in each case: 1. If `cleanSourceWith` defaults to `"source"`, then we may end up with a user not knowing what directory a source store path corresponds to. However, it being called "unnamed" may give them a clue that there is a way for them to name it, and lead them to the definition of the function, which has a clear `name` parameter. 2. If `cleanSoureWith` defaults to the directory name, then a user may face occasional loss of caching, which is hard to notice, and hard to track down. Tracking it down likely requires use of more advanced tools like `nix-diff`, and reading the source of a lot of nix code. I think the downside of the status quo is worse. This is really another iteration of NixOS/nix#1305: that led to adding the `name` argument in the first place, this just makes us use a better default `name`.
This is a move-over of NixOS/nixpkgs#24575 from nixpkgs, which turned out to be a nix issue.
When you use
filterSource (...) ./.
, nix puts thebasename
of the current dir, that is, the name of the parent directory, into the derivation.That is problematic because that could be
gnu-hello
orgnu-hello-myclone
or/tmp/asdf123
etc (see #904 for more such problems).I think that
filterSource
should not rely on the basename here.The easiest solution would be to just use the hash and not try to make up a nice extra name.
The text was updated successfully, but these errors were encountered: