mirror of
https://github.com/NixOS/nix
synced 2025-06-24 18:01:16 +02:00
copyPathToStore(): Preserve symlinks
E.g. in a derivation attribute `foo = ./bar`, if ./bar is a symlink, we should copy the symlink to the store, not its target. This restores the behaviour of Nix <= 2.19.
This commit is contained in:
parent
92bf150b1c
commit
26b87e78b5
4 changed files with 19 additions and 2 deletions
|
@ -2384,7 +2384,7 @@ StorePath EvalState::copyPathToStore(NixStringContext & context, const SourcePat
|
||||||
: [&]() {
|
: [&]() {
|
||||||
auto dstPath = fetchToStore(
|
auto dstPath = fetchToStore(
|
||||||
*store,
|
*store,
|
||||||
path.resolveSymlinks(),
|
path.resolveSymlinks(SymlinkResolution::Ancestors),
|
||||||
settings.readOnlyMode ? FetchMode::DryRun : FetchMode::Copy,
|
settings.readOnlyMode ? FetchMode::DryRun : FetchMode::Copy,
|
||||||
path.baseName(),
|
path.baseName(),
|
||||||
ContentAddressMethod::Raw::NixArchive,
|
ContentAddressMethod::Raw::NixArchive,
|
||||||
|
|
|
@ -164,6 +164,7 @@ suites = [
|
||||||
'debugger.sh',
|
'debugger.sh',
|
||||||
'extra-sandbox-profile.sh',
|
'extra-sandbox-profile.sh',
|
||||||
'help.sh',
|
'help.sh',
|
||||||
|
'symlinks.sh',
|
||||||
],
|
],
|
||||||
'workdir': meson.current_source_dir(),
|
'workdir': meson.current_source_dir(),
|
||||||
},
|
},
|
||||||
|
|
|
@ -15,7 +15,7 @@ echo "output path is $outPath"
|
||||||
[[ ! -w $outPath ]]
|
[[ ! -w $outPath ]]
|
||||||
|
|
||||||
text=$(cat "$outPath/hello")
|
text=$(cat "$outPath/hello")
|
||||||
if test "$text" != "Hello World!"; then exit 1; fi
|
[[ "$text" = "Hello World!" ]]
|
||||||
|
|
||||||
TODO_NixOS
|
TODO_NixOS
|
||||||
|
|
||||||
|
|
16
tests/functional/symlinks.sh
Normal file
16
tests/functional/symlinks.sh
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
source common.sh
|
||||||
|
|
||||||
|
# Check that when we have a derivation attribute that refers to a
|
||||||
|
# symlink, we copy the symlink, not its target.
|
||||||
|
# shellcheck disable=SC2016
|
||||||
|
nix build --impure --no-link --expr '
|
||||||
|
with import ./config.nix;
|
||||||
|
|
||||||
|
mkDerivation {
|
||||||
|
name = "simple";
|
||||||
|
builder = builtins.toFile "builder.sh" "[[ -L \"$symlink\" ]]; mkdir $out";
|
||||||
|
symlink = ./lang/symlink-resolution/foo/overlays;
|
||||||
|
}
|
||||||
|
'
|
Loading…
Add table
Add a link
Reference in a new issue