Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stdenv.mkDerivation: Remove
checkDependencyList
I recently encountered this error attempting to build a derivation: ``` error: … while calling the 'derivationStrict' builtin at /builtin/derivation.nix:9:12: (source not available) … while evaluating derivation 'infra-shell' whose name attribute is located at /nix/store/ppm74s0slima7385piksmdcnvcawgs1x-source/pkgs/stdenv/generic/make-derivation.nix:353:7 … while evaluating attribute 'nativeBuildInputs' of derivation 'infra-shell' at /nix/store/ppm74s0slima7385piksmdcnvcawgs1x-source/pkgs/stdenv/generic/make-derivation.nix:397:7: 396| depsBuildBuild = elemAt (elemAt dependencies 0) 0; 397| nativeBuildInputs = elemAt (elemAt dependencies 0) 1; | ^ 398| depsBuildTarget = elemAt (elemAt dependencies 0) 2; error: Dependency is not of a valid type: element 23 of nativeBuildInputs for infra-shell ``` This isn't very helpful; it doesn't tell me what the type of the dependency is. I'm also not directly constructing `stdenv.mkDerivation { nativeBuildInputs = [...]; }`, so it's not obvious what "element 23" would be (the derivation is constructed through several layers of helpers, like many derivations in nixpkgs are). Ultimately, element 23 was a function, which surfaces another issue: ``` nix-repl> throw "Dependency is not of a valid type: ${a: a}" error: … while evaluating a path segment at «string»:1:43: 1| throw "Dependency is not of a valid type: ${a: a}" | ^ error: cannot coerce a function to a string ``` (`builtins.toString` produces similar results.) The Nix language doesn't provide a safe value printing function, so we can't really construct a good error message here. The good news is that we can remove this error checking code from nixpkgs entirely without losing usability. Here's the error message on Nix 2.19.3: ``` error: … while calling the 'derivationStrict' builtin at /derivation-internal.nix:9:12: 8| 9| strict = derivationStrict drvAttrs; | ^ 10| … while evaluating derivation 'my-derivation' whose name attribute is located at /Users/wiggles/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:347:7 … while evaluating attribute 'nativeBuildInputs' of derivation 'my-derivation' at /Users/wiggles/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:391:7: 390| depsBuildBuild = elemAt (elemAt dependencies 0) 0; 391| nativeBuildInputs = elemAt (elemAt dependencies 0) 1; | ^ 392| depsBuildTarget = elemAt (elemAt dependencies 0) 2; error: cannot coerce a function to a string ``` Thanks to PRs like NixOS/nix#9754, these error messages will improve in coming Nix releases: ``` … while evaluating attribute 'nativeBuildInputs' of derivation 'my-derivation' at /Users/wiggles/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:391:7: 390| depsBuildBuild = elemAt (elemAt dependencies 0) 0; 391| nativeBuildInputs = elemAt (elemAt dependencies 0) 1; | ^ 392| depsBuildTarget = elemAt (elemAt dependencies 0) 2; … while evaluating one element of the list error: cannot coerce a function to a string: «lambda @ /Users/wiggles/nixpkgs/xxx-derivation.nix:7:28» ```
- Loading branch information