nix-lib documentation


default.nix {#sec-functions-library-default}

recursiveFuse {#function-library-lib.default.recursiveFuse}

Type: [attrs] -> attrs

Same as fuseAttrs but using lib.recursiveUpdate to merge attribute sets together.


mkConfig {#function-library-lib.default.mkConfig}

Creates a confugiration by merging enabled modules, services and extraConfig.

structured function argument

enabledModules : List of modules to enable with enableModules

enabledServices : List of services to import

extraConfig : Extra configuration, defaults to { }

root : Path relative to which the enabled services will be imported

mkConfig usage example {#function-library-example-lib.default.mkConfig}

mkConfig {
enabledModules = [ "ht-defaults" ];
enabledServices = [ "toto" ];
extraConfig = { services.nginx.enable = true; };
root = ./.;
}
=>
{
imports = [ ./toto ];
ht-defaults.enable = true;
services.nginx.enable = true;
}

getKeys {#function-library-lib.default.getKeys}

Type: str -> [str]

Read public keys of a given name

name : Function argument


trivial.nix {#sec-functions-library-trivial}

fuseAttrs {#function-library-lib.trivial.fuseAttrs}

Type: [attrs] -> attrs

Fuses a list of attribute sets into a single attribute set.

fuseAttrs usage example {#function-library-example-lib.trivial.fuseAttrs}

x = [ { a = 1; } { b = 2; } ]
fuseAttrs x
=> { a = 1; b = 2; }

mapFuse {#function-library-lib.trivial.mapFuse}

Type: ('a -> attrs) -> ['a] -> attrs

Applies a function to attrsList before fusing the resulting list of attribute sets.

f : 'a -> attrs

attrsList : ['a]

mapFuse usage example {#function-library-example-lib.trivial.mapFuse}

x = [ "to" "ta" "ti" ]
f = s: { ${s} = s + s; }
mapFuse f x
=> { to = "toto"; ta = "tata"; ti = "titi"; }

singleAttr {#function-library-lib.trivial.singleAttr}

Type: str -> 'a -> attrs

Equivalent of lib.singleton but for an attribute set.

name : Function argument

value : Function argument

singleAttr usage example {#function-library-example-lib.trivial.singleAttr}

singleAttr "a" 1
=> { a = 1; }

mapSingleFuse {#function-library-lib.trivial.mapSingleFuse}

Create an attribute set from a list of values, mapping those values through the function f.

f : Function argument

mapSingleFuse usage example {#function-library-example-lib.trivial.mapSingleFuse}

mapSingleFuse (x: "val-${x}") [ "a" "b" ]
=> { a = "val-a"; b = "val-b" }

mkRel {#function-library-lib.trivial.mkRel}

Type: path -> str -> path

Creates a relative path as a string

path : Function argument

file : Function argument

mkRel usage example {#function-library-example-lib.trivial.mkRel}

mkRel /home/test/ "file.txt"
=> "/home/test/file.txt"