nix-lib documentation

default.nix

recursiveFuse

Type: [attrs] -> attrs

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


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

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

getKeys

Type: str -> [str]

Read public keys of a given name

name : Function argument


trivial.nix

fuseAttrs

Type: [attrs] -> attrs

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

fuseAttrs usage example

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

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

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

singleAttr

Type: str -> 'a -> attrs

Equivalent of lib.singleton but for an attribute set.

name : Function argument

value : Function argument

singleAttr usage example

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

mapSingleFuse

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

f : Function argument

mapSingleFuse usage example

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

mkRel

Type: path -> str -> path

Creates a relative path as a string

path : Function argument

file : Function argument

mkRel usage example

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