From 1cab56e01a284d8fb29ae6b07616732f5bd3079b Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Thu, 7 Feb 2019 03:20:07 +0100 Subject: [PATCH] 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 { } }: let file = pkgs.writeText "test" '' content ''; in pkgs.buildEnv { name = "test-env"; paths = [ /* ... */ file ]; } ``` --- pkgs/build-support/buildenv/builder.pl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/build-support/buildenv/builder.pl b/pkgs/build-support/buildenv/builder.pl index 678f5a3fe9e..1f77edf86cb 100755 --- a/pkgs/build-support/buildenv/builder.pl +++ b/pkgs/build-support/buildenv/builder.pl @@ -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" ||