1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

treewide: reformat nixfmt-rfc-style

Reformat repository using new nixfmt-rfc-style.
This commit is contained in:
Austin Horstman 2025-04-07 16:11:29 -05:00
parent 5df48c4255
commit cba2f9ce95
1051 changed files with 37028 additions and 26594 deletions

View file

@ -1,10 +1,28 @@
{ lib, gvariant ? import ./gvariant.nix { inherit lib; } }:
{
lib,
gvariant ? import ./gvariant.nix { inherit lib; },
}:
let
inherit (lib)
all concatMap foldl' getFiles getValues head isFunction literalExpression
mergeAttrs mergeDefaultOption mergeOneOption mergeOptions mkOption
mkOptionType showFiles showOption types;
all
concatMap
foldl'
getFiles
getValues
head
isFunction
literalExpression
mergeAttrs
mergeDefaultOption
mergeOneOption
mergeOptions
mkOption
mkOptionType
showFiles
showOption
types
;
typesDag = import ./types-dag.nix { inherit lib; };
@ -12,24 +30,30 @@ let
# must refer back to the type.
gvar = gvariant;
in rec {
in
rec {
inherit (typesDag) dagOf;
selectorFunction = mkOptionType {
name = "selectorFunction";
description = "Function that takes an attribute set and returns a list"
description =
"Function that takes an attribute set and returns a list"
+ " containing a selection of the values of the input set";
check = isFunction;
merge = _loc: defs: as: concatMap (select: select as) (getValues defs);
merge =
_loc: defs: as:
concatMap (select: select as) (getValues defs);
};
overlayFunction = mkOptionType {
name = "overlayFunction";
description = "An overlay function, takes self and super and returns"
description =
"An overlay function, takes self and super and returns"
+ " an attribute set overriding the desired attributes.";
check = isFunction;
merge = _loc: defs: self: super:
merge =
_loc: defs: self: super:
foldl' (res: def: mergeAttrs res (def.value self super)) { } defs;
};
@ -69,28 +93,34 @@ in rec {
name = "gvariant";
description = "GVariant value";
check = v: gvar.mkValue v != null;
merge = loc: defs:
merge =
loc: defs:
let
vdefs = map (d:
d // {
value =
if gvar.isGVariant d.value then d.value else gvar.mkValue d.value;
}) defs;
vdefs = map (
d:
d
// {
value = if gvar.isGVariant d.value then d.value else gvar.mkValue d.value;
}
) defs;
vals = map (d: d.value) vdefs;
defTypes = map (x: x.type) vals;
sameOrNull = x: y: if x == y then y else null;
# A bit naive to just check the first entry…
sharedDefType = foldl' sameOrNull (head defTypes) defTypes;
allChecked = all (x: check x) vals;
in if sharedDefType == null then
throw ("Cannot merge definitions of `${showOption loc}' with"
in
if sharedDefType == null then
throw (
"Cannot merge definitions of `${showOption loc}' with"
+ " mismatched GVariant types given in"
+ " ${showFiles (getFiles defs)}.")
+ " ${showFiles (getFiles defs)}."
)
else if gvar.isArray sharedDefType && allChecked then
gvar.mkValue ((types.listOf gvariant).merge loc
(map (d: d // { value = d.value.value; }) vdefs)) // {
type = sharedDefType;
}
gvar.mkValue ((types.listOf gvariant).merge loc (map (d: d // { value = d.value.value; }) vdefs))
// {
type = sharedDefType;
}
else if gvar.isTuple sharedDefType && allChecked then
mergeOneOption loc defs
else if gvar.isMaybe sharedDefType && allChecked then
@ -107,27 +137,37 @@ in rec {
mergeDefaultOption loc defs;
};
nushellValue = let
valueType = types.nullOr (types.oneOf [
(lib.mkOptionType {
name = "nushell";
description = "Nushell inline value";
descriptionClass = "name";
check = lib.isType "nushell-inline";
})
types.bool
types.int
types.float
types.str
types.path
(types.attrsOf valueType // {
description = "attribute set of Nushell values";
descriptionClass = "name";
})
(types.listOf valueType // {
description = "list of Nushell values";
descriptionClass = "name";
})
]);
in valueType;
nushellValue =
let
valueType = types.nullOr (
types.oneOf [
(lib.mkOptionType {
name = "nushell";
description = "Nushell inline value";
descriptionClass = "name";
check = lib.isType "nushell-inline";
})
types.bool
types.int
types.float
types.str
types.path
(
types.attrsOf valueType
// {
description = "attribute set of Nushell values";
descriptionClass = "name";
}
)
(
types.listOf valueType
// {
description = "list of Nushell values";
descriptionClass = "name";
}
)
]
);
in
valueType;
}