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