From ea5ba6e13d8b359059245668b69fe72e6d2a6211 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Thu, 3 Sep 2020 21:16:29 +0200 Subject: lib/types: Show sub options of freeform types Previously if you set the freeform type to e.g. attrsOf (submodule ..), those submodule options wouldn't be shown in the manual. --- lib/types.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/types.nix b/lib/types.nix index 1845b6ae339e..cc125c20311d 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -522,7 +522,12 @@ rec { # would be used, and use of `<` and `>` would break the XML document. # It shouldn't cause an issue since this is cosmetic for the manual. args.name = "‹name›"; - }).options; + }).options // optionalAttrs (freeformType != null) { + # Expose the sub options of the freeform type. Note that the option + # discovery doesn't care about the attribute name used here, so this + # is just to avoid conflicts with potential options from the submodule + _freeformOptions = freeformType.getSubOptions prefix; + }; getSubModules = modules; substSubModules = m: submoduleWith (attrs // { modules = m; -- cgit v1.2.3 From f320dbae41cf875ea669b2a8b6083bf2a54f70ce Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Fri, 4 Sep 2020 15:50:13 +0200 Subject: lib/tests: Add test for freeform option docs --- lib/tests/misc.nix | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'lib') diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index b066f577f323..03eff4ce48b7 100644 --- a/lib/tests/misc.nix +++ b/lib/tests/misc.nix @@ -542,4 +542,30 @@ runTests { name = ""; expected = "unknown"; }; + + testFreeformOptions = { + expr = + let + submodule = { lib, ... }: { + freeformType = lib.types.attrsOf (lib.types.submodule { + options.bar = lib.mkOption {}; + }); + options.bar = lib.mkOption {}; + }; + + module = { lib, ... }: { + options.foo = lib.mkOption { + type = lib.types.submodule submodule; + }; + }; + + options = (evalModules { + modules = [ module ]; + }).options; + + locs = filter (o: ! o.internal) (optionAttrSetToDocList options); + in map (o: o.loc) locs; + expected = [ [ "foo" ] [ "foo" "" "bar" ] [ "foo" "bar" ] ]; + }; + } -- cgit v1.2.3 From 1d4656225d4f1e93ea9801c72eb0b1b0bffa245d Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Fri, 4 Sep 2020 13:39:27 +0200 Subject: lib/types: Allow types to emit a deprecation warning Previously the only way to deprecate a type was using theType = lib.warn "deprecated" (mkOptionType ...) This caused the warning to be emitted when the type was evaluated, but the error didn't include which option actually used that type. With this commit, types can specify a deprecationMessage, which when non-null, is printed along with the option that uses the type --- lib/modules.nix | 6 +++++- lib/types.nix | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/modules.nix b/lib/modules.nix index decb96ffe111..412c7f1df712 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -457,7 +457,11 @@ rec { # yield a value computed from the definitions value = if opt ? apply then opt.apply res.mergedValue else res.mergedValue; - in opt // + warnDeprecation = + if opt.type.deprecationMessage == null then id + else warn "The type `types.${opt.type.name}' of option `${showOption loc}' defined in ${showFiles opt.declarations} is deprecated. ${opt.type.deprecationMessage}"; + + in warnDeprecation opt // { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value; inherit (res.defsFinal') highestPrio; definitions = map (def: def.value) res.defsFinal; diff --git a/lib/types.nix b/lib/types.nix index 17e7a939fe3d..f999805e1a98 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -91,9 +91,12 @@ rec { # combinable with the binOp binary operation. # binOp: binary operation that merge two payloads of the same type. functor ? defaultFunctor name + , # The deprecation message to display when this type is used by an option + # If null, the type isn't deprecated + deprecationMessage ? null }: { _type = "option-type"; - inherit name check merge emptyValue getSubOptions getSubModules substSubModules typeMerge functor; + inherit name check merge emptyValue getSubOptions getSubModules substSubModules typeMerge functor deprecationMessage; description = if description == null then name else description; }; -- cgit v1.2.3 From 14095f8f480d850d146341abb72bb81d9952248c Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Fri, 4 Sep 2020 13:45:11 +0200 Subject: lib/types: Remove types.list, it's been deprecated long enough Has been deprecated since fd803fce606a007403ba6d05f09ed2e6a3371830 (2013-08-22) --- lib/types.nix | 3 --- 1 file changed, 3 deletions(-) (limited to 'lib') diff --git a/lib/types.nix b/lib/types.nix index f999805e1a98..caeb688fd908 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -255,9 +255,6 @@ rec { merge = mergeEqualOption; }; - # TODO: drop this in the future: - list = builtins.trace "`types.list` has been removed; please use `types.listOf` instead" types.listOf; - listOf = elemType: mkOptionType rec { name = "listOf"; description = "list of ${elemType.description}s"; -- cgit v1.2.3 From 2bed3b2ad7e671f75580c0df7d2b644bde0181b7 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Fri, 4 Sep 2020 13:47:04 +0200 Subject: lib/types: Set deprecationMessage for types.string --- lib/types.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/types.nix b/lib/types.nix index caeb688fd908..005be5123e7e 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -225,8 +225,10 @@ rec { # Deprecated; should not be used because it quietly concatenates # strings, which is usually not what you want. - string = warn "types.string is deprecated because it quietly concatenates strings" - (separatedString ""); + string = separatedString "" // { + name = "string"; + deprecationMessage = "See https://github.com/NixOS/nixpkgs/pull/66346 for better alternative types."; + }; attrs = mkOptionType { name = "attrs"; -- cgit v1.2.3 From 3b7aca47e0d2523da3158a6522e768a461b08e9f Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Fri, 4 Sep 2020 13:53:03 +0200 Subject: lib/types: Set deprecationMessage for types.loaOf --- lib/types.nix | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/types.nix b/lib/types.nix index 005be5123e7e..a8f744685f9b 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -329,14 +329,12 @@ rec { }; # TODO: drop this in the future: - loaOf = - let msg = - '' - `types.loaOf` has been removed and mixing lists with attribute values - is no longer possible; please use `types.attrsOf` instead. - See https://github.com/NixOS/nixpkgs/issues/1800 for the motivation. - ''; - in builtins.trace msg types.attrsOf; + loaOf = elemType: types.attrsOf elemType // { + name = "loaOf"; + deprecationMessage = "Mixing lists with attribute values is no longer" + + " possible; please use `types.attrsOf` instead. See" + + " https://github.com/NixOS/nixpkgs/issues/1800 for the motivation."; + }; # Value of given type but with no merging (i.e. `uniq list`s are not concatenated). uniq = elemType: mkOptionType rec { -- cgit v1.2.3 From a582f6adde8f4345582c80fc3ccfe0de3aa89480 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Fri, 4 Sep 2020 13:56:18 +0200 Subject: lib/types: Set deprecationMessage for types.optionSet --- lib/types.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/types.nix b/lib/types.nix index a8f744685f9b..d3469450963d 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -529,8 +529,9 @@ rec { # declarations from the ‘options’ attribute of containing option # declaration. optionSet = mkOptionType { - name = builtins.trace "types.optionSet is deprecated; use types.submodule instead" "optionSet"; + name = "optionSet"; description = "option set"; + deprecationMessage = "Use `types.submodule' instead"; }; # Augment the given type with an additional type check function. addCheck = elemType: check: elemType // { check = x: elemType.check x && check x; }; -- cgit v1.2.3 From 1f3587cdd53443912c015dae3a7f0b948d5f7747 Mon Sep 17 00:00:00 2001 From: Jonathan Ringer Date: Mon, 7 Sep 2020 14:15:25 -0700 Subject: 21.03 is Okapi * Okapi is an artiodactyl mammal native to Central Africa * https://en.wikipedia.org/wiki/Okapi --- lib/trivial.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/trivial.nix b/lib/trivial.nix index 6eb1fb3a5b11..9501a2906cae 100644 --- a/lib/trivial.nix +++ b/lib/trivial.nix @@ -171,7 +171,7 @@ rec { On each release the first letter is bumped and a new animal is chosen starting with that new letter. */ - codeName = "Nightingale"; + codeName = "Okapi"; /* Returns the current nixpkgs version suffix as string. */ versionSuffix = -- cgit v1.2.3 From e2bef8fbdc998c07c146db1d047a1e331e4f0517 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 8 Sep 2020 09:33:09 -0400 Subject: lib.systems.examples: Bump android SDK to 21 074bc78cc8749faa31729096b65f2ef51b10abeb evidently meant to do this, but forgot. --- lib/systems/examples.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix index 40e2b8fcefbc..5403f73405c2 100644 --- a/lib/systems/examples.nix +++ b/lib/systems/examples.nix @@ -47,7 +47,7 @@ rec { armv7a-android-prebuilt = { config = "armv7a-unknown-linux-androideabi"; sdkVer = "29"; - ndkVer = "18b"; + ndkVer = "21"; platform = platforms.armv7a-android; useAndroidPrebuilt = true; }; @@ -55,7 +55,7 @@ rec { aarch64-android-prebuilt = { config = "aarch64-unknown-linux-android"; sdkVer = "29"; - ndkVer = "18b"; + ndkVer = "21"; platform = platforms.aarch64-multiplatform; useAndroidPrebuilt = true; }; -- cgit v1.2.3 From 3a38cef8f9108bcbf024c05dc89dd80561f7e62b Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 14 Mar 2020 01:30:31 -0700 Subject: jasper: remove, abandoned upstream. Jasper has been marked insecure for a while, and upstream has not been responsive to CVEs for over a year. Fixes #55388. Signed-off-by: David Anderson --- lib/licenses.nix | 5 ----- 1 file changed, 5 deletions(-) (limited to 'lib') diff --git a/lib/licenses.nix b/lib/licenses.nix index ee11966b0d53..8492cf2495b4 100644 --- a/lib/licenses.nix +++ b/lib/licenses.nix @@ -448,11 +448,6 @@ lib.mapAttrs (n: v: v // { shortName = n; }) { free = false; }; - jasper = spdx { - spdxId = "JasPer-2.0"; - fullName = "JasPer License"; - }; - lgpl2Only = spdx { spdxId = "LGPL-2.0-only"; fullName = "GNU Library General Public License v2 only"; -- cgit v1.2.3 From 8f3efbde4e5d5d5f6af97e8f7e199f37d51d9faa Mon Sep 17 00:00:00 2001 From: arcnmx Date: Wed, 9 Sep 2020 11:56:52 -0700 Subject: Fix arch eval error introduced in #61019 This occurs when using a `platform.gcc.arch` that isn't one of the pre-existing hard-coded options. --- lib/systems/architectures.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/systems/architectures.nix b/lib/systems/architectures.nix index 9d1c29fd9f0b..bfecaec1ae88 100644 --- a/lib/systems/architectures.nix +++ b/lib/systems/architectures.nix @@ -60,7 +60,7 @@ rec { }; predicates = let - featureSupport = feature: x: builtins.elem feature features.${x}; + featureSupport = feature: x: builtins.elem feature features.${x} or []; in { sse3Support = featureSupport "sse3"; ssse3Support = featureSupport "ssse3"; -- cgit v1.2.3