Marc Weber schrieb:
The key function is
getArgs which simply is some kind of map replacing all occurences of
attribute names with the attribute values.
Thus [ "dep1" "dep2" ] becomes [ <derivation dep1> <derivation dep2> ]
If a dependency (requirement) hasn't been supplied an exception is
thrown. Thus you no longer need an extra call checkArgs ..
The second advantage is that you can no only pass a set of args but also
a set of configure args (see confArgsReqs).. Then you won't get a set of
derivations taken from args but a set of configure argument strings..
flatten the set and you are done..
Any comments?
# # all-packages.nix:
# foo = (import [..]) {
# inherit opengl otherlib directx winlib spellde spellus gnused;
# flags = ["opengl" "spellde"];
# }
I'm not quite sure but is this about optional dependencies? In Haskell,
one would simply use a Maybe type for that, i.e.
ghostscript =
{ stdenv, fetchurl, libjpeg, libpng, zlib, x11 ? Nothing} :
{
...
buildInputs = [
libjpeg libpng zlib
(case x11 of {Nothing -> null; Just x11 -> x11})
];
}
In other words, if the argument x11 supplied is Nothing then disable x11
support, otherwise enable it. It seems that null takes a similar role
as Nothing but unfortunately, everything can be null (?).
With proper helper-functions like
maybe = mx : n : f : case mx of {Nothing -> n; Just x -> f x}
has = mx : maybe mx false (x:true)
we can succinctly write
configureFlags = "
${if has x11 then "--with-x" else "--without-x"}
";
instead of
configureFlags = "
${if x11Support then "--with-x" else "--without-x"}
";
and there is no need to supply the superfluous x11Support flag.
Regards,
apfelmus
_______________________________________________
nix-dev mailing list
[email protected]
https://mail.cs.uu.nl/mailman/listinfo/nix-dev