aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/lib
diff options
context:
space:
mode:
authorKatharina Fey <kookie@spacekookie.de>2020-04-19 14:57:25 +0200
committerKatharina Fey <kookie@spacekookie.de>2020-04-19 14:57:25 +0200
commit0ca211d4ec600fa7b3cc701e4997cd1e8d38ebdc (patch)
tree4f9b09ca5d55e44710f020bcf6621daa4fd6b73a /nixpkgs/lib
parent1c2ef52230ed2c8b2529c47ce6a857bdde46c7c7 (diff)
parentb61999e4ad60c351b4da63ae3ff43aae3c0bbdfb (diff)
Merge commit 'b61999e4ad60c351b4da63ae3ff43aae3c0bbdfb'
Diffstat (limited to 'nixpkgs/lib')
-rw-r--r--nixpkgs/lib/attrsets.nix4
-rw-r--r--nixpkgs/lib/default.nix2
-rw-r--r--nixpkgs/lib/deprecated.nix1
-rw-r--r--nixpkgs/lib/generators.nix53
-rw-r--r--nixpkgs/lib/licenses.nix58
-rw-r--r--nixpkgs/lib/options.nix9
-rw-r--r--nixpkgs/lib/sources.nix7
-rw-r--r--nixpkgs/lib/strings.nix47
-rw-r--r--nixpkgs/lib/systems/default.nix1
-rw-r--r--nixpkgs/lib/systems/doubles.nix11
-rw-r--r--nixpkgs/lib/systems/inspect.nix1
-rw-r--r--nixpkgs/lib/systems/parse.nix3
-rw-r--r--nixpkgs/lib/tests/maintainers.nix75
-rw-r--r--nixpkgs/lib/tests/misc.nix42
-rwxr-xr-xnixpkgs/lib/tests/modules.sh5
-rw-r--r--nixpkgs/lib/tests/release.nix8
-rw-r--r--nixpkgs/lib/tests/systems.nix7
17 files changed, 293 insertions, 41 deletions
diff --git a/nixpkgs/lib/attrsets.nix b/nixpkgs/lib/attrsets.nix
index 72430522f7d..7d84c25de77 100644
--- a/nixpkgs/lib/attrsets.nix
+++ b/nixpkgs/lib/attrsets.nix
@@ -4,7 +4,7 @@
let
inherit (builtins) head tail length;
inherit (lib.trivial) and;
- inherit (lib.strings) concatStringsSep;
+ inherit (lib.strings) concatStringsSep sanitizeDerivationName;
inherit (lib.lists) fold concatMap concatLists;
in
@@ -310,7 +310,7 @@ rec {
path' = builtins.storePath path;
res =
{ type = "derivation";
- name = builtins.unsafeDiscardStringContext (builtins.substring 33 (-1) (baseNameOf path'));
+ name = sanitizeDerivationName (builtins.substring 33 (-1) (baseNameOf path'));
outPath = path';
outputs = [ "out" ];
out = res;
diff --git a/nixpkgs/lib/default.nix b/nixpkgs/lib/default.nix
index a909cefd60f..d00c4abec0a 100644
--- a/nixpkgs/lib/default.nix
+++ b/nixpkgs/lib/default.nix
@@ -141,7 +141,7 @@ let
mergeAttrsWithFunc mergeAttrsConcatenateValues
mergeAttrsNoOverride mergeAttrByFunc mergeAttrsByFuncDefaults
mergeAttrsByFuncDefaultsClean mergeAttrBy
- fakeSha256 fakeSha512
+ fakeSri fakeSha256 fakeSha512
nixType imap;
inherit (versions)
splitVersion;
diff --git a/nixpkgs/lib/deprecated.nix b/nixpkgs/lib/deprecated.nix
index 155d6f0c361..8c4fe9c390c 100644
--- a/nixpkgs/lib/deprecated.nix
+++ b/nixpkgs/lib/deprecated.nix
@@ -272,6 +272,7 @@ rec {
imap = imap1;
# Fake hashes. Can be used as hash placeholders, when computing hash ahead isn't trivial
+ fakeSri = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
fakeSha256 = "0000000000000000000000000000000000000000000000000000000000000000";
fakeSha512 = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
}
diff --git a/nixpkgs/lib/generators.nix b/nixpkgs/lib/generators.nix
index 240a19789b5..efe6ea6031d 100644
--- a/nixpkgs/lib/generators.nix
+++ b/nixpkgs/lib/generators.nix
@@ -126,6 +126,59 @@ rec {
# map input to ini sections
mapAttrsToStringsSep "\n" mkSection attrsOfAttrs;
+ /* Generate a git-config file from an attrset.
+ *
+ * It has two major differences from the regular INI format:
+ *
+ * 1. values are indented with tabs
+ * 2. sections can have sub-sections
+ *
+ * generators.toGitINI {
+ * url."ssh://git@github.com/".insteadOf = "https://github.com";
+ * user.name = "edolstra";
+ * }
+ *
+ *> [url "ssh://git@github.com/"]
+ *> insteadOf = https://github.com/
+ *>
+ *> [user]
+ *> name = edolstra
+ */
+ toGitINI = attrs:
+ with builtins;
+ let
+ mkSectionName = name:
+ let
+ containsQuote = libStr.hasInfix ''"'' name;
+ sections = libStr.splitString "." name;
+ section = head sections;
+ subsections = tail sections;
+ subsection = concatStringsSep "." subsections;
+ in if containsQuote || subsections == [ ] then
+ name
+ else
+ ''${section} "${subsection}"'';
+
+ # generation for multiple ini values
+ mkKeyValue = k: v:
+ let mkKeyValue = mkKeyValueDefault { } " = " k;
+ in concatStringsSep "\n" (map (kv: "\t" + mkKeyValue kv) (lib.toList v));
+
+ # converts { a.b.c = 5; } to { "a.b".c = 5; } for toINI
+ gitFlattenAttrs = let
+ recurse = path: value:
+ if isAttrs value then
+ lib.mapAttrsToList (name: value: recurse ([ name ] ++ path) value) value
+ else if length path > 1 then {
+ ${concatStringsSep "." (lib.reverseList (tail path))}.${head path} = value;
+ } else {
+ ${head path} = value;
+ };
+ in attrs: lib.foldl lib.recursiveUpdate { } (lib.flatten (recurse [ ] attrs));
+
+ toINI_ = toINI { inherit mkKeyValue mkSectionName; };
+ in
+ toINI_ (gitFlattenAttrs attrs);
/* Generates JSON from an arbitrary (non-function) value.
* For more information see the documentation of the builtin.
diff --git a/nixpkgs/lib/licenses.nix b/nixpkgs/lib/licenses.nix
index e2f94e565ce..81976a769c0 100644
--- a/nixpkgs/lib/licenses.nix
+++ b/nixpkgs/lib/licenses.nix
@@ -40,13 +40,13 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
amazonsl = {
fullName = "Amazon Software License";
- url = http://aws.amazon.com/asl/;
+ url = "http://aws.amazon.com/asl/";
free = false;
};
amd = {
fullName = "AMD License Agreement";
- url = http://developer.amd.com/amd-license-agreement/;
+ url = "http://developer.amd.com/amd-license-agreement/";
free = false;
};
@@ -57,7 +57,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
arphicpl = {
fullName = "Arphic Public License";
- url = https://www.freedesktop.org/wiki/Arphic_Public_License/;
+ url = "https://www.freedesktop.org/wiki/Arphic_Public_License/";
};
artistic1 = spdx {
@@ -107,7 +107,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
bsl11 = {
fullName = "Business Source License 1.1";
- url = https://mariadb.com/bsl11;
+ url = "https://mariadb.com/bsl11";
free = false;
};
@@ -230,7 +230,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
eapl = {
fullName = "EPSON AVASYS PUBLIC LICENSE";
- url = http://avasys.jp/hp/menu000000700/hpg000000603.htm;
+ url = "http://avasys.jp/hp/menu000000700/hpg000000603.htm";
free = false;
};
@@ -246,7 +246,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
elastic = {
fullName = "ELASTIC LICENSE";
- url = https://github.com/elastic/elasticsearch/blob/master/licenses/ELASTIC-LICENSE.txt;
+ url = "https://github.com/elastic/elasticsearch/blob/master/licenses/ELASTIC-LICENSE.txt";
free = false;
};
@@ -262,7 +262,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
epson = {
fullName = "Seiko Epson Corporation Software License Agreement for Linux";
- url = https://download.ebz.epson.net/dsc/du/02/eula/global/LINUX_EN.html;
+ url = "https://download.ebz.epson.net/dsc/du/02/eula/global/LINUX_EN.html";
free = false;
};
@@ -293,7 +293,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
ffsl = {
fullName = "Floodgap Free Software License";
- url = http://www.floodgap.com/software/ffsl/license.html;
+ url = "http://www.floodgap.com/software/ffsl/license.html";
free = false;
};
@@ -303,12 +303,12 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
g4sl = {
fullName = "Geant4 Software License";
- url = https://geant4.web.cern.ch/geant4/license/LICENSE.html;
+ url = "https://geant4.web.cern.ch/geant4/license/LICENSE.html";
};
geogebra = {
fullName = "GeoGebra Non-Commercial License Agreement";
- url = https://www.geogebra.org/license;
+ url = "https://www.geogebra.org/license";
free = false;
};
@@ -334,12 +334,12 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
gpl2ClasspathPlus = {
fullName = "GNU General Public License v2.0 or later (with Classpath exception)";
- url = https://fedoraproject.org/wiki/Licensing/GPL_Classpath_Exception;
+ url = "https://fedoraproject.org/wiki/Licensing/GPL_Classpath_Exception";
};
gpl2Oss = {
fullName = "GNU General Public License version 2 only (with OSI approved licenses linking exception)";
- url = https://www.mysql.com/about/legal/licensing/foss-exception;
+ url = "https://www.mysql.com/about/legal/licensing/foss-exception";
};
gpl2Plus = spdx {
@@ -359,7 +359,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
gpl3ClasspathPlus = {
fullName = "GNU General Public License v3.0 or later (with Classpath exception)";
- url = https://fedoraproject.org/wiki/Licensing/GPL_Classpath_Exception;
+ url = "https://fedoraproject.org/wiki/Licensing/GPL_Classpath_Exception";
};
hpnd = spdx {
@@ -370,7 +370,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
# Intel's license, seems free
iasl = {
fullName = "iASL";
- url = http://www.calculate-linux.org/packages/licenses/iASL;
+ url = "http://www.calculate-linux.org/packages/licenses/iASL";
};
ijg = spdx {
@@ -413,7 +413,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
# Proprietary binaries; free to redistribute without modification.
issl = {
fullName = "Intel Simplified Software License";
- url = https://software.intel.com/en-us/license/intel-simplified-software-license;
+ url = "https://software.intel.com/en-us/license/intel-simplified-software-license";
free = false;
};
@@ -469,7 +469,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
llgpl21 = {
fullName = "Lisp LGPL; GNU Lesser General Public License version 2.1 with Franz Inc. preamble for clarification of LGPL terms in context of Lisp";
- url = http://opensource.franz.com/preamble.html;
+ url = "http://opensource.franz.com/preamble.html";
};
lppl12 = spdx {
@@ -489,7 +489,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
miros = {
fullName = "MirOS License";
- url = https://opensource.org/licenses/MirOS;
+ url = "https://opensource.org/licenses/MirOS";
};
# spdx.org does not (yet) differentiate between the X11 and Expat versions
@@ -589,7 +589,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
postman = {
fullName = "Postman EULA";
- url = https://www.getpostman.com/licenses/postman_base_app;
+ url = "https://www.getpostman.com/licenses/postman_base_app";
free = false;
};
@@ -605,7 +605,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
purdueBsd = {
fullName = " Purdue BSD-Style License"; # also know as lsof license
- url = https://enterprise.dejacode.com/licenses/public/purdue-bsd;
+ url = "https://enterprise.dejacode.com/licenses/public/purdue-bsd";
};
qhull = spdx {
@@ -620,7 +620,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
qwt = {
fullName = "Qwt License, Version 1.0";
- url = http://qwt.sourceforge.net/qwtlicense.html;
+ url = "http://qwt.sourceforge.net/qwtlicense.html";
};
ruby = spdx {
@@ -646,7 +646,14 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
smail = {
shortName = "smail";
fullName = "SMAIL General Public License";
- url = http://metadata.ftp-master.debian.org/changelogs/main/d/debianutils/debianutils_4.8.1_copyright;
+ url = "http://metadata.ftp-master.debian.org/changelogs/main/d/debianutils/debianutils_4.8.1_copyright";
+ };
+
+ sspl = {
+ shortName = "SSPL";
+ fullName = "Server Side Public License";
+ url = "https://www.mongodb.com/licensing/server-side-public-license";
+ free = false;
};
tcltk = spdx {
@@ -656,7 +663,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
ufl = {
fullName = "Ubuntu Font License 1.0";
- url = http://font.ubuntu.com/ufl/ubuntu-font-licence-1.0.txt;
+ url = "http://font.ubuntu.com/ufl/ubuntu-font-licence-1.0.txt";
};
unfree = {
@@ -675,6 +682,11 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
# channel and NixOS images.
};
+ unicode-dfs-2016 = spdx {
+ spdxId = "Unicode-DFS-2016";
+ fullName = "Unicode License Agreement - Data Files and Software (2016)";
+ };
+
unlicense = spdx {
spdxId = "Unlicense";
fullName = "The Unlicense";
@@ -713,7 +725,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) {
wadalab = {
fullName = "Wadalab Font License";
- url = https://fedoraproject.org/wiki/Licensing:Wadalab?rd=Licensing/Wadalab;
+ url = "https://fedoraproject.org/wiki/Licensing:Wadalab?rd=Licensing/Wadalab";
};
wtfpl = spdx {
diff --git a/nixpkgs/lib/options.nix b/nixpkgs/lib/options.nix
index 71481c9250a..38f4f1329f2 100644
--- a/nixpkgs/lib/options.nix
+++ b/nixpkgs/lib/options.nix
@@ -191,7 +191,14 @@ rec {
Example:
(showOption ["foo" "bar" "baz"]) == "foo.bar.baz"
- (showOption ["foo" "bar.baz" "tux"]) == "foo.\"bar.baz\".tux"
+ (showOption ["foo" "bar.baz" "tux"]) == "foo.bar.baz.tux"
+
+ Placeholders will not be quoted as they are not actual values:
+ (showOption ["foo" "*" "bar"]) == "foo.*.bar"
+ (showOption ["foo" "<name>" "bar"]) == "foo.<name>.bar"
+
+ Unlike attributes, options can also start with numbers:
+ (showOption ["windowManager" "2bwm" "enable"]) == "windowManager.2bwm.enable"
*/
showOption = parts: let
escapeOptionPart = part:
diff --git a/nixpkgs/lib/sources.nix b/nixpkgs/lib/sources.nix
index 05519c3e392..ed9bce48530 100644
--- a/nixpkgs/lib/sources.nix
+++ b/nixpkgs/lib/sources.nix
@@ -63,17 +63,14 @@ rec {
# https://nixos.org/nix/manual/#builtin-filterSource
#
# name: Optional name to use as part of the store path.
- # This defaults `src.name` or otherwise `baseNameOf src`.
- # We recommend setting `name` whenever `src` is syntactically `./.`.
- # Otherwise, you depend on `./.`'s name in the parent directory,
- # which can cause inconsistent names, defeating caching.
+ # This defaults to `src.name` or otherwise `"source"`.
#
cleanSourceWith = { filter ? _path: _type: true, src, name ? null }:
let
isFiltered = src ? _isLibCleanSourceWith;
origSrc = if isFiltered then src.origSrc else src;
filter' = if isFiltered then name: type: filter name type && src.filter name type else filter;
- name' = if name != null then name else if isFiltered then src.name else baseNameOf src;
+ name' = if name != null then name else if isFiltered then src.name else "source";
in {
inherit origSrc;
filter = filter';
diff --git a/nixpkgs/lib/strings.nix b/nixpkgs/lib/strings.nix
index 4f9509ffe7c..74e3eaa0722 100644
--- a/nixpkgs/lib/strings.nix
+++ b/nixpkgs/lib/strings.nix
@@ -315,6 +315,21 @@ rec {
*/
escapeNixString = s: escape ["$"] (builtins.toJSON s);
+ /* Quotes a string if it can't be used as an identifier directly.
+
+ Type: string -> string
+
+ Example:
+ escapeNixIdentifier "hello"
+ => "hello"
+ escapeNixIdentifier "0abc"
+ => "\"0abc\""
+ */
+ escapeNixIdentifier = s:
+ # Regex from https://github.com/NixOS/nix/blob/d048577909e383439c2549e849c5c2f2016c997e/src/libexpr/lexer.l#L91
+ if builtins.match "[a-zA-Z_][a-zA-Z0-9_'-]*" s != null
+ then s else escapeNixString s;
+
# Obsolete - use replaceStrings instead.
replaceChars = builtins.replaceStrings or (
del: new: s:
@@ -678,4 +693,36 @@ rec {
=> "1.0"
*/
fileContents = file: removeSuffix "\n" (builtins.readFile file);
+
+
+ /* Creates a valid derivation name from a potentially invalid one.
+
+ Type: sanitizeDerivationName :: String -> String
+
+ Example:
+ sanitizeDerivationName "../hello.bar # foo"
+ => "-hello.bar-foo"
+ sanitizeDerivationName ""
+ => "unknown"
+ sanitizeDerivationName pkgs.hello
+ => "-nix-store-2g75chlbpxlrqn15zlby2dfh8hr9qwbk-hello-2.10"
+ */
+ sanitizeDerivationName = string: lib.pipe string [
+ # Get rid of string context. This is safe under the assumption that the
+ # resulting string is only used as a derivation name
+ builtins.unsafeDiscardStringContext
+ # Strip all leading "."
+ (x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0)
+ # Split out all invalid characters
+ # https://github.com/NixOS/nix/blob/2.3.2/src/libstore/store-api.cc#L85-L112
+ # https://github.com/NixOS/nix/blob/2242be83c61788b9c0736a92bb0b5c7bbfc40803/nix-rust/src/store/path.rs#L100-L125
+ (builtins.split "[^[:alnum:]+._?=-]+")
+ # Replace invalid character ranges with a "-"
+ (concatMapStrings (s: if lib.isList s then "-" else s))
+ # Limit to 211 characters (minus 4 chars for ".drv")
+ (x: substring (lib.max (stringLength x - 207) 0) (-1) x)
+ # If the result is empty, replace it with "unknown"
+ (x: if stringLength x == 0 then "unknown" else x)
+ ];
+
}
diff --git a/nixpkgs/lib/systems/default.nix b/nixpkgs/lib/systems/default.nix
index 4ca932d1792..210674cc639 100644
--- a/nixpkgs/lib/systems/default.nix
+++ b/nixpkgs/lib/systems/default.nix
@@ -65,6 +65,7 @@ rec {
freebsd = "FreeBSD";
openbsd = "OpenBSD";
wasi = "Wasi";
+ genode = "Genode";
}.${final.parsed.kernel.name} or null;
# uname -p
diff --git a/nixpkgs/lib/systems/doubles.nix b/nixpkgs/lib/systems/doubles.nix
index 96e602d0e16..a839b3d3d57 100644
--- a/nixpkgs/lib/systems/doubles.nix
+++ b/nixpkgs/lib/systems/doubles.nix
@@ -26,9 +26,17 @@ let
"riscv32-linux" "riscv64-linux"
- "aarch64-none" "avr-none" "arm-none" "i686-none" "x86_64-none" "powerpc-none" "msp430-none" "riscv64-none" "riscv32-none" "vc4-none"
+ "arm-none" "armv6l-none" "aarch64-none"
+ "avr-none"
+ "i686-none" "x86_64-none"
+ "powerpc-none"
+ "msp430-none"
+ "riscv64-none" "riscv32-none"
+ "vc4-none"
"js-ghcjs"
+
+ "aarch64-genode" "x86_64-genode"
];
allParsed = map parse.mkSystemFromString all;
@@ -62,6 +70,7 @@ in {
unix = filterDoubles predicates.isUnix;
wasi = filterDoubles predicates.isWasi;
windows = filterDoubles predicates.isWindows;
+ genode = filterDoubles predicates.isGenode;
embedded = filterDoubles predicates.isNone;
diff --git a/nixpkgs/lib/systems/inspect.nix b/nixpkgs/lib/systems/inspect.nix
index 01dcf0787df..90a1fb6d80c 100644
--- a/nixpkgs/lib/systems/inspect.nix
+++ b/nixpkgs/lib/systems/inspect.nix
@@ -47,6 +47,7 @@ rec {
isMinGW = { kernel = kernels.windows; abi = abis.gnu; };
isWasi = { kernel = kernels.wasi; };
isGhcjs = { kernel = kernels.ghcjs; };
+ isGenode = { kernel = kernels.genode; };
isNone = { kernel = kernels.none; };
isAndroid = [ { abi = abis.android; } { abi = abis.androideabi; } ];
diff --git a/nixpkgs/lib/systems/parse.nix b/nixpkgs/lib/systems/parse.nix
index 6a02dbb5152..648e7c27024 100644
--- a/nixpkgs/lib/systems/parse.nix
+++ b/nixpkgs/lib/systems/parse.nix
@@ -279,6 +279,7 @@ rec {
wasi = { execFormat = wasm; families = { }; };
windows = { execFormat = pe; families = { }; };
ghcjs = { execFormat = unknown; families = { }; };
+ genode = { execFormat = elf; families = { }; };
} // { # aliases
# 'darwin' is the kernel for all of them. We choose macOS by default.
darwin = kernels.macos;
@@ -395,6 +396,8 @@ rec {
then { cpu = elemAt l 0; vendor = "unknown"; kernel = elemAt l 1; abi = elemAt l 2; }
else if (elemAt l 2 == "ghcjs")
then { cpu = elemAt l 0; vendor = "unknown"; kernel = elemAt l 2; }
+ else if hasPrefix "genode" (elemAt l 2)
+ then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; }
else throw "Target specification with 3 components is ambiguous";
"4" = { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; abi = elemAt l 3; };
}.${toString (length l)}
diff --git a/nixpkgs/lib/tests/maintainers.nix b/nixpkgs/lib/tests/maintainers.nix
new file mode 100644
index 00000000000..60d296eecae
--- /dev/null
+++ b/nixpkgs/lib/tests/maintainers.nix
@@ -0,0 +1,75 @@
+# to run these tests:
+# nix-build nixpkgs/lib/tests/maintainers.nix
+# If nothing is output, all tests passed
+{ pkgs ? import ../.. {} }:
+
+let
+ inherit (pkgs) lib;
+ inherit (lib) types;
+
+ maintainerModule = { config, ... }: {
+ options = {
+ name = lib.mkOption {
+ type = types.str;
+ };
+ email = lib.mkOption {
+ type = types.str;
+ };
+ github = lib.mkOption {
+ type = types.nullOr types.str;
+ default = null;
+ };
+ githubId = lib.mkOption {
+ type = types.nullOr types.ints.unsigned;
+ default = null;
+ };
+ keys = lib.mkOption {
+ type = types.listOf (types.submodule {
+ options.longkeyid = lib.mkOption { type = types.str; };
+ options.fingerprint = lib.mkOption { type = types.str; };
+ });
+ default = [];
+ };
+ };
+ };
+
+ checkMaintainer = handle: uncheckedAttrs:
+ let
+ prefix = [ "lib" "maintainers" handle ];
+ checkedAttrs = (lib.modules.evalModules {
+ inherit prefix;
+ modules = [
+ maintainerModule
+ {
+ _file = toString ../../maintainers/maintainer-list.nix;
+ config = uncheckedAttrs;
+ }
+ ];
+ }).config;
+
+ checkGithubId = lib.optional (checkedAttrs.github != null && checkedAttrs.githubId == null) ''
+ echo ${lib.escapeShellArg (lib.showOption prefix)}': If `github` is specified, `githubId` must be too.'
+ # Calling this too often would hit non-authenticated API limits, but this
+ # shouldn't happen since such errors will get fixed rather quickly
+ info=$(curl -sS https://api.github.com/users/${checkedAttrs.github})
+ id=$(jq -r '.id' <<< "$info")
+ echo "The GitHub ID for GitHub user ${checkedAttrs.github} is $id:"
+ echo -e " githubId = $id;\n"
+ '';
+ in lib.deepSeq checkedAttrs checkGithubId;
+
+ missingGithubIds = lib.concatLists (lib.mapAttrsToList checkMaintainer lib.maintainers);
+
+ success = pkgs.runCommandNoCC "checked-maintainers-success" {} ">$out";
+
+ failure = pkgs.runCommandNoCC "checked-maintainers-failure" {
+ nativeBuildInputs = [ pkgs.curl pkgs.jq ];
+ outputHash = "sha256:${lib.fakeSha256}";
+ outputHAlgo = "sha256";
+ outputHashMode = "flat";
+ SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
+ } ''
+ ${lib.concatStringsSep "\n" missingGithubIds}
+ exit 1
+ '';
+in if missingGithubIds == [] then success else failure
diff --git a/nixpkgs/lib/tests/misc.nix b/nixpkgs/lib/tests/misc.nix
index 739c5d5fe15..36ddd186d7b 100644
--- a/nixpkgs/lib/tests/misc.nix
+++ b/nixpkgs/lib/tests/misc.nix
@@ -3,6 +3,23 @@
# if the resulting list is empty, all tests passed
with import ../default.nix;
+let
+
+ testSanitizeDerivationName = { name, expected }:
+ let
+ drv = derivation {
+ name = strings.sanitizeDerivationName name;
+ builder = "x";
+ system = "x";
+ };
+ in {
+ # Evaluate the derivation so an invalid name would be caught
+ expr = builtins.seq drv.drvPath drv.name;
+ inherit expected;
+ };
+
+in
+
runTests {
@@ -490,4 +507,29 @@ runTests {
expected = "'-X' 'PUT' '--data' '{\"id\":0}' '--retry' '3' '--url' 'https://example.com/foo' '--url' 'https://example.com/bar' '--verbose'";
};
+
+ testSanitizeDerivationNameLeadingDots = testSanitizeDerivationName {
+ name = "..foo";
+ expected = "foo";
+ };
+
+ testSanitizeDerivationNameAscii = testSanitizeDerivationName {
+ name = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
+ expected = "-+--.-0123456789-=-?-ABCDEFGHIJKLMNOPQRSTUVWXYZ-_-abcdefghijklmnopqrstuvwxyz-";
+ };
+
+ testSanitizeDerivationNameTooLong = testSanitizeDerivationName {
+ name = "This string is loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong";
+ expected = "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong";
+ };
+
+ testSanitizeDerivationNameTooLongWithInvalid = testSanitizeDerivationName {
+ name = "Hello there aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&&&&&&&";
+ expected = "there-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-";
+ };
+
+ testSanitizeDerivationNameEmpty = testSanitizeDerivationName {
+ name = "";
+ expected = "unknown";
+ };
}
diff --git a/nixpkgs/lib/tests/modules.sh b/nixpkgs/lib/tests/modules.sh
index e81cf016ee9..6258244457a 100755
--- a/nixpkgs/lib/tests/modules.sh
+++ b/nixpkgs/lib/tests/modules.sh
@@ -3,7 +3,10 @@
# This script is used to test that the module system is working as expected.
# By default it test the version of nixpkgs which is defined in the NIX_PATH.
-cd ./modules
+# https://stackoverflow.com/a/246128/6605742
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+
+cd "$DIR"/modules
pass=0
fail=0
diff --git a/nixpkgs/lib/tests/release.nix b/nixpkgs/lib/tests/release.nix
index 069c015d783..ec0f9c32d3f 100644
--- a/nixpkgs/lib/tests/release.nix
+++ b/nixpkgs/lib/tests/release.nix
@@ -1,7 +1,7 @@
-{ pkgs ? import ((import ../.).cleanSource ../..) {} }:
+{ pkgs ? import ../.. {} }:
pkgs.runCommandNoCC "nixpkgs-lib-tests" {
- buildInputs = [ pkgs.nix (import ./check-eval.nix) ];
+ buildInputs = [ pkgs.nix (import ./check-eval.nix) (import ./maintainers.nix { inherit pkgs; }) ];
NIX_PATH = "nixpkgs=${toString pkgs.path}";
} ''
datadir="${pkgs.nix}/share"
@@ -17,8 +17,8 @@ pkgs.runCommandNoCC "nixpkgs-lib-tests" {
cacheDir=$TEST_ROOT/binary-cache
nix-store --init
- cd ${pkgs.path}/lib/tests
- bash ./modules.sh
+ cp -r ${../.} lib
+ bash lib/tests/modules.sh
touch $out
''
diff --git a/nixpkgs/lib/tests/systems.nix b/nixpkgs/lib/tests/systems.nix
index 6f52912994d..ea6e337937f 100644
--- a/nixpkgs/lib/tests/systems.nix
+++ b/nixpkgs/lib/tests/systems.nix
@@ -12,16 +12,17 @@ let
expected = lib.sort lib.lessThan y;
};
in with lib.systems.doubles; lib.runTests {
- testall = mseteq all (linux ++ darwin ++ freebsd ++ openbsd ++ netbsd ++ illumos ++ wasi ++ windows ++ embedded ++ js);
+ testall = mseteq all (linux ++ darwin ++ freebsd ++ openbsd ++ netbsd ++ illumos ++ wasi ++ windows ++ embedded ++ js ++ genode);
- testarm = mseteq arm [ "armv5tel-linux" "armv6l-linux" "armv7a-linux" "armv7l-linux" "arm-none" "armv7a-darwin" ];
+ testarm = mseteq arm [ "armv5tel-linux" "armv6l-linux" "armv6l-none" "armv7a-linux" "armv7l-linux" "arm-none" "armv7a-darwin" ];
testi686 = mseteq i686 [ "i686-linux" "i686-freebsd" "i686-netbsd" "i686-openbsd" "i686-cygwin" "i686-windows" "i686-none" "i686-darwin" ];
testmips = mseteq mips [ "mipsel-linux" ];
- testx86_64 = mseteq x86_64 [ "x86_64-linux" "x86_64-darwin" "x86_64-freebsd" "x86_64-openbsd" "x86_64-netbsd" "x86_64-cygwin" "x86_64-solaris" "x86_64-windows" "x86_64-none" ];
+ testx86_64 = mseteq x86_64 [ "x86_64-linux" "x86_64-darwin" "x86_64-freebsd" "x86_64-genode" "x86_64-openbsd" "x86_64-netbsd" "x86_64-cygwin" "x86_64-solaris" "x86_64-windows" "x86_64-none" ];
testcygwin = mseteq cygwin [ "i686-cygwin" "x86_64-cygwin" ];
testdarwin = mseteq darwin [ "x86_64-darwin" "i686-darwin" "aarch64-darwin" "armv7a-darwin" ];
testfreebsd = mseteq freebsd [ "i686-freebsd" "x86_64-freebsd" ];
+ testgenode = mseteq genode [ "aarch64-genode" "x86_64-genode" ];
testgnu = mseteq gnu (linux /* ++ kfreebsd ++ ... */);
testillumos = mseteq illumos [ "x86_64-solaris" ];
testlinux = mseteq linux [ "aarch64-linux" "armv5tel-linux" "armv6l-linux" "armv7a-linux" "armv7l-linux" "i686-linux" "mipsel-linux" "riscv32-linux" "riscv64-linux" "x86_64-linux" "powerpc64le-linux" ];