at 16.09-beta 2.3 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 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 let 16 lhs = optCall lhs_ { inherit pkgs; }; 17 rhs = optCall rhs_ { inherit pkgs; }; 18 in 19 lhs // rhs // 20 optionalAttrs (lhs ? packageOverrides) { 21 packageOverrides = pkgs: 22 optCall lhs.packageOverrides pkgs // 23 optCall (attrByPath ["packageOverrides"] ({}) rhs) pkgs; 24 } // 25 optionalAttrs (lhs ? perlPackageOverrides) { 26 perlPackageOverrides = pkgs: 27 optCall lhs.perlPackageOverrides pkgs // 28 optCall (attrByPath ["perlPackageOverrides"] ({}) rhs) pkgs; 29 }; 30 31 configType = mkOptionType { 32 name = "nixpkgs config"; 33 check = traceValIfNot isConfig; 34 merge = args: fold (def: mergeConfig def.value) {}; 35 }; 36 37in 38 39{ 40 options = { 41 42 nixpkgs.config = mkOption { 43 default = {}; 44 example = literalExample 45 '' 46 { firefox.enableGeckoMediaPlayer = true; 47 packageOverrides = pkgs: { 48 firefox60Pkgs = pkgs.firefox60Pkgs.override { 49 enableOfficialBranding = true; 50 }; 51 }; 52 } 53 ''; 54 type = configType; 55 description = '' 56 The configuration of the Nix Packages collection. (For 57 details, see the Nixpkgs documentation.) It allows you to set 58 package configuration options, and to override packages 59 globally through the <varname>packageOverrides</varname> 60 option. The latter is a function that takes as an argument 61 the <emphasis>original</emphasis> Nixpkgs, and must evaluate 62 to a set of new or overridden packages. 63 ''; 64 }; 65 66 nixpkgs.system = mkOption { 67 type = types.str; 68 example = "i686-linux"; 69 description = '' 70 Specifies the Nix platform type for which NixOS should be built. 71 If unset, it defaults to the platform type of your host system. 72 Specifying this option is useful when doing distributed 73 multi-platform deployment, or when building virtual machines. 74 ''; 75 }; 76 77 }; 78 79 config = { 80 _module.args.pkgs = import ../../.. { 81 system = config.nixpkgs.system; 82 83 inherit (config.nixpkgs) config; 84 }; 85 }; 86}