From ed58e70864e139ecf39ddaf82b559367bfb28d81 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 24 Sep 2006 18:59:49 +0000 Subject: [PATCH] * Rather than having the Nixpkgs config file as a flat set of configuration switches, it should be structured. For instance, { firefox = { enableRealPlayer = true; }; quake3 = { dataFiles = "/windows/D/Program Files/Quake 3/baseq3"; } } Configuration switches can be obtained using the function getConfig, e.g., `getConfig ["firefox" "enableRealPlayer"] false'. svn path=/nixpkgs/trunk/; revision=6596 --- pkgs/top-level/all-packages.nix | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 95e585a399a..c268e0cef84 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -77,12 +77,22 @@ rec { useFromStdenv = hasIt: it: alternative: if hasIt then it else alternative; + # Return an attribute from nested attribute sets. For instance ["x" + # "y"] applied to some set e returns e.x.y, if it exists. The + # default value is returned otherwise. + getAttr = attrPath: default: e: + let { + attr = builtins.head attrPath; + body = + if attrPath == [] then e + else if builtins ? hasAttr && builtins.hasAttr attr e + then getAttr (builtins.tail attrPath) default (builtins.getAttr attr e) + else default; + }; + # Return an attribute from the Nixpkgs configuration file, or # a default value if the attribute doesn't exist. - getConfig = attr: default: - if builtins ? hasAttr && builtins.hasAttr attr config - then builtins.getAttr attr config - else default; + getConfig = attrPath: default: getAttr attrPath default config; # The contents of the configuration file found at $NIXPKGS_CONFIG or # $HOME/.nixpkgs/config.nix. @@ -2596,7 +2606,7 @@ rec { flashplayer ] # RealPlayer is disabled by default for legal reasons. - ++ (if getConfig "enableRealPlayer" false then [RealPlayer] else []) + ++ (if getConfig ["firefox" "enableRealPlayer"] false then [RealPlayer] else []) ++ (if blackdown != null then [blackdown] else []); };