From 118e9d6ebf3c8106acc6a26fb9cc44a6feb70545 Mon Sep 17 00:00:00 2001 From: Michael Raskin <7c6f434c@mail.ru> Date: Sat, 11 Aug 2007 11:14:36 +0000 Subject: [PATCH] Corrected a flaw that made automated package silently accept any extra arguments svn path=/nixpkgs/trunk/; revision=9101 --- pkgs/applications/editors/vim/default.nix | 20 ++++++++------------ pkgs/lib/default.nix | 10 ++++++++++ pkgs/top-level/template.nix | 17 +++++++---------- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/pkgs/applications/editors/vim/default.nix b/pkgs/applications/editors/vim/default.nix index 317fedd902d..840881cfd09 100644 --- a/pkgs/applications/editors/vim/default.nix +++ b/pkgs/applications/editors/vim/default.nix @@ -2,7 +2,6 @@ args: let defList = []; #stdenv and fetchurl are added automatically - notForBuildInputs = []; getVal = (args.lib.getValue args defList); check = args.lib.checkFlag args; reqsList = [ @@ -11,14 +10,13 @@ let ["x11Support" "libX11"] ["hugeFeatures"] ["true" "ncurses"] + ["false" "libSM"] ]; - buildInputsNames = args.lib.filter (x: (null!=getVal x)&& - (! args.lib.isInList (notForBuildInputs ++ - ["stdenv" "fetchurl" "lib"] ++ - (map builtins.head reqsList)) x)) - /*["libX11" "glib" "gtk" "pkgconfig" "libXpm" "libXext" - "libXau" "libXt" "libXaw" "ncurses"];*/ - (builtins.attrNames args); + buildInputsNames = args.lib.filter (x: (null!=getVal x)) + (args.lib.uniqList {inputList = + (args.lib.concatLists (map + (x:(if (x==[]) then [] else builtins.tail x)) + reqsList));}); in assert args.lib.checkReqs args defList reqsList; args.stdenv.mkDerivation { @@ -36,10 +34,8 @@ args.stdenv.mkDerivation { inherit (args) ncurses; - debug = builtins.attrNames args; - buildInputs = args.lib.filter (x: x!=null) (map getVal buildInputsNames); - - preConfigure = "echo \$debug"; + buildInputs = args.lib.filter (x: (x!=null)) (map getVal buildInputsNames); + postInstall = "ln -s $out/bin/vim $out/bin/vi"; preBuild="touch src/auto/link.sed"; configureFlags=" --enable-gui=auto --disable-xim "+ diff --git a/pkgs/lib/default.nix b/pkgs/lib/default.nix index a6e87b21802..2359a1d3dd0 100644 --- a/pkgs/lib/default.nix +++ b/pkgs/lib/default.nix @@ -127,6 +127,7 @@ rec { # Return true only if there is an attribute and it is true. checkFlag = attrSet: name: if (name == "true") then true else + if (name == "false") then false else getAttr [name] false attrSet ; logicalOR = x: y: x || y; @@ -160,4 +161,13 @@ rec { if (list == []) then false else if (x == (head list)) then true else isInList (tail list) x; + + uniqList = {inputList, outputList ? []}: + if (inputList == []) then outputList else + let x=head inputList; + newOutputList = outputList ++ + (if (isInList outputList x) then [] else [x]); + in uniqList {outputList=newOutputList; + inputList = (tail inputList);}; + } diff --git a/pkgs/top-level/template.nix b/pkgs/top-level/template.nix index 4f834dd18f1..62ff006ac6f 100644 --- a/pkgs/top-level/template.nix +++ b/pkgs/top-level/template.nix @@ -4,21 +4,18 @@ let (assert false) - correct it; List element is of form ["name" default] ]; #stdenv and fetchurl are added automatically - notForBuildInputs = [ -(assert false) - correct it; List of names of non-buildInput arguments - ]; getVal = (args.lib.getValue args defList); check = args.lib.checkFlag args; reqsList = [ (assert false) - correct it; List element is of form ["name" "requirement-name" ... ] + ["true"] + ["false"] ]; - buildInputsNames = args.lib.filter (x: (null!=getVal x)&& - (! args.lib.isInList (notForBuildInputs ++ - ["stdenv" "fetchurl" "lib"] ++ - (map builtins.head reqsList)) x)) - /*["libX11" "glib" "gtk" "pkgconfig" "libXpm" "libXext" - "libXau" "libXt" "libXaw" "ncurses"];*/ - (builtins.attrNames args); + buildInputsNames = args.lib.filter (x: (null!=getVal x)) + (args.lib.uniqList {inputList = + (args.lib.concatLists (map + (x:(if (x==[]) then [] else builtins.tail x)) + reqsList));}); in assert args.lib.checkReqs args defList reqsList; with args;