summary refs log tree commit diff
path: root/modules/misc/nixpkgs.nix
diff options
context:
space:
mode:
authorNicolas Pierron <nicolas.b.pierron@gmail.com>2011-09-05 09:19:59 +0000
committerNicolas Pierron <nicolas.b.pierron@gmail.com>2011-09-05 09:19:59 +0000
commit6669cf61f44d750677462d46ee1ac987b7cae0d6 (patch)
tree3515255b10ca1e664cc4b5216907a9cb4809d952 /modules/misc/nixpkgs.nix
parentdef746fcdda7b243ed60e490030f6ee81ab5cfa0 (diff)
downloadnixpkgs-6669cf61f44d750677462d46ee1ac987b7cae0d6.tar
nixpkgs-6669cf61f44d750677462d46ee1ac987b7cae0d6.tar.gz
nixpkgs-6669cf61f44d750677462d46ee1ac987b7cae0d6.tar.bz2
nixpkgs-6669cf61f44d750677462d46ee1ac987b7cae0d6.tar.lz
nixpkgs-6669cf61f44d750677462d46ee1ac987b7cae0d6.tar.xz
nixpkgs-6669cf61f44d750677462d46ee1ac987b7cae0d6.tar.zst
nixpkgs-6669cf61f44d750677462d46ee1ac987b7cae0d6.zip
Add merge capabilities to nixpkgs.config option.
svn path=/nixos/trunk/; revision=29021
Diffstat (limited to 'modules/misc/nixpkgs.nix')
-rw-r--r--modules/misc/nixpkgs.nix38
1 files changed, 37 insertions, 1 deletions
diff --git a/modules/misc/nixpkgs.nix b/modules/misc/nixpkgs.nix
index 154c619bd36..88f5de1be5c 100644
--- a/modules/misc/nixpkgs.nix
+++ b/modules/misc/nixpkgs.nix
@@ -1,5 +1,32 @@
 { config, pkgs, ... }:
 
+with pkgs.lib;
+
+let
+  isConfig = x:
+    builtins.isAttrs x || builtins.isFunction x;
+
+  optCall = f: x:
+    if builtins.isFunction f
+    then f x
+    else f;
+
+  mergeConfig = lhs: rhs:
+    lhs // rhs //
+    optionalAttrs (lhs ? packageOverrides) {
+      packageOverrides = pkgs:
+        optCall lhs.packageOverrides pkgs //
+        optCall (attrByPath ["packageOverrides"] ({}) rhs) pkgs;
+    };
+
+  configType = mkOptionType {
+    name = "nixpkgs config";
+    check = traceValIfNot isConfig;
+    merge = fold mergeConfig {};
+  };
+
+in
+
 {
   options = {
 
@@ -8,8 +35,17 @@
       example = {
         firefox.enableGeckoMediaPlayer = true;
       };
+      type = configType;
       description = ''
-        The configuration of the Nix Packages collection.
+        The configuration of the Nix Packages collection.  This expression
+        defines default value of attributes and allow packages to be
+        overriden globally via the `packageOverrides'.
+
+        the `packageOverrides' configuration option must be a set of new or
+        overriden packages.  Any occurence of `pkgs' inside this attribute
+        set refers to the *original* (un-overriden) set of packages,
+        allowing packageOverrides attributes to refer to the original
+        attributes (e.g. "packageOverrides.foo = ... pkgs.foo ...").
       '';
     };