In the past, I have seen (and recommended myself) to set mkDerivation
attributes (e.g. for cmakeFlags
) to null
to avoid causing unneeded rebuilds. For example:
cmakeFlags = if stdenv.isDarwin then [
"-DCMAKE_SKIP_BUILD_RPATH=OFF"
] else null;
using else null
instead of else []
.
However, I just found out that does not work at all with this common pattern:
cmakeFlags = (args.cmakeFlags or []) ++ [ "-DSTUFF..." ];
because (null or []) ++ []
is null ++ []
which fails with
value is null while a list was expected
An example is to try to biuld the following simple package:
$ nix-shell -p pkgsStatic.murmur
while evaluating the attribute 'cmakeFlags' of the derivation 'libtiff-4.1.0-x86_64-unknown-linux-musl' at pkgs/stdenv/generic/make-derivation.nix:198:11:
value is null while a list was expected, at pkgs/stdenv/adapters.nix:63:22
What do we do about this? What should we recommend right now in PRs?
Can we change the build process so that []
for somethingFlags
does not cause the eval to change, the same way as null
does?