at 17.09-beta 2.9 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 description = "nixpkgs config"; 34 check = traceValIfNot isConfig; 35 merge = args: fold (def: mergeConfig def.value) {}; 36 }; 37 38 overlayType = mkOptionType { 39 name = "nixpkgs-overlay"; 40 description = "nixpkgs overlay"; 41 check = builtins.isFunction; 42 merge = lib.mergeOneOption; 43 }; 44 45 _pkgs = import ../../.. config.nixpkgs; 46 47in 48 49{ 50 options.nixpkgs = { 51 config = mkOption { 52 default = {}; 53 example = literalExample 54 '' 55 { firefox.enableGeckoMediaPlayer = true; } 56 ''; 57 type = configType; 58 description = '' 59 The configuration of the Nix Packages collection. (For 60 details, see the Nixpkgs documentation.) It allows you to set 61 package configuration options. 62 ''; 63 }; 64 65 overlays = mkOption { 66 default = []; 67 example = literalExample 68 '' 69 [ (self: super: { 70 openssh = super.openssh.override { 71 hpnSupport = true; 72 withKerberos = true; 73 kerberos = self.libkrb5; 74 }; 75 }; 76 ) ] 77 ''; 78 type = types.listOf overlayType; 79 description = '' 80 List of overlays to use with the Nix Packages collection. 81 (For details, see the Nixpkgs documentation.) It allows 82 you to override packages globally. This is a function that 83 takes as an argument the <emphasis>original</emphasis> Nixpkgs. 84 The first argument should be used for finding dependencies, and 85 the second should be used for overriding recipes. 86 ''; 87 }; 88 89 system = mkOption { 90 type = types.str; 91 example = "i686-linux"; 92 description = '' 93 Specifies the Nix platform type for which NixOS should be built. 94 If unset, it defaults to the platform type of your host system. 95 Specifying this option is useful when doing distributed 96 multi-platform deployment, or when building virtual machines. 97 ''; 98 }; 99 }; 100 101 config = { 102 _module.args = { 103 pkgs = _pkgs; 104 pkgs_i686 = _pkgs.pkgsi686Linux; 105 }; 106 }; 107}