Open rmcgibbo opened 3 years ago
I'm new to nix. And I don't even know how print-and-debug the value of any internal variables. All I known is to run nix-build
with --show-trace
to get the prompts.
I would like to share my experiment.
when it was originally:
cmakeFlags = (args.cmakeFlags or []) ++ [ "-DBUILD_SHARED_LIBS:BOOL=OFF" ];
The error prompted: value is null while a list was expected
I guess the (args.cmakeFlags or [])
become null and lead to the result of concatLists(++)
being null.
But when I changed it to:
cmakeFlags = (if args.cmakeFlags == null then [] else args.cmakeFlags) ++ [ "-DBUILD_SHARED_LIBS:BOOL=OFF" ];
The error prompted: attribute 'cmakeFlags' missing
Not robusting enough? So I tried :
(if builtins.hasAttr "cmakeFlags" args then args.cmakeFlags else []) ++ [ "-DBUILD_SHARED_LIBS:BOOL=OFF" ];
The error prompted: value is null while a list was expected
, AGAIN!
Finally, this annoyed me, so I used this to fix the problem.
(if builtins.hasAttr "cmakeFlags" args then [ args.cmakeFlags ] else []) ++ [ "-DBUILD_SHARED_LIBS:BOOL=OFF" ];
Obviously, it would be a problem if the cmakeFlags was originally a list.
It worked at least. And I would appreciate it if any one tell me the reason why all these happened.
If you run nix shell -f /home/jtojnar/Projects/nixpkgs-hammering -c nixpkgs-hammer nixStatic --show-trace
, you will get the Nix expression used to run the checks. You can save it into a file and then evaluate it using nix-instantiate --strict --json --eval test.nix
, commenting out individual overlays using binary search to find the offending check. In this case it looks like overlays/unnecessary-parallel-building.nix
.
You are right that the issue is that cmakeFlags
is null. <set>.<attr> or <fallback>
syntax only returns the fallback if the attribute set does not contain the attribute – when it is present but set to null, the syntax will return null.
(if builtins.hasAttr "cmakeFlags" args then [ args.cmakeFlags ] else []) ++ [ "-DBUILD_SHARED_LIBS:BOOL=OFF" ]
will return a list or null, depending on the original value, wrapped in a list. That avoids the type error but is still not optimal since inputs should be precisely of type list of derivations.
You could use:
(if args.cmakeFlags or [] == null then [] else args.cmakeFlags or []) ++ [ "-DBUILD_SHARED_LIBS:BOOL=OFF" ]
or
(if args.cmakeFlags or null == null then [] else args.cmakeFlags) ++ [ "-DBUILD_SHARED_LIBS:BOOL=OFF" ]
Running with --show-trace
also reveals that the null
value comes from https://github.com/NixOS/nixpkgs/blob/6d049fcad132f1f05336fcf373ec009d0d9a62cc/pkgs/development/libraries/libtiff/default.nix#L22-L24
In nixpkgs e58bd1763e4cd047371712f2030716440b40cff9
This looks like a new error beyond those that were flagged in #97