From 21025cb280aef34956c6ddd6a62b0f251443417e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 24 Sep 2006 18:38:12 +0000 Subject: [PATCH] * Site-local configuration for Nixpkgs can now be stored in $NIXPKGS_CONFIG or $HOME/.nixpkgs/config.nix. E.g., a configuration file { enableRealPlayer = true; } will cause the RealPlayer plugin to be enabled in the Firefox wrapper, which isn't the default case. Previously users had to modify all-packages.nix for this sort of thing, which made it tricky to keep an installation up-to-date without losing those local configuration changes (channels would override such changes completely, for instance). svn path=/nixpkgs/trunk/; revision=6595 --- pkgs/top-level/all-packages.nix | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 37a80c08e2b..95e585a399a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -77,6 +77,33 @@ rec { useFromStdenv = hasIt: it: alternative: if hasIt then it else alternative; + # 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; + + # The contents of the configuration file found at $NIXPKGS_CONFIG or + # $HOME/.nixpkgs/config.nix. + config = + let { + toPath = builtins.toPath; + pathExists = name: + builtins ? pathExists && builtins.pathExists (toPath name); + + configFile = builtins.getEnv "NIXPKGS_CONFIG"; + homeDir = builtins.getEnv "HOME"; + configFile2 = homeDir + "/.nixpkgs/config.nix"; + + body = + if configFile != "" && pathExists configFile + then import (toPath configFile) + else if homeDir != "" && pathExists configFile2 + then import (toPath configFile2) + else {}; + }; + ### STANDARD ENVIRONMENT @@ -2567,8 +2594,10 @@ rec { plugins = [ MPlayerPlugin flashplayer -# RealPlayer # disabled by default for legal reasons - ] ++ (if blackdown != null then [blackdown] else []); + ] + # RealPlayer is disabled by default for legal reasons. + ++ (if getConfig "enableRealPlayer" false then [RealPlayer] else []) + ++ (if blackdown != null then [blackdown] else []); }; xara = (import ../applications/graphics/xara) {