diff options
author | Alyssa Ross <hi@alyssa.is> | 2020-05-13 00:32:00 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2020-05-13 00:41:26 +0000 |
commit | 439d80fbdcdf6245444e99e3764f233122c86358 (patch) | |
tree | bd769aabc0c8e46d3fdf8f0cc80297463e7d0dba /lib | |
parent | cc2d9c385f776f38fa37656b8440b5c4a460e9a7 (diff) | |
parent | 9f5e9ef4b71a2a1ea8efef56f5876cdc846d6387 (diff) | |
download | nixpkgs-439d80fbdcdf6245444e99e3764f233122c86358.tar nixpkgs-439d80fbdcdf6245444e99e3764f233122c86358.tar.gz nixpkgs-439d80fbdcdf6245444e99e3764f233122c86358.tar.bz2 nixpkgs-439d80fbdcdf6245444e99e3764f233122c86358.tar.lz nixpkgs-439d80fbdcdf6245444e99e3764f233122c86358.tar.xz nixpkgs-439d80fbdcdf6245444e99e3764f233122c86358.tar.zst nixpkgs-439d80fbdcdf6245444e99e3764f233122c86358.zip |
Merge remote-tracking branch 'nixpkgs/master' into master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/default.nix | 2 | ||||
-rw-r--r-- | lib/deprecated.nix | 2 | ||||
-rw-r--r-- | lib/kernel.nix | 2 | ||||
-rw-r--r-- | lib/licenses.nix | 41 | ||||
-rw-r--r-- | lib/lists.nix | 4 | ||||
-rw-r--r-- | lib/options.nix | 9 | ||||
-rw-r--r-- | lib/strings.nix | 15 | ||||
-rw-r--r-- | lib/tests/maintainers.nix | 76 | ||||
-rwxr-xr-x | lib/tests/modules.sh | 5 | ||||
-rw-r--r-- | lib/tests/release.nix | 19 |
10 files changed, 142 insertions, 33 deletions
diff --git a/lib/default.nix b/lib/default.nix index d00c4abec0a..e7f59a67abb 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -141,7 +141,7 @@ let mergeAttrsWithFunc mergeAttrsConcatenateValues mergeAttrsNoOverride mergeAttrByFunc mergeAttrsByFuncDefaults mergeAttrsByFuncDefaultsClean mergeAttrBy - fakeSri fakeSha256 fakeSha512 + fakeHash fakeSha256 fakeSha512 nixType imap; inherit (versions) splitVersion; diff --git a/lib/deprecated.nix b/lib/deprecated.nix index 8c4fe9c390c..be0ef904c66 100644 --- a/lib/deprecated.nix +++ b/lib/deprecated.nix @@ -272,7 +272,7 @@ rec { imap = imap1; # Fake hashes. Can be used as hash placeholders, when computing hash ahead isn't trivial - fakeSri = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; + fakeHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="; fakeSha256 = "0000000000000000000000000000000000000000000000000000000000000000"; fakeSha512 = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; } diff --git a/lib/kernel.nix b/lib/kernel.nix index 2ce19f8cb68..8045a228d05 100644 --- a/lib/kernel.nix +++ b/lib/kernel.nix @@ -14,7 +14,7 @@ with lib; freeform = x: { freeform = x; }; /* - Common patterns/legacy used in common-config/hardened-config.nix + Common patterns/legacy used in common-config/hardened/config.nix */ whenHelpers = version: { whenAtLeast = ver: mkIf (versionAtLeast version ver); diff --git a/lib/licenses.nix b/lib/licenses.nix index 81976a769c0..4c07797b16c 100644 --- a/lib/licenses.nix +++ b/lib/licenses.nix @@ -2,7 +2,7 @@ let spdx = lic: lic // { - url = "http://spdx.org/licenses/${lic.spdxId}.html"; + url = "https://spdx.org/licenses/${lic.spdxId}.html"; }; in @@ -40,13 +40,13 @@ lib.mapAttrs (n: v: v // { shortName = n; }) { amazonsl = { fullName = "Amazon Software License"; - url = "http://aws.amazon.com/asl/"; + url = "https://aws.amazon.com/asl/"; free = false; }; amd = { fullName = "AMD License Agreement"; - url = "http://developer.amd.com/amd-license-agreement/"; + url = "https://developer.amd.com/amd-license-agreement/"; 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 = "https://avasys.jp/hp/menu000000700/hpg000000603.htm"; free = false; }; @@ -271,6 +271,11 @@ lib.mapAttrs (n: v: v // { shortName = n; }) { fullName = "European Union Public License 1.1"; }; + eupl12 = spdx { + spdxId = "EUPL-1.2"; + fullName = "European Union Public License 1.2"; + }; + fdl12 = spdx { spdxId = "GFDL-1.2-only"; fullName = "GNU Free Documentation License v1.2 only"; @@ -293,7 +298,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) { ffsl = { fullName = "Floodgap Free Software License"; - url = "http://www.floodgap.com/software/ffsl/license.html"; + url = "https://www.floodgap.com/software/ffsl/license.html"; free = false; }; @@ -370,7 +375,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 = "https://old.calculate-linux.org/packages/licenses/iASL"; }; ijg = spdx { @@ -385,13 +390,13 @@ lib.mapAttrs (n: v: v // { shortName = n; }) { inria-compcert = { fullName = "INRIA Non-Commercial License Agreement for the CompCert verified compiler"; - url = "http://compcert.inria.fr/doc/LICENSE"; + url = "http://compcert.inria.fr/doc/LICENSE"; # https is broken free = false; }; inria-icesl = { fullName = "INRIA Non-Commercial License Agreement for IceSL"; - url = "http://shapeforge.loria.fr/icesl/EULA_IceSL_binary.pdf"; + url = "http://shapeforge.loria.fr/icesl/EULA_IceSL_binary.pdf"; # https is broken free = false; }; @@ -469,7 +474,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 = "https://opensource.franz.com/preamble.html"; }; lppl12 = spdx { @@ -493,7 +498,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) { }; # spdx.org does not (yet) differentiate between the X11 and Expat versions - # for details see http://en.wikipedia.org/wiki/MIT_License#Various_versions + # for details see https://en.wikipedia.org/wiki/MIT_License#Various_versions mit = spdx { spdxId = "MIT"; fullName = "MIT License"; @@ -519,12 +524,6 @@ lib.mapAttrs (n: v: v // { shortName = n; }) { fullName = "Microsoft Public License"; }; - msrla = { - fullName = "Microsoft Research License Agreement"; - url = "http://research.microsoft.com/en-us/projects/pex/msr-la.txt"; - free = false; - }; - nasa13 = spdx { spdxId = "NASA-1.3"; fullName = "NASA Open Source Agreement 1.3"; @@ -596,7 +595,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) { psfl = spdx { spdxId = "Python-2.0"; fullName = "Python Software Foundation License version 2"; - #url = http://docs.python.org/license.html; + url = "https://docs.python.org/license.html"; }; publicDomain = { @@ -620,7 +619,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) { qwt = { fullName = "Qwt License, Version 1.0"; - url = "http://qwt.sourceforge.net/qwtlicense.html"; + url = "https://qwt.sourceforge.io/qwtlicense.html"; }; ruby = spdx { @@ -646,7 +645,7 @@ 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 = "https://sources.debian.org/copyright/license/debianutils/4.9.1/"; }; sspl = { @@ -663,7 +662,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 = "https://ubuntu.com/legal/font-licence"; }; unfree = { @@ -740,7 +739,7 @@ lib.mapAttrs (n: v: v // { shortName = n; }) { xfig = { fullName = "xfig"; - url = "http://mcj.sourceforge.net/authors.html#xfig"; + url = "http://mcj.sourceforge.net/authors.html#xfig"; # https is broken }; zlib = spdx { diff --git a/lib/lists.nix b/lib/lists.nix index f9f30412770..f424946c72c 100644 --- a/lib/lists.nix +++ b/lib/lists.nix @@ -73,8 +73,8 @@ rec { lconcat [ "a" "b" "c" ] => "zabc" # different types - lstrange = foldl (str: int: str + toString (int + 1)) "" - strange [ 1 2 3 4 ] + lstrange = foldl (str: int: str + toString (int + 1)) "a" + lstrange [ 1 2 3 4 ] => "a2345" */ foldl = op: nul: list: diff --git a/lib/options.nix b/lib/options.nix index 71481c9250a..38f4f1329f2 100644 --- a/lib/options.nix +++ b/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/lib/strings.nix b/lib/strings.nix index 7ecd6b143ee..74e3eaa0722 100644 --- a/lib/strings.nix +++ b/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: diff --git a/lib/tests/maintainers.nix b/lib/tests/maintainers.nix new file mode 100644 index 00000000000..d3ed398c80a --- /dev/null +++ b/lib/tests/maintainers.nix @@ -0,0 +1,76 @@ +# to run these tests (and the others) +# nix-build nixpkgs/lib/tests/release.nix +{ # The pkgs used for dependencies for the testing itself + pkgs +, lib +}: + +let + 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/lib/tests/modules.sh b/lib/tests/modules.sh index e81cf016ee9..6258244457a 100755 --- a/lib/tests/modules.sh +++ b/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/lib/tests/release.nix b/lib/tests/release.nix index 069c015d783..eebee1b49bc 100644 --- a/lib/tests/release.nix +++ b/lib/tests/release.nix @@ -1,8 +1,17 @@ -{ pkgs ? import ((import ../.).cleanSource ../..) {} }: +{ # The pkgs used for dependencies for the testing itself + # Don't test properties of pkgs.lib, but rather the lib in the parent directory + pkgs ? import ../.. {} // { lib = throw "pkgs.lib accessed, but the lib tests should use nixpkgs' lib path directly!"; } +}: pkgs.runCommandNoCC "nixpkgs-lib-tests" { - buildInputs = [ pkgs.nix (import ./check-eval.nix) ]; - NIX_PATH = "nixpkgs=${toString pkgs.path}"; + buildInputs = [ + pkgs.nix + (import ./check-eval.nix) + (import ./maintainers.nix { + inherit pkgs; + lib = import ../.; + }) + ]; } '' datadir="${pkgs.nix}/share" export TEST_ROOT=$(pwd)/test-tmp @@ -17,8 +26,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 '' |