NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
11.51k stars 1.44k forks source link

Source roots result in /nix/store/<hash>-<hash>-source #10627

Open edolstra opened 2 months ago

edolstra commented 2 months ago

Describe the bug

In a flake with a derivation attribute like

src = ./.;

the tree gets copied into the store as /nix/store/<hash1>-<hash2>-source. This is because (pre lazy-trees) the basename of the tree is /nix/store/<hash2>-source.

This double-copying is obviously undesirable, but we can't fix it without a breaking change (i.e. without changing derivation paths).

On lazy-trees, we can at least avoid writing /nix/store/<hash2>-source to disk, but we do need to hash the input to compute <hash2>. (See https://github.com/NixOS/nix/commit/c5ae41d8be6eb391ae39de9cce58b5e6b9e8085b.)

Steps To Reproduce

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

A clear and concise description of what you expected to happen.

nix-env --version output

Additional context

Add any other context about the problem here.

Priorities

Add :+1: to issues you find important.

KiaraGrouwstra commented 1 month ago

we could already improve on the user experience here by warning the user to avoid such paths.

roberth commented 3 days ago

This is a pre-flakes behavior that would be a breaking change.

we could already improve on the user experience here by warning the user to avoid such paths.

I believe this would trigger quite often, and without being all that actionable for most users.

We'd better address the root cause, which is putting flakes in the store in the first place, making this problem prevalent instead of niche.

We could do so with either