diff --git a/third_party/nixpkgs/doc/builders/fetchers.chapter.md b/third_party/nixpkgs/doc/builders/fetchers.chapter.md index 5b28b2dcb3..28388ba685 100644 --- a/third_party/nixpkgs/doc/builders/fetchers.chapter.md +++ b/third_party/nixpkgs/doc/builders/fetchers.chapter.md @@ -40,6 +40,24 @@ Used with Git. Expects `url` to a Git repo, `rev`, and `sha256`. `rev` in this c Additionally the following optional arguments can be given: `fetchSubmodules = true` makes `fetchgit` also fetch the submodules of a repository. If `deepClone` is set to true, the entire repository is cloned as opposing to just creating a shallow clone. `deepClone = true` also implies `leaveDotGit = true` which means that the `.git` directory of the clone won't be removed after checkout. +If only parts of the repository are needed, `sparseCheckout` can be used. This will prevent git from fetching unnecessary blobs from server, see [git sparse-checkout](https://git-scm.com/docs/git-sparse-checkout) and [git clone --filter](https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---filterltfilter-specgt) for more infomation: + +```nix +{ stdenv, fetchgit }: + +stdenv.mkDerivation { + name = "hello"; + src = fetchgit { + url = "https://..."; + sparseCheckout = '' + path/to/be/included + another/path + ''; + sha256 = "0000000000000000000000000000000000000000000000000000"; + }; +} +``` + ## `fetchfossil` {#fetchfossil} Used with Fossil. Expects `url` to a Fossil archive, `rev`, and `sha256`. diff --git a/third_party/nixpkgs/lib/default.nix b/third_party/nixpkgs/lib/default.nix index 2dfe62e82a..2684225388 100644 --- a/third_party/nixpkgs/lib/default.nix +++ b/third_party/nixpkgs/lib/default.nix @@ -122,8 +122,9 @@ let mkRenamedOptionModule mkMergedOptionModule mkChangedOptionModule mkAliasOptionModule mkDerivedConfig doRename; inherit (self.options) isOption mkEnableOption mkSinkUndeclaredOptions - mergeDefaultOption mergeOneOption mergeEqualOption getValues - getFiles optionAttrSetToDocList optionAttrSetToDocList' + mergeDefaultOption mergeOneOption mergeEqualOption mergeUniqueOption + getValues getFiles + optionAttrSetToDocList optionAttrSetToDocList' scrubOptionValue literalExpression literalExample literalDocBook showOption showFiles unknownModule mkOption; inherit (self.types) isType setType defaultTypeMerge defaultFunctor diff --git a/third_party/nixpkgs/lib/options.nix b/third_party/nixpkgs/lib/options.nix index 794ca5e339..627aac24d2 100644 --- a/third_party/nixpkgs/lib/options.nix +++ b/third_party/nixpkgs/lib/options.nix @@ -172,11 +172,13 @@ rec { else if all isInt list && all (x: x == head list) list then head list else throw "Cannot merge definitions of `${showOption loc}'. Definition values:${showDefs defs}"; - mergeOneOption = loc: defs: - if defs == [] then abort "This case should never happen." - else if length defs != 1 then - throw "The unique option `${showOption loc}' is defined multiple times. Definition values:${showDefs defs}" - else (head defs).value; + mergeOneOption = mergeUniqueOption { message = ""; }; + + mergeUniqueOption = { message }: loc: defs: + if length defs == 1 + then (head defs).value + else assert length defs > 1; + throw "The option `${showOption loc}' is defined multiple times.\n${message}\nDefinition values:${showDefs defs}"; /* "Merge" option definitions by checking that they all have the same value. */ mergeEqualOption = loc: defs: diff --git a/third_party/nixpkgs/lib/types.nix b/third_party/nixpkgs/lib/types.nix index cc3ac5fdf6..f2f9b2bca9 100644 --- a/third_party/nixpkgs/lib/types.nix +++ b/third_party/nixpkgs/lib/types.nix @@ -32,7 +32,6 @@ let last length tail - unique ; inherit (lib.attrsets) attrNames @@ -48,6 +47,7 @@ let mergeDefaultOption mergeEqualOption mergeOneOption + mergeUniqueOption showFiles showOption ; @@ -470,6 +470,18 @@ rec { nestedTypes.elemType = elemType; }; + unique = { message }: type: mkOptionType rec { + name = "unique"; + inherit (type) description check; + merge = mergeUniqueOption { inherit message; }; + emptyValue = type.emptyValue; + getSubOptions = type.getSubOptions; + getSubModules = type.getSubModules; + substSubModules = m: uniq (type.substSubModules m); + functor = (defaultFunctor name) // { wrapped = type; }; + nestedTypes.elemType = type; + }; + # Null or value of ... nullOr = elemType: mkOptionType rec { name = "nullOr"; @@ -599,6 +611,7 @@ rec { # A value from a set of allowed ones. enum = values: let + inherit (lib.lists) unique; show = v: if builtins.isString v then ''"${v}"'' else if builtins.isInt v then builtins.toString v diff --git a/third_party/nixpkgs/maintainers/maintainer-list.nix b/third_party/nixpkgs/maintainers/maintainer-list.nix index 9d1d35f01c..e991280a0f 100644 --- a/third_party/nixpkgs/maintainers/maintainer-list.nix +++ b/third_party/nixpkgs/maintainers/maintainer-list.nix @@ -515,6 +515,8 @@ }; algorith = { email = "dries_van_daele@telenet.be"; + github = "DriesVanDaele"; + githubId = 1141488; name = "Dries Van Daele"; }; alibabzo = { @@ -3543,7 +3545,7 @@ name = "Leo Maroni"; }; emmanuelrosa = { - email = "emmanuel_rosa@aol.com"; + email = "emmanuelrosa@protonmail.com"; matrix = "@emmanuelrosa:matrix.org"; github = "emmanuelrosa"; githubId = 13485450; @@ -5982,6 +5984,13 @@ githubId = 107689; name = "Josh Holland"; }; + jsierles = { + email = "joshua@hey.com"; + matrix = "@jsierles:matrix.org"; + name = "Joshua Sierles"; + github = "jsierles"; + githubId = 82; + }; jtcoolen = { email = "jtcoolen@pm.me"; name = "Julien Coolen"; @@ -7024,7 +7033,7 @@ email = "nullarequest@vivlaid.net"; github = "Lunarequest"; githubId = 30698906; - name = "Advaith Madhukar"; # this is my legal name, I prefer Luna; please keep that in mind! + name = "Luna D Dragon"; }; lionello = { email = "lio@lunesu.com"; @@ -8586,6 +8595,12 @@ githubId = 7845120; name = "Alex Martens"; }; + nialov = { + email = "nikolasovaskainen@gmail.com"; + github = "nialov"; + githubId = 47318483; + name = "Nikolas Ovaskainen"; + }; nikitavoloboev = { email = "nikita.voloboev@gmail.com"; github = "nikitavoloboev"; @@ -12041,7 +12056,7 @@ name = "Tiago Castro"; }; tilcreator = { - name = "Tilman Jackel"; + name = "TilCreator"; email = "contact.nixos@tc-j.de"; matrix = "@tilcreator:matrix.org"; github = "TilCreator"; diff --git a/third_party/nixpkgs/nixos/doc/manual/development/option-types.section.md b/third_party/nixpkgs/nixos/doc/manual/development/option-types.section.md index ed55720665..56ffa8e9d7 100644 --- a/third_party/nixpkgs/nixos/doc/manual/development/option-types.section.md +++ b/third_party/nixpkgs/nixos/doc/manual/development/option-types.section.md @@ -250,6 +250,12 @@ Composed types are types that take a type as parameter. `listOf : Ensures that type *`t`* cannot be merged. It is used to ensure option definitions are declared only once. +`types.unique` `{ message = m }` *`t`* + +: Ensures that type *`t`* cannot be merged. Prints the message *`m`*, after + the line `The option