diff options
author | Frederik Rietdijk <fridh@fridh.nl> | 2020-09-12 10:00:45 +0200 |
---|---|---|
committer | Frederik Rietdijk <fridh@fridh.nl> | 2020-09-12 10:00:45 +0200 |
commit | 37d29394ecba3ccff2083119ec49fc3eaf36db8c (patch) | |
tree | f5392870bb7a3c48a55cd326dc4f51d9000cb59e /lib | |
parent | 6d269ce4095d110e9e1bc0e358338f8dc8f58076 (diff) | |
parent | fd6899d9b5171da75d53b2435cefee8de4212521 (diff) |
Merge staging-next into staging
Diffstat (limited to 'lib')
-rw-r--r-- | lib/licenses.nix | 5 | ||||
-rw-r--r-- | lib/modules.nix | 6 | ||||
-rw-r--r-- | lib/systems/architectures.nix | 2 | ||||
-rw-r--r-- | lib/systems/examples.nix | 4 | ||||
-rw-r--r-- | lib/tests/misc.nix | 26 | ||||
-rw-r--r-- | lib/trivial.nix | 2 | ||||
-rw-r--r-- | lib/types.nix | 38 |
7 files changed, 57 insertions, 26 deletions
diff --git a/lib/licenses.nix b/lib/licenses.nix index ee11966b0d533..8492cf2495b41 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"; diff --git a/lib/modules.nix b/lib/modules.nix index decb96ffe1117..412c7f1df712f 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/systems/architectures.nix b/lib/systems/architectures.nix index 9d1c29fd9f0bd..bfecaec1ae889 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"; diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix index 5b90fdca5244a..87c05a0b0524f 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; }; diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index b066f577f323b..03eff4ce48b7c 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" "<name>" "bar" ] [ "foo" "bar" ] ]; + }; + } diff --git a/lib/trivial.nix b/lib/trivial.nix index 6eb1fb3a5b115..9501a2906caee 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 = diff --git a/lib/types.nix b/lib/types.nix index 17e7a939fe3d3..ef2c78082f8d6 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; }; @@ -222,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"; @@ -252,9 +257,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"; @@ -327,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 { @@ -427,7 +427,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; @@ -529,8 +534,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; }; |