buildEnv: improve file check to avoid false-positives
The original change in #55372 was supposed to fix the case where a store path which is a file should be placed into `buildEnv` which broke with a fairly misleading Perl error. Unfortunately this introduced a regression, `findFiles` can have targets that are files if the file isn't a store path. Rather than adding more obscure checks with probably further regressions, I figured that it's better to replicate the behavior of `lib.isStorePath` and explicitly check if the store path is a file and break in this case only. This should also fix recent staging issues.
This commit is contained in:
parent
e2cd07b997
commit
9fcd3bffc2
|
@ -26,6 +26,13 @@ sub isInPathsToLink {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Similar to `lib.isStorePath`
|
||||||
|
sub isStorePath {
|
||||||
|
my $path = shift;
|
||||||
|
my $storePath = "@storeDir@";
|
||||||
|
|
||||||
|
return substr($path, 0, 1) eq "/" && dirname($path) eq $storePath;
|
||||||
|
}
|
||||||
|
|
||||||
# For each activated package, determine what symlinks to create.
|
# For each activated package, determine what symlinks to create.
|
||||||
|
|
||||||
|
@ -84,8 +91,9 @@ sub checkCollision {
|
||||||
sub findFiles {
|
sub findFiles {
|
||||||
my ($relName, $target, $baseName, $ignoreCollisions, $checkCollisionContents, $priority) = @_;
|
my ($relName, $target, $baseName, $ignoreCollisions, $checkCollisionContents, $priority) = @_;
|
||||||
|
|
||||||
if (-f $target) {
|
# The store path must not be a file
|
||||||
die "Path $target is a file and can't be merged into an environment using pkgs.buildEnv!";
|
if (-f $target && isStorePath $target) {
|
||||||
|
die "The store path $target is a file and can't be merged into an environment using pkgs.buildEnv!";
|
||||||
}
|
}
|
||||||
|
|
||||||
# Urgh, hacky...
|
# Urgh, hacky...
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# a fork of the buildEnv in the Nix distribution. Most changes should
|
# a fork of the buildEnv in the Nix distribution. Most changes should
|
||||||
# eventually be merged back into the Nix distribution.
|
# eventually be merged back into the Nix distribution.
|
||||||
|
|
||||||
{ buildPackages, runCommand, lib }:
|
{ buildPackages, runCommand, lib, substituteAll }:
|
||||||
|
|
||||||
lib.makeOverridable
|
lib.makeOverridable
|
||||||
({ name
|
({ name
|
||||||
|
@ -43,6 +43,13 @@ lib.makeOverridable
|
||||||
, meta ? {}
|
, meta ? {}
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
builder = substituteAll {
|
||||||
|
src = ./builder.pl;
|
||||||
|
inherit (builtins) storeDir;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
|
||||||
runCommand name
|
runCommand name
|
||||||
rec {
|
rec {
|
||||||
inherit manifest ignoreCollisions checkCollisionContents passthru
|
inherit manifest ignoreCollisions checkCollisionContents passthru
|
||||||
|
@ -67,6 +74,6 @@ runCommand name
|
||||||
passAsFile = if builtins.stringLength pkgs >= 128*1024 then [ "pkgs" ] else null;
|
passAsFile = if builtins.stringLength pkgs >= 128*1024 then [ "pkgs" ] else null;
|
||||||
}
|
}
|
||||||
''
|
''
|
||||||
${buildPackages.perl}/bin/perl -w ${./builder.pl}
|
${buildPackages.perl}/bin/perl -w ${builder}
|
||||||
eval "$postBuild"
|
eval "$postBuild"
|
||||||
'')
|
'')
|
||||||
|
|
Loading…
Reference in a new issue