lol
at 24.11-pre 185 lines 5.3 kB view raw
1# This file defines the structure of the `config` nixpkgs option. 2 3# This file is tested in `pkgs/test/config.nix`. 4# Run tests with: 5# 6# nix-build -A tests.config 7# 8 9{ config, lib, ... }: 10 11let 12 inherit (lib) 13 literalExpression 14 mapAttrsToList 15 mkOption 16 optionals 17 types 18 ; 19 20 mkMassRebuild = args: mkOption (builtins.removeAttrs args [ "feature" ] // { 21 type = args.type or (types.uniq types.bool); 22 default = args.default or false; 23 description = ((args.description or '' 24 Whether to ${args.feature} while building nixpkgs packages. 25 '') + '' 26 Changing the default may cause a mass rebuild. 27 ''); 28 }); 29 30 options = { 31 32 /* Internal stuff */ 33 34 # Hide built-in module system options from docs. 35 _module.args = mkOption { 36 internal = true; 37 }; 38 39 warnings = mkOption { 40 type = types.listOf types.str; 41 default = []; 42 internal = true; 43 }; 44 45 /* Config options */ 46 47 warnUndeclaredOptions = mkOption { 48 description = "Whether to warn when `config` contains an unrecognized attribute."; 49 type = types.bool; 50 default = false; 51 }; 52 53 doCheckByDefault = mkMassRebuild { 54 feature = "run `checkPhase` by default"; 55 }; 56 57 strictDepsByDefault = mkMassRebuild { 58 feature = "set `strictDeps` to true by default"; 59 }; 60 61 structuredAttrsByDefault = mkMassRebuild { 62 feature = "set `__structuredAttrs` to true by default"; 63 }; 64 65 enableParallelBuildingByDefault = mkMassRebuild { 66 feature = "set `enableParallelBuilding` to true by default"; 67 }; 68 69 configurePlatformsByDefault = mkMassRebuild { 70 feature = "set `configurePlatforms` to `[\"build\" \"host\"]` by default"; 71 }; 72 73 contentAddressedByDefault = mkMassRebuild { 74 feature = "set `__contentAddressed` to true by default"; 75 }; 76 77 allowAliases = mkOption { 78 type = types.bool; 79 default = true; 80 description = '' 81 Whether to expose old attribute names for compatibility. 82 83 The recommended setting is to enable this, as it 84 improves backward compatibility, easing updates. 85 86 The only reason to disable aliases is for continuous 87 integration purposes. For instance, Nixpkgs should 88 not depend on aliases in its internal code. Projects 89 that aren't Nixpkgs should be cautious of instantly 90 removing all usages of aliases, as migrating too soon 91 can break compatibility with the stable Nixpkgs releases. 92 ''; 93 }; 94 95 allowUnfree = mkOption { 96 type = types.bool; 97 default = false; 98 # getEnv part is in check-meta.nix 99 defaultText = literalExpression ''false || builtins.getEnv "NIXPKGS_ALLOW_UNFREE" == "1"''; 100 description = '' 101 Whether to allow unfree packages. 102 103 See [Installing unfree packages](https://nixos.org/manual/nixpkgs/stable/#sec-allow-unfree) in the NixOS manual. 104 ''; 105 }; 106 107 allowBroken = mkOption { 108 type = types.bool; 109 default = false; 110 # getEnv part is in check-meta.nix 111 defaultText = literalExpression ''false || builtins.getEnv "NIXPKGS_ALLOW_BROKEN" == "1"''; 112 description = '' 113 Whether to allow broken packages. 114 115 See [Installing broken packages](https://nixos.org/manual/nixpkgs/stable/#sec-allow-broken) in the NixOS manual. 116 ''; 117 }; 118 119 allowUnsupportedSystem = mkOption { 120 type = types.bool; 121 default = false; 122 # getEnv part is in check-meta.nix 123 defaultText = literalExpression ''false || builtins.getEnv "NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM" == "1"''; 124 description = '' 125 Whether to allow unsupported packages. 126 127 See [Installing packages on unsupported systems](https://nixos.org/manual/nixpkgs/stable/#sec-allow-unsupported-system) in the NixOS manual. 128 ''; 129 }; 130 131 cudaSupport = mkMassRebuild { 132 type = types.bool; 133 default = false; 134 feature = "build packages with CUDA support by default"; 135 }; 136 137 rocmSupport = mkMassRebuild { 138 type = types.bool; 139 default = false; 140 feature = "build packages with ROCm support by default"; 141 }; 142 143 showDerivationWarnings = mkOption { 144 type = types.listOf (types.enum [ "maintainerless" ]); 145 default = []; 146 description = '' 147 Which warnings to display for potentially dangerous 148 or deprecated values passed into `stdenv.mkDerivation`. 149 150 A list of warnings can be found in 151 [/pkgs/stdenv/generic/check-meta.nix](https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/check-meta.nix). 152 153 This is not a stable interface; warnings may be added, changed 154 or removed without prior notice. 155 ''; 156 }; 157 158 checkMeta = mkOption { 159 type = types.bool; 160 default = false; 161 description = '' 162 Whether to check that the `meta` attribute of derivations are correct during evaluation time. 163 ''; 164 }; 165 }; 166 167in { 168 169 freeformType = 170 let t = types.lazyAttrsOf types.raw; 171 in t // { 172 merge = loc: defs: 173 let r = t.merge loc defs; 174 in r // { _undeclared = r; }; 175 }; 176 177 inherit options; 178 179 config = { 180 warnings = optionals config.warnUndeclaredOptions ( 181 mapAttrsToList (k: v: "undeclared Nixpkgs option set: config.${k}") config._undeclared or {} 182 ); 183 }; 184 185}