Merge pull request #157106 from lheckemann/better-error-for-bad-buildinputs

stdenv/make-derivation: check that all inputs are of an appropriate type

authored by

Linus Heckemann and committed by
GitHub
676e4d42 b0c6c8c9

+19 -13
+19 -13
pkgs/stdenv/generic/make-derivation.nix
··· 193 else lib.subtractLists hardeningDisable (defaultHardeningFlags ++ hardeningEnable); 194 # hardeningDisable additionally supports "all". 195 erroneousHardeningFlags = lib.subtractLists supportedHardeningFlags (hardeningEnable ++ lib.remove "all" hardeningDisable); 196 in if builtins.length erroneousHardeningFlags != 0 197 then abort ("mkDerivation was called with unsupported hardening flags: " + lib.generators.toPretty {} { 198 inherit erroneousHardeningFlags hardeningDisable hardeningEnable supportedHardeningFlags; ··· 208 209 dependencies = map (map lib.chooseDevOutputs) [ 210 [ 211 - (map (drv: drv.__spliced.buildBuild or drv) depsBuildBuild) 212 - (map (drv: drv.nativeDrv or drv) nativeBuildInputs 213 ++ lib.optional separateDebugInfo' ../../build-support/setup-hooks/separate-debug-info.sh 214 ++ lib.optional stdenv.hostPlatform.isWindows ../../build-support/setup-hooks/win-dll-link.sh 215 ++ lib.optionals doCheck checkInputs 216 - ++ lib.optionals doInstallCheck' installCheckInputs) 217 - (map (drv: drv.__spliced.buildTarget or drv) depsBuildTarget) 218 ] 219 [ 220 - (map (drv: drv.__spliced.hostHost or drv) depsHostHost) 221 - (map (drv: drv.crossDrv or drv) buildInputs) 222 ] 223 [ 224 - (map (drv: drv.__spliced.targetTarget or drv) depsTargetTarget) 225 ] 226 ]; 227 propagatedDependencies = map (map lib.chooseDevOutputs) [ 228 [ 229 - (map (drv: drv.__spliced.buildBuild or drv) depsBuildBuildPropagated) 230 - (map (drv: drv.nativeDrv or drv) propagatedNativeBuildInputs) 231 - (map (drv: drv.__spliced.buildTarget or drv) depsBuildTargetPropagated) 232 ] 233 [ 234 - (map (drv: drv.__spliced.hostHost or drv) depsHostHostPropagated) 235 - (map (drv: drv.crossDrv or drv) propagatedBuildInputs) 236 ] 237 [ 238 - (map (drv: drv.__spliced.targetTarget or drv) depsTargetTargetPropagated) 239 ] 240 ]; 241
··· 193 else lib.subtractLists hardeningDisable (defaultHardeningFlags ++ hardeningEnable); 194 # hardeningDisable additionally supports "all". 195 erroneousHardeningFlags = lib.subtractLists supportedHardeningFlags (hardeningEnable ++ lib.remove "all" hardeningDisable); 196 + 197 + checkDependencyList = checkDependencyList' []; 198 + checkDependencyList' = positions: name: deps: lib.flip lib.imap1 deps (index: dep: 199 + if lib.isDerivation dep || isNull dep || builtins.typeOf dep == "string" || builtins.typeOf dep == "path" then dep 200 + else if lib.isList dep then checkDependencyList' ([index] ++ positions) name dep 201 + else throw "Dependency is not of a valid type: ${lib.concatMapStrings (ix: "element ${toString ix} of ") ([index] ++ positions)}${name} for ${attrs.name or attrs.pname}"); 202 in if builtins.length erroneousHardeningFlags != 0 203 then abort ("mkDerivation was called with unsupported hardening flags: " + lib.generators.toPretty {} { 204 inherit erroneousHardeningFlags hardeningDisable hardeningEnable supportedHardeningFlags; ··· 214 215 dependencies = map (map lib.chooseDevOutputs) [ 216 [ 217 + (map (drv: drv.__spliced.buildBuild or drv) (checkDependencyList "depsBuildBuild" depsBuildBuild)) 218 + (map (drv: drv.nativeDrv or drv) (checkDependencyList "nativeBuildInputs" nativeBuildInputs 219 ++ lib.optional separateDebugInfo' ../../build-support/setup-hooks/separate-debug-info.sh 220 ++ lib.optional stdenv.hostPlatform.isWindows ../../build-support/setup-hooks/win-dll-link.sh 221 ++ lib.optionals doCheck checkInputs 222 + ++ lib.optionals doInstallCheck' installCheckInputs)) 223 + (map (drv: drv.__spliced.buildTarget or drv) (checkDependencyList "depsBuildTarget" depsBuildTarget)) 224 ] 225 [ 226 + (map (drv: drv.__spliced.hostHost or drv) (checkDependencyList "depsHostHost" depsHostHost)) 227 + (map (drv: drv.crossDrv or drv) (checkDependencyList "buildInputs" buildInputs)) 228 ] 229 [ 230 + (map (drv: drv.__spliced.targetTarget or drv) (checkDependencyList "depsTargetTarget" depsTargetTarget)) 231 ] 232 ]; 233 propagatedDependencies = map (map lib.chooseDevOutputs) [ 234 [ 235 + (map (drv: drv.__spliced.buildBuild or drv) (checkDependencyList "depsBuildBuildPropagated" depsBuildBuildPropagated)) 236 + (map (drv: drv.nativeDrv or drv) (checkDependencyList "propagatedNativeBuildInputs" propagatedNativeBuildInputs)) 237 + (map (drv: drv.__spliced.buildTarget or drv) (checkDependencyList "depsBuildTargetPropagated" depsBuildTargetPropagated)) 238 ] 239 [ 240 + (map (drv: drv.__spliced.hostHost or drv) (checkDependencyList "depsHostHostPropagated" depsHostHostPropagated)) 241 + (map (drv: drv.crossDrv or drv) (checkDependencyList "propagatedBuildInputs" propagatedBuildInputs)) 242 ] 243 [ 244 + (map (drv: drv.__spliced.targetTarget or drv) (checkDependencyList "depsTargetTargetPropagated" depsTargetTargetPropagated)) 245 ] 246 ]; 247