Skip to content
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

don't copy path if it's already a (top-level) store path. #1731

Closed
wants to merge 1 commit into from

Conversation

LnL7
Copy link
Member

@LnL7 LnL7 commented Dec 12, 2017

Fixes #1728

Assuming there's no reason to do the extra copy.

$ nix repl
nix-repl> "${/nix/store/6vjwsyv4il8f9jm3wylbzmbbsa70qc33-hello-2.10}"
"/nix/store/6vjwsyv4il8f9jm3wylbzmbbsa70qc33-hello-2.10"
nix-repl> "${/nix/store/6vjwsyv4il8f9jm3wylbzmbbsa70qc33-hello-2.10/bin/hello}"
"/nix/store/xh98c1bv1fjrggl36dpj3j0wnsay94wp-hello"

Copy link
Member

@zimbatm zimbatm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@shlevy shlevy added the backlog label Apr 1, 2018
@shlevy shlevy self-assigned this Apr 1, 2018
@symphorien
Copy link
Member

Doesn't it make evaluation impure ? What "${/nix/store/6vjwsyv4il8f9jm3wylbzmbbsa70qc33-hello-2.10}" evaluates to depends on whether hello is already present in the store.

@LnL7
Copy link
Member Author

LnL7 commented Dec 1, 2018

I ran into this again today. This problem is easily solved with toString in most cases, but that's not obvious and can cause confusion. Given that it uses the semantics from isStorePath I feel like this is not a hacky special case, but I'll close this if the consensus is that it is.
/cc @NixOS/nix-core

@symphorien Indeed, however ensuring the path exists is pretty straightforward, eg. nix-store -r /nix/store/6vjwsyv4il8f9jm3wylbzmbbsa70qc33-hello-2.10. The specific case I use this for is reproducing issues with a known good/bad version of a package without having to figure out the exact package set and expression used to build it.

@timokau
Copy link
Member

timokau commented Nov 25, 2019

I also needed to work around this behaviour with builtins.storePath, conditioned on lib.isStorePath:

  system.extraSystemBuilderCmds = let
    # make sure store paths are not copied to the store again, which leads to
    # long filenames (https://github.com/NixOS/nix/issues/1728)
    nixpkgs_str = if lib.isStorePath pkgs.path then builtins.storePath pkgs.path else pkgs.path;
  in ''
    ln -sv '${nixpkgs_str}' "$out/nixpkgs"
    echo '${pkgs.path}'
  '';

The intention is to pin nixpkgs to the last version that was explicitly passed in through NIX_PATH, which may or may not be a store path.

@stale
Copy link

stale bot commented Feb 12, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Feb 12, 2021
@stale
Copy link

stale bot commented Apr 16, 2022

I closed this issue due to inactivity. → More info

@stale stale bot closed this Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

store path literals are copied to the store again
6 participants