Skip to content

Commit 6669cf6

Browse files
committed
Add merge capabilities to nixpkgs.config option.
svn path=/nixos/trunk/; revision=29021
1 parent def746f commit 6669cf6

1 file changed

Lines changed: 37 additions & 1 deletion

File tree

modules/misc/nixpkgs.nix

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
11
{ config, pkgs, ... }:
22

3+
with pkgs.lib;
4+
5+
let
6+
isConfig = x:
7+
builtins.isAttrs x || builtins.isFunction x;
8+
9+
optCall = f: x:
10+
if builtins.isFunction f
11+
then f x
12+
else f;
13+
14+
mergeConfig = lhs: rhs:
15+
lhs // rhs //
16+
optionalAttrs (lhs ? packageOverrides) {
17+
packageOverrides = pkgs:
18+
optCall lhs.packageOverrides pkgs //
19+
optCall (attrByPath ["packageOverrides"] ({}) rhs) pkgs;
20+
};
21+
22+
configType = mkOptionType {
23+
name = "nixpkgs config";
24+
check = traceValIfNot isConfig;
25+
merge = fold mergeConfig {};
26+
};
27+
28+
in
29+
330
{
431
options = {
532

@@ -8,8 +35,17 @@
835
example = {
936
firefox.enableGeckoMediaPlayer = true;
1037
};
38+
type = configType;
1139
description = ''
12-
The configuration of the Nix Packages collection.
40+
The configuration of the Nix Packages collection. This expression
41+
defines default value of attributes and allow packages to be
42+
overriden globally via the `packageOverrides'.
43+
44+
the `packageOverrides' configuration option must be a set of new or
45+
overriden packages. Any occurence of `pkgs' inside this attribute
46+
set refers to the *original* (un-overriden) set of packages,
47+
allowing packageOverrides attributes to refer to the original
48+
attributes (e.g. "packageOverrides.foo = ... pkgs.foo ...").
1349
'';
1450
};
1551

0 commit comments

Comments
 (0)