Skip to content

Commit

Permalink
Copy roots to the store as /nix/store/<hash1>-<hash2>-source
Browse files Browse the repository at this point in the history
When you have a attribute like

  src = ./.;

the root of the flake should produce a store path
/nix/store/<hash1>-<hash2>-source, because before lazy trees, the
basename of the tree in the store was /nix/store/<hash2>-source. Even
though that was really a bug, we do need to mimic this behaviour so we
don't change evaluation results.
  • Loading branch information
edolstra committed Apr 30, 2024
1 parent a65c8a9 commit c5ae41d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/libexpr/eval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2431,7 +2431,16 @@ StorePath EvalState::copyPathToStore(NixStringContext & context, const SourcePat
*store,
path.resolveSymlinks(),
settings.readOnlyMode ? FetchMode::DryRun : FetchMode::Copy,
path.baseName(),
/* For backwards compatibility, if the path is the
root of a tree, we need to construct a
"double-copied" store path like
/nix/store/<hash1>-<hash2>-source. We don't need to
materialize /nix/store/<hash2>-source
though. Still, this requires reading/hashing the
path twice. */
path.path.isRoot()
? store->computeStorePath("source", *path.accessor, path.path).first.to_string()
: path.baseName(),
FileIngestionMethod::Recursive,
nullptr,
repair);
Expand Down

0 comments on commit c5ae41d

Please sign in to comment.