mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-01 15:11:25 +00:00
buildEnv: break with a proper error if one path is actually a file
I noticed by creating `buildEnv` where I accidentally put a derivation from `pkgs.writeText` into `paths` and got a broken build with the following misleading error message: ``` Use of uninitialized value $stat1 in numeric ne (!=) at /nix/store/9g4wc31j7a2xp22xpgwr0qssfxahxdzl-builder.pl line 74. Use of uninitialized value $stat1 in bitwise and (&) at /nix/store/9g4wc31j7a2xp22xpgwr0qssfxahxdzl-builder.pl line 75. different permissions in `' and `/nix/store/0vy5ss91laxvwkyvrbld5hv27i88qk5w-noise': 0000 <-> 0444 at /nix/store/9g4wc31j7a2xp22xpgwr0qssfxahxdzl-builder.pl line 75. ``` It can be reproduced with an expression like this: ``` nix { pkgs ? import <nixpkgs> { } }: let file = pkgs.writeText "test" '' content ''; in pkgs.buildEnv { name = "test-env"; paths = [ /* ... */ file ]; } ```
This commit is contained in:
parent
b1bbd94bb6
commit
1cab56e01a
@ -84,6 +84,10 @@ sub checkCollision {
|
||||
sub findFiles {
|
||||
my ($relName, $target, $baseName, $ignoreCollisions, $checkCollisionContents, $priority) = @_;
|
||||
|
||||
if (-f $target) {
|
||||
die "Path $target is a file and can't be merged into an environment using pkgs.buildEnv!";
|
||||
}
|
||||
|
||||
# Urgh, hacky...
|
||||
return if
|
||||
$relName eq "/propagated-build-inputs" ||
|
||||
|
Loading…
Reference in New Issue
Block a user