2008-12-20 02:20:35 +01:00
|
|
|
{lib, pkgs} :
|
|
|
|
let inherit (lib) nv nvs; in
|
|
|
|
{
|
2009-01-27 15:08:49 +01:00
|
|
|
# see for example:
|
2009-01-27 15:01:00 +01:00
|
|
|
# - development/interpreters/php_configurable/default.nix
|
|
|
|
# - .. search composableDerivation in all-packages.nix ..
|
|
|
|
#
|
2008-12-20 02:20:35 +01:00
|
|
|
# You should be able to override anything you like easily
|
|
|
|
# grep the mailinglist by title "python proposal" (dec 08)
|
|
|
|
# -> http://mail.cs.uu.nl/pipermail/nix-dev/2008-December/001571.html
|
|
|
|
# to see why this got complicated when using all its features
|
2009-03-07 00:21:24 +01:00
|
|
|
# TODO add newer example using new syntax (kernel derivation proposal -> mailinglist)
|
2008-12-20 02:20:35 +01:00
|
|
|
composableDerivation = {
|
2009-03-07 00:21:24 +01:00
|
|
|
mkDerivation ? pkgs.stdenv.mkDerivation,
|
|
|
|
|
|
|
|
# list of functions to be applied before defaultOverridableDelayableArgs removes removeAttrs names
|
|
|
|
# prepareDerivationArgs handles derivation configurations
|
2009-03-07 00:21:28 +01:00
|
|
|
applyPreTidy ? [ lib.prepareDerivationArgs ],
|
2009-03-07 00:21:24 +01:00
|
|
|
|
2009-03-07 00:21:28 +01:00
|
|
|
# consider adding addtional elements by derivation.merge { removeAttrs = ["elem"]; };
|
2009-03-07 00:21:24 +01:00
|
|
|
removeAttrs ? ["cfg" "flags"]
|
|
|
|
|
|
|
|
}: (lib.defaultOverridableDelayableArgs ( a: mkDerivation a)
|
|
|
|
{
|
|
|
|
inherit applyPreTidy removeAttrs;
|
|
|
|
}).merge;
|
2008-12-20 02:20:35 +01:00
|
|
|
|
|
|
|
# some utility functions
|
|
|
|
# use this function to generate flag attrs for prepareDerivationArgs
|
|
|
|
# E nable D isable F eature
|
|
|
|
edf = {name, feat ? name, enable ? {}, disable ? {} , value ? ""}:
|
|
|
|
nvs name {
|
|
|
|
set = {
|
|
|
|
configureFlags = ["--enable-${feat}${if value == "" then "" else "="}${value}"];
|
|
|
|
} // enable;
|
|
|
|
unset = {
|
|
|
|
configureFlags = ["--disable-${feat}"];
|
|
|
|
} // disable;
|
|
|
|
};
|
|
|
|
|
|
|
|
# same for --with and --without-
|
|
|
|
# W ith or W ithout F eature
|
|
|
|
wwf = {name, feat ? name, enable ? {}, disable ? {}, value ? ""}:
|
|
|
|
nvs name {
|
|
|
|
set = {
|
|
|
|
configureFlags = ["--with-${feat}${if value == "" then "" else "="}${value}"];
|
|
|
|
} // enable;
|
|
|
|
unset = {
|
|
|
|
configureFlags = ["--without-${feat}"];
|
|
|
|
} // disable;
|
|
|
|
};
|
|
|
|
}
|