1
0
mirror of https://github.com/nix-community/home-manager synced 2024-07-01 19:08:33 +02:00
home-manager/modules/lib/types.nix
Robert Helgesson 6e4b9af080
Switch to extended Nixpkg's lib
This change makes use of the `extend` function inside `lib` to inject
a new `hm` field containing the Home Manager library functions. This
simplifies use of the Home Manager library in the modules and reduces
the risk of accidental infinite recursion.

PR #994
2020-01-21 20:47:04 +01:00

37 lines
859 B
Nix

{ lib, dag ? import ./dag.nix { inherit lib; } }:
with lib;
let
typesDag = import ./types-dag.nix { inherit dag lib; };
in
{
inherit (typesDag) dagOf listOrDagOf;
selectorFunction = mkOptionType {
name = "selectorFunction";
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);
};
overlayFunction = mkOptionType {
name = "overlayFunction";
description =
"An overlay function, takes self and super and returns"
+ " an attribute set overriding the desired attributes.";
check = isFunction;
merge = _loc: defs:
self: super:
foldl' (res: def: mergeAttrs res (def.value self super)) {} defs;
};
}