Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 8f1994c2cc27
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 42cc5c233e61
Choose a head ref
  • 2 commits
  • 1 file changed
  • 2 contributors

Commits on Jan 14, 2020

  1. lib/types: prioritise coercedType in coercedTo

    This more intuitively matches `types.either` and allows paths to be
    coerced to submodules again, which was inhibited by #76861
    arcnmx committed Jan 14, 2020
    Copy the full SHA
    92b464d View commit details
  2. lib/types: prioritise coercedType in coercedTo (#77691)

    lib/types: prioritise coercedType in coercedTo
    infinisil authored Jan 14, 2020
    Copy the full SHA
    42cc5c2 View commit details
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/types.nix
8 changes: 4 additions & 4 deletions lib/types.nix
Original file line number Diff line number Diff line change
@@ -590,7 +590,7 @@ rec {
tail' = tail ts;
in foldl' either head' tail';

# Either value of type `finalType` or `coercedType`, the latter is
# Either value of type `coercedType` or `finalType`, the former is
# converted to `finalType` using `coerceFunc`.
coercedTo = coercedType: coerceFunc: finalType:
assert lib.assertMsg (coercedType.getSubModules == null)
@@ -599,12 +599,12 @@ rec {
mkOptionType rec {
name = "coercedTo";
description = "${finalType.description} or ${coercedType.description} convertible to it";
check = x: finalType.check x || (coercedType.check x && finalType.check (coerceFunc x));
check = x: (coercedType.check x && finalType.check (coerceFunc x)) || finalType.check x;
merge = loc: defs:
let
coerceVal = val:
if finalType.check val then val
else coerceFunc val;
if coercedType.check val then coerceFunc val
else val;
in finalType.merge loc (map (def: def // { value = coerceVal def.value; }) defs);
emptyValue = finalType.emptyValue;
getSubOptions = finalType.getSubOptions;