diff --git a/pkgs/applications/editors/vim/default.nix b/pkgs/applications/editors/vim/default.nix index 840881cfd09d..a08808a47567 100644 --- a/pkgs/applications/editors/vim/default.nix +++ b/pkgs/applications/editors/vim/default.nix @@ -12,6 +12,15 @@ let ["true" "ncurses"] ["false" "libSM"] ]; + nameSuffixes = [ + "hugeFeatures" "-huge" + "x11Support" "-X11" + ]; + configFlags = [ + "true" " --disable-xim " + "x11Support" " --enable-gui=auto " + "hugeFeatures" "--with-features=huge --enable-cscope --enable-multibyte --enable-xsmp" + ]; buildInputsNames = args.lib.filter (x: (null!=getVal x)) (args.lib.uniqList {inputList = (args.lib.concatLists (map @@ -20,12 +29,7 @@ let in assert args.lib.checkReqs args defList reqsList; args.stdenv.mkDerivation { - name = "vim-7.1" + - (if (check "hugeFeatures") then - "-huge" else "") - + (if (check "x11Support") - then "-X11" else "") - ; + name = args.lib.condConcat "vim-7.1" nameSuffixes check; src = args.fetchurl { url = ftp://ftp.nluug.nl/pub/editors/vim/unix/vim-7.1.tar.bz2; @@ -38,10 +42,7 @@ args.stdenv.mkDerivation { postInstall = "ln -s $out/bin/vim $out/bin/vi"; preBuild="touch src/auto/link.sed"; - configureFlags=" --enable-gui=auto --disable-xim "+ - (if (check "hugeFeatures") then - "--with-features=huge --enable-cscope --enable-multibyte --enable-xsmp " - else ""); + configureFlags = args.lib.condConcat "" configFlags check; meta = { description = "The most popular clone of the VI editor"; diff --git a/pkgs/lib/default.nix b/pkgs/lib/default.nix index a30fe46623ac..9ee216f82722 100644 --- a/pkgs/lib/default.nix +++ b/pkgs/lib/default.nix @@ -172,4 +172,14 @@ rec { in uniqList {outputList=newOutputList; inputList = (tail inputList);}; + condConcat = name: list: checker: + if list == [] then name else + if checker (head list) then + condConcat + (name + (head (tail list))) + (tail (tail list)) + checker + else condConcat + name (tail (tail list)) checker; + } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index cc09c1144031..28b1efa02a09 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3363,9 +3363,7 @@ rec { inherit (xlibs) libX11 libXext libSM libXpm libXt libXaw libXau; inherit (gtkLibs) glib gtk; - hugeFeatures = true; - gtkGUI = true; - x11Support = true; + flags = ["hugeFeatures" "gtkGUI" "x11Support"]; }; vlc = import ../applications/video/vlc { diff --git a/pkgs/top-level/template.nix b/pkgs/top-level/template.nix index 62ff006ac6f5..fabd6de584a8 100644 --- a/pkgs/top-level/template.nix +++ b/pkgs/top-level/template.nix @@ -16,18 +16,26 @@ let (args.lib.concatLists (map (x:(if (x==[]) then [] else builtins.tail x)) reqsList));}); + configFlags = [ + "true" "" +(assert false) - fill it; list consists of pairs "condition" "flags". "True" means always. + ]; + nameSuffixes = [ +(assert false) - fill it if needed, or blank it. + ]; in assert args.lib.checkReqs args defList reqsList; with args; args.stdenv.mkDerivation { - name = " -#!!! Fill me // -" ; + name = args.lib.condConcat " +#Fill the name // +" nameSuffixes check; src = args. #Put fetcher here buildInputs = args.lib.filter (x: x!=null) (map getVal buildInputsNames); + configureFlags = args.lib.condConcat "" configFlags check; meta = { description = "