···44can take. Types are also responsible of how values are merged in case of55multiple value definitions.6677-## Basic Types {#sec-option-types-basic}77+## Basic types {#sec-option-types-basic}8899Basic types are the simplest available types in the module system. Basic1010types include multiple string types that mainly differ in how definition···24242525: A top-level store path. This can be an attribute set pointing2626 to a store path, like a derivation or a flake input.2727+2828+`types.enum` *`l`*2929+3030+: One element of the list *`l`*, e.g. `types.enum [ "left" "right" ]`.3131+ Multiple definitions cannot be merged.27322833`types.anything`2934···10095 problems.10196 :::10297103103-Integer-related types:9898+### Numeric types {#sec-option-types-numeric}10499105100`types.int`106101···123118 from 0 to 2^n−1 respectively (e.g. `0`124119 to `255` for 8 bits).125120121121+`types.ints.between` *`lowest highest`*122122+123123+: An integer between *`lowest`* and *`highest`* (both inclusive).124124+126125`types.ints.positive`127126128127: A positive integer (that is > 0).···136127: A port number. This type is an alias to137128 `types.ints.u16`.138129139139-String-related types:130130+`types.float`131131+132132+: A floating point number.133133+134134+ ::: {.warning}135135+ Converting a floating point number to a string with `toString` or `toJSON`136136+ may result in [precision loss](https://github.com/NixOS/nix/issues/5733).137137+ :::138138+139139+`types.number`140140+141141+: Either a signed integer or a floating point number. No implicit conversion142142+ is done between the two types, and multiple equal definitions will only be143143+ merged if they have the same type.144144+145145+`types.numbers.between` *`lowest highest`*146146+147147+: An integer or floating point number between *`lowest`* and *`highest`* (both inclusive).148148+149149+`types.numbers.nonnegative`150150+151151+: A nonnegative integer or floating point number (that is >= 0).152152+153153+`types.numbers.positive`154154+155155+: A positive integer or floating point number (that is > 0).156156+157157+### String types {#sec-option-types-string}140158141159`types.str`142160143161: A string. Multiple definitions cannot be merged.162162+163163+`types.separatedString` *`sep`*164164+165165+: A string. Multiple definitions are concatenated with *`sep`*, e.g.166166+ `types.separatedString "|"`.144167145168`types.lines`146169···185144186145`types.envVar`187146188188-: A string. Multiple definitions are concatenated with a collon `":"`.147147+: A string. Multiple definitions are concatenated with a colon `":"`.189148190149`types.strMatching`191150···193152 definitions cannot be merged. The regular expression is processed194153 using `builtins.match`.195154196196-## Value Types {#sec-option-types-value}155155+## Submodule types {#sec-option-types-submodule}197156198198-Value types are types that take a value parameter.199199-200200-`types.enum` *`l`*201201-202202-: One element of the list *`l`*, e.g. `types.enum [ "left" "right" ]`.203203- Multiple definitions cannot be merged.204204-205205-`types.separatedString` *`sep`*206206-207207-: A string with a custom separator *`sep`*, e.g.208208- `types.separatedString "|"`.209209-210210-`types.ints.between` *`lowest highest`*211211-212212-: An integer between *`lowest`* and *`highest`* (both inclusive). Useful213213- for creating types like `types.port`.157157+Submodules are detailed in [Submodule](#section-option-types-submodule).214158215159`types.submodule` *`o`*216160···204178 value. Submodules are used in composed types to create modular205179 options. This is equivalent to206180 `types.submoduleWith { modules = toList o; shorthandOnlyDefinesConfig = true; }`.207207- Submodules are detailed in [Submodule](#section-option-types-submodule).208181209182`types.submoduleWith` { *`modules`*, *`specialArgs`* ? {}, *`shorthandOnlyDefinesConfig`* ? false }210183···264239 more convenient and discoverable than expecting the module user to265240 type-merge with the `attrsOf submodule` option.266241267267-## Composed Types {#sec-option-types-composed}242242+## Composed types {#sec-option-types-composed}268243269244Composed types are types that take a type as parameter. `listOf270245 int` and `either int str` are examples of composed types.···521496 of strings, and `defs` the list of defined values as a list. It is522497 possible to override a type merge function for custom needs.523498524524-## Custom Types {#sec-option-types-custom}499499+## Custom types {#sec-option-types-custom}525500526501Custom types can be created with the `mkOptionType` function. As type527502creation includes some more complex topics such as submodule handling,
···66 in case of multiple value definitions.77 </para>88 <section xml:id="sec-option-types-basic">99- <title>Basic Types</title>99+ <title>Basic types</title>1010 <para>1111 Basic types are the simplest available types in the module system.1212 Basic types include multiple string types that mainly differ in···4646 A top-level store path. This can be an attribute set4747 pointing to a store path, like a derivation or a flake4848 input.4949+ </para>5050+ </listitem>5151+ </varlistentry>5252+ <varlistentry>5353+ <term>5454+ <literal>types.enum</literal>5555+ <emphasis><literal>l</literal></emphasis>5656+ </term>5757+ <listitem>5858+ <para>5959+ One element of the list6060+ <emphasis><literal>l</literal></emphasis>, e.g.6161+ <literal>types.enum [ "left" "right" ]</literal>.6262+ Multiple definitions cannot be merged.4963 </para>5064 </listitem>5165 </varlistentry>···164150 </listitem>165151 </varlistentry>166152 </variablelist>167167- <para>168168- Integer-related types:169169- </para>170170- <variablelist>171171- <varlistentry>172172- <term>173173- <literal>types.int</literal>174174- </term>175175- <listitem>176176- <para>177177- A signed integer.178178- </para>179179- </listitem>180180- </varlistentry>181181- <varlistentry>182182- <term>183183- <literal>types.ints.{s8, s16, s32}</literal>184184- </term>185185- <listitem>186186- <para>187187- Signed integers with a fixed length (8, 16 or 32 bits). They188188- go from −2^n/2 to 2^n/2−1 respectively (e.g.189189- <literal>−128</literal> to <literal>127</literal> for 8190190- bits).191191- </para>192192- </listitem>193193- </varlistentry>194194- <varlistentry>195195- <term>196196- <literal>types.ints.unsigned</literal>197197- </term>198198- <listitem>199199- <para>200200- An unsigned integer (that is >= 0).201201- </para>202202- </listitem>203203- </varlistentry>204204- <varlistentry>205205- <term>206206- <literal>types.ints.{u8, u16, u32}</literal>207207- </term>208208- <listitem>209209- <para>210210- Unsigned integers with a fixed length (8, 16 or 32 bits).211211- They go from 0 to 2^n−1 respectively (e.g.212212- <literal>0</literal> to <literal>255</literal> for 8 bits).213213- </para>214214- </listitem>215215- </varlistentry>216216- <varlistentry>217217- <term>218218- <literal>types.ints.positive</literal>219219- </term>220220- <listitem>221221- <para>222222- A positive integer (that is > 0).223223- </para>224224- </listitem>225225- </varlistentry>226226- <varlistentry>227227- <term>228228- <literal>types.port</literal>229229- </term>230230- <listitem>231231- <para>232232- A port number. This type is an alias to233233- <literal>types.ints.u16</literal>.234234- </para>235235- </listitem>236236- </varlistentry>237237- </variablelist>238238- <para>239239- String-related types:240240- </para>241241- <variablelist>242242- <varlistentry>243243- <term>244244- <literal>types.str</literal>245245- </term>246246- <listitem>247247- <para>248248- A string. Multiple definitions cannot be merged.249249- </para>250250- </listitem>251251- </varlistentry>252252- <varlistentry>253253- <term>254254- <literal>types.lines</literal>255255- </term>256256- <listitem>257257- <para>258258- A string. Multiple definitions are concatenated with a new259259- line <literal>"\n"</literal>.260260- </para>261261- </listitem>262262- </varlistentry>263263- <varlistentry>264264- <term>265265- <literal>types.commas</literal>266266- </term>267267- <listitem>268268- <para>269269- A string. Multiple definitions are concatenated with a comma270270- <literal>","</literal>.271271- </para>272272- </listitem>273273- </varlistentry>274274- <varlistentry>275275- <term>276276- <literal>types.envVar</literal>277277- </term>278278- <listitem>279279- <para>280280- A string. Multiple definitions are concatenated with a281281- collon <literal>":"</literal>.282282- </para>283283- </listitem>284284- </varlistentry>285285- <varlistentry>286286- <term>287287- <literal>types.strMatching</literal>288288- </term>289289- <listitem>290290- <para>291291- A string matching a specific regular expression. Multiple292292- definitions cannot be merged. The regular expression is293293- processed using <literal>builtins.match</literal>.294294- </para>295295- </listitem>296296- </varlistentry>297297- </variablelist>153153+ <section xml:id="sec-option-types-numeric">154154+ <title>Numeric types</title>155155+ <variablelist>156156+ <varlistentry>157157+ <term>158158+ <literal>types.int</literal>159159+ </term>160160+ <listitem>161161+ <para>162162+ A signed integer.163163+ </para>164164+ </listitem>165165+ </varlistentry>166166+ <varlistentry>167167+ <term>168168+ <literal>types.ints.{s8, s16, s32}</literal>169169+ </term>170170+ <listitem>171171+ <para>172172+ Signed integers with a fixed length (8, 16 or 32 bits).173173+ They go from −2^n/2 to 2^n/2−1 respectively (e.g.174174+ <literal>−128</literal> to <literal>127</literal> for 8175175+ bits).176176+ </para>177177+ </listitem>178178+ </varlistentry>179179+ <varlistentry>180180+ <term>181181+ <literal>types.ints.unsigned</literal>182182+ </term>183183+ <listitem>184184+ <para>185185+ An unsigned integer (that is >= 0).186186+ </para>187187+ </listitem>188188+ </varlistentry>189189+ <varlistentry>190190+ <term>191191+ <literal>types.ints.{u8, u16, u32}</literal>192192+ </term>193193+ <listitem>194194+ <para>195195+ Unsigned integers with a fixed length (8, 16 or 32 bits).196196+ They go from 0 to 2^n−1 respectively (e.g.197197+ <literal>0</literal> to <literal>255</literal> for 8198198+ bits).199199+ </para>200200+ </listitem>201201+ </varlistentry>202202+ <varlistentry>203203+ <term>204204+ <literal>types.ints.between</literal>205205+ <emphasis><literal>lowest highest</literal></emphasis>206206+ </term>207207+ <listitem>208208+ <para>209209+ An integer between210210+ <emphasis><literal>lowest</literal></emphasis> and211211+ <emphasis><literal>highest</literal></emphasis> (both212212+ inclusive).213213+ </para>214214+ </listitem>215215+ </varlistentry>216216+ <varlistentry>217217+ <term>218218+ <literal>types.ints.positive</literal>219219+ </term>220220+ <listitem>221221+ <para>222222+ A positive integer (that is > 0).223223+ </para>224224+ </listitem>225225+ </varlistentry>226226+ <varlistentry>227227+ <term>228228+ <literal>types.port</literal>229229+ </term>230230+ <listitem>231231+ <para>232232+ A port number. This type is an alias to233233+ <literal>types.ints.u16</literal>.234234+ </para>235235+ </listitem>236236+ </varlistentry>237237+ <varlistentry>238238+ <term>239239+ <literal>types.float</literal>240240+ </term>241241+ <listitem>242242+ <para>243243+ A floating point number.244244+ </para>245245+ <warning>246246+ <para>247247+ Converting a floating point number to a string with248248+ <literal>toString</literal> or <literal>toJSON</literal>249249+ may result in250250+ <link xlink:href="https://github.com/NixOS/nix/issues/5733">precision251251+ loss</link>.252252+ </para>253253+ </warning>254254+ </listitem>255255+ </varlistentry>256256+ <varlistentry>257257+ <term>258258+ <literal>types.number</literal>259259+ </term>260260+ <listitem>261261+ <para>262262+ Either a signed integer or a floating point number. No263263+ implicit conversion is done between the two types, and264264+ multiple equal definitions will only be merged if they265265+ have the same type.266266+ </para>267267+ </listitem>268268+ </varlistentry>269269+ <varlistentry>270270+ <term>271271+ <literal>types.numbers.between</literal>272272+ <emphasis><literal>lowest highest</literal></emphasis>273273+ </term>274274+ <listitem>275275+ <para>276276+ An integer or floating point number between277277+ <emphasis><literal>lowest</literal></emphasis> and278278+ <emphasis><literal>highest</literal></emphasis> (both279279+ inclusive).280280+ </para>281281+ </listitem>282282+ </varlistentry>283283+ <varlistentry>284284+ <term>285285+ <literal>types.numbers.nonnegative</literal>286286+ </term>287287+ <listitem>288288+ <para>289289+ A nonnegative integer or floating point number (that is290290+ >= 0).291291+ </para>292292+ </listitem>293293+ </varlistentry>294294+ <varlistentry>295295+ <term>296296+ <literal>types.numbers.positive</literal>297297+ </term>298298+ <listitem>299299+ <para>300300+ A positive integer or floating point number (that is >301301+ 0).302302+ </para>303303+ </listitem>304304+ </varlistentry>305305+ </variablelist>306306+ </section>307307+ <section xml:id="sec-option-types-string">308308+ <title>String types</title>309309+ <variablelist>310310+ <varlistentry>311311+ <term>312312+ <literal>types.str</literal>313313+ </term>314314+ <listitem>315315+ <para>316316+ A string. Multiple definitions cannot be merged.317317+ </para>318318+ </listitem>319319+ </varlistentry>320320+ <varlistentry>321321+ <term>322322+ <literal>types.separatedString</literal>323323+ <emphasis><literal>sep</literal></emphasis>324324+ </term>325325+ <listitem>326326+ <para>327327+ A string. Multiple definitions are concatenated with328328+ <emphasis><literal>sep</literal></emphasis>, e.g.329329+ <literal>types.separatedString "|"</literal>.330330+ </para>331331+ </listitem>332332+ </varlistentry>333333+ <varlistentry>334334+ <term>335335+ <literal>types.lines</literal>336336+ </term>337337+ <listitem>338338+ <para>339339+ A string. Multiple definitions are concatenated with a new340340+ line <literal>"\n"</literal>.341341+ </para>342342+ </listitem>343343+ </varlistentry>344344+ <varlistentry>345345+ <term>346346+ <literal>types.commas</literal>347347+ </term>348348+ <listitem>349349+ <para>350350+ A string. Multiple definitions are concatenated with a351351+ comma <literal>","</literal>.352352+ </para>353353+ </listitem>354354+ </varlistentry>355355+ <varlistentry>356356+ <term>357357+ <literal>types.envVar</literal>358358+ </term>359359+ <listitem>360360+ <para>361361+ A string. Multiple definitions are concatenated with a362362+ colon <literal>":"</literal>.363363+ </para>364364+ </listitem>365365+ </varlistentry>366366+ <varlistentry>367367+ <term>368368+ <literal>types.strMatching</literal>369369+ </term>370370+ <listitem>371371+ <para>372372+ A string matching a specific regular expression. Multiple373373+ definitions cannot be merged. The regular expression is374374+ processed using <literal>builtins.match</literal>.375375+ </para>376376+ </listitem>377377+ </varlistentry>378378+ </variablelist>379379+ </section>298380 </section>299299- <section xml:id="sec-option-types-value">300300- <title>Value Types</title>381381+ <section xml:id="sec-option-types-submodule">382382+ <title>Submodule types</title>301383 <para>302302- Value types are types that take a value parameter.384384+ Submodules are detailed in385385+ <link linkend="section-option-types-submodule">Submodule</link>.303386 </para>304387 <variablelist>305305- <varlistentry>306306- <term>307307- <literal>types.enum</literal>308308- <emphasis><literal>l</literal></emphasis>309309- </term>310310- <listitem>311311- <para>312312- One element of the list313313- <emphasis><literal>l</literal></emphasis>, e.g.314314- <literal>types.enum [ "left" "right" ]</literal>.315315- Multiple definitions cannot be merged.316316- </para>317317- </listitem>318318- </varlistentry>319319- <varlistentry>320320- <term>321321- <literal>types.separatedString</literal>322322- <emphasis><literal>sep</literal></emphasis>323323- </term>324324- <listitem>325325- <para>326326- A string with a custom separator327327- <emphasis><literal>sep</literal></emphasis>, e.g.328328- <literal>types.separatedString "|"</literal>.329329- </para>330330- </listitem>331331- </varlistentry>332332- <varlistentry>333333- <term>334334- <literal>types.ints.between</literal>335335- <emphasis><literal>lowest highest</literal></emphasis>336336- </term>337337- <listitem>338338- <para>339339- An integer between340340- <emphasis><literal>lowest</literal></emphasis> and341341- <emphasis><literal>highest</literal></emphasis> (both342342- inclusive). Useful for creating types like343343- <literal>types.port</literal>.344344- </para>345345- </listitem>346346- </varlistentry>347388 <varlistentry>348389 <term>349390 <literal>types.submodule</literal>···414345 in composed types to create modular options. This is415346 equivalent to416347 <literal>types.submoduleWith { modules = toList o; shorthandOnlyDefinesConfig = true; }</literal>.417417- Submodules are detailed in418418- <link linkend="section-option-types-submodule">Submodule</link>.419348 </para>420349 </listitem>421350 </varlistentry>···534467 </variablelist>535468 </section>536469 <section xml:id="sec-option-types-composed">537537- <title>Composed Types</title>470470+ <title>Composed types</title>538471 <para>539472 Composed types are types that take a type as parameter.540473 <literal>listOf int</literal> and···917850 </variablelist>918851 </section>919852 <section xml:id="sec-option-types-custom">920920- <title>Custom Types</title>853853+ <title>Custom types</title>921854 <para>922855 Custom types can be created with the923856 <literal>mkOptionType</literal> function. As type creation
···26262727 # Provide networkmanager for easy wireless configuration.2828 networking.networkmanager.enable = true;2929- networking.wireless.enable = mkForce false;2929+ networking.wireless.enable = mkImageMediaOverride false;30303131 # KDE complains if power management is disabled (to be precise, if3232 # there is no power management backend such as upower).
+3-3
nixos/modules/profiles/installation-device.nix
···2222 config = {23232424 # Enable in installer, even if the minimal profile disables it.2525- documentation.enable = mkForce true;2525+ documentation.enable = mkImageMediaOverride true;26262727 # Show the manual.2828- documentation.nixos.enable = mkForce true;2828+ documentation.nixos.enable = mkImageMediaOverride true;29293030 # Use less privileged nixos user3131 users.users.nixos = {···4141 # Allow passwordless sudo from nixos user4242 security.sudo = {4343 enable = mkDefault true;4444- wheelNeedsPassword = mkForce false;4444+ wheelNeedsPassword = mkImageMediaOverride false;4545 };46464747 # Automatically log in at the virtual consoles.
···628628 };629629 allowedDomains = mkOption {630630 description = lib.mdDoc ''631631- To limit access to authenticated users who are members of one or more groups,632632- set allowedGroups to a comma- or space-separated list of group object IDs.633633- You can find object IDs for a specific group on the Azure portal.631631+ Limits access to users who belong to specific domains.632632+ Separate domains with space or comma.634633 '';635634 default = "";636635 type = types.str;637636 };638637 allowedGroups = mkOption {639638 description = lib.mdDoc ''640640- Limits access to users who belong to specific domains.641641- Separate domains with space or comma.642642- '';639639+ To limit access to authenticated users who are members of one or more groups,640640+ set allowedGroups to a comma- or space-separated list of group object IDs.641641+ You can find object IDs for a specific group on the Azure portal.642642+ '';643643 default = "";644644 type = types.str;645645 };
+3-2
nixos/modules/services/networking/syncthing.nix
···325325 };326326327327 type = mkOption {328328- type = types.enum [ "sendreceive" "sendonly" "receiveonly" ];328328+ type = types.enum [ "sendreceive" "sendonly" "receiveonly" "receiveencrypted" ];329329 default = "sendreceive";330330 description = lib.mdDoc ''331331 Whether to only send changes for this folder, only receive them332332- or both.332332+ or both. `receiveencrypted` can be used for untrusted devices. See333333+ <https://docs.syncthing.net/users/untrusted.html> for reference.333334 '';334335 };335336
+5-14
nixos/modules/services/x11/picom.nix
···1111 addCheck (listOf x) (y: length y == 2)1212 // { description = "pair of ${x.description}"; };13131414- floatBetween = a: b: with types;1515- let1616- # toString prints floats with hardcoded high precision1717- floatToString = f: builtins.toJSON f;1818- in1919- addCheck float (x: x <= b && x >= a)2020- // { description = "a floating point number in " +2121- "range [${floatToString a}, ${floatToString b}]"; };2222-2314 mkDefaultAttrs = mapAttrs (n: v: mkDefault v);24152516 # Basically a tinkered lib.generators.mkKeyValueDefault···8493 };85948695 fadeSteps = mkOption {8787- type = pairOf (floatBetween 0.01 1);9696+ type = pairOf (types.numbers.between 0.01 1);8897 default = [ 0.028 0.03 ];8998 example = [ 0.04 0.04 ];9099 description = lib.mdDoc ''···124133 };125134126135 shadowOpacity = mkOption {127127- type = floatBetween 0 1;136136+ type = types.numbers.between 0 1;128137 default = 0.75;129138 example = 0.8;130139 description = lib.mdDoc ''···147156 };148157149158 activeOpacity = mkOption {150150- type = floatBetween 0 1;159159+ type = types.numbers.between 0 1;151160 default = 1.0;152161 example = 0.8;153162 description = lib.mdDoc ''···156165 };157166158167 inactiveOpacity = mkOption {159159- type = floatBetween 0.1 1;168168+ type = types.numbers.between 0.1 1;160169 default = 1.0;161170 example = 0.8;162171 description = lib.mdDoc ''···165174 };166175167176 menuOpacity = mkOption {168168- type = floatBetween 0 1;177177+ type = types.numbers.between 0 1;169178 default = 1.0;170179 example = 0.8;171180 description = lib.mdDoc ''
+1-1
nixos/modules/system/boot/networkd.nix
···1411141114121412 ipv6RoutePrefixes = mkOption {14131413 default = [];14141414- example = [ { Route = "fd00::/64"; LifetimeSec = 3600; } ];14141414+ example = [ { ipv6RoutePrefixConfig = { Route = "fd00::/64"; LifetimeSec = 3600; }; } ];14151415 type = with types; listOf (submodule ipv6RoutePrefixOptions);14161416 description = ''14171417 A list of ipv6RoutePrefix sections to be added to the unit. See
···4455stdenv.mkDerivation rec {66 pname = "argyllcms";77- version = "2.3.0";77+ version = "2.3.1";8899 src = fetchzip {1010 # Kind of flacky URL, it was reaturning 406 and inconsistent binaries for a1111 # while on me. It might be good to find a mirror1212 url = "https://www.argyllcms.com/Argyll_V${version}_src.zip";1313- sha256 = "sha256-UNjCcqJgbRSox55OP3pLdKFHY0NPLHEq3nwqvxWre7U=";1313+ sha256 = "sha256-XWsubjdD1tg0o7x/aoAalemAChehWkwh4fkP2WRvhAw=";1414 };15151616 nativeBuildInputs = [ jam unzip ];