summary refs log tree commit diff
path: root/pkgs/top-level/all-packages.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2006-09-24 18:38:12 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2006-09-24 18:38:12 +0000
commit21025cb280aef34956c6ddd6a62b0f251443417e (patch)
tree5c7919361d21ef0340fbaa8ba2abb085038a488a /pkgs/top-level/all-packages.nix
parent1995e1265e97b2668ade8716de70507b330dcc82 (diff)
downloadnixpkgs-21025cb280aef34956c6ddd6a62b0f251443417e.tar
nixpkgs-21025cb280aef34956c6ddd6a62b0f251443417e.tar.gz
nixpkgs-21025cb280aef34956c6ddd6a62b0f251443417e.tar.bz2
nixpkgs-21025cb280aef34956c6ddd6a62b0f251443417e.tar.lz
nixpkgs-21025cb280aef34956c6ddd6a62b0f251443417e.tar.xz
nixpkgs-21025cb280aef34956c6ddd6a62b0f251443417e.tar.zst
nixpkgs-21025cb280aef34956c6ddd6a62b0f251443417e.zip
* 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
Diffstat (limited to 'pkgs/top-level/all-packages.nix')
-rw-r--r--pkgs/top-level/all-packages.nix33
1 files 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) {