Structure
This section uses the variables myconfigName, moduleSystem, and homeManagerUser, so it's recommended to first review the corresponding subsection: delib.configurations Function Arguments.
Function Arguments
name: string. It is recommended that it matches the parent path of the module'senableoption, such as"programs.example", since thecfgargument depends on this path.options: attrset or a lambda that returns an attrset (see Options).[myconfig|nixos|home|darwin].[ifEnabled|ifDisabled|always]: attrset or a lambda that returns an attrset.myconfig.*: sets values inconfig.${myconfigName}.nixos.*: sets values inconfigifmoduleSystemisnixos. Otherwise, does nothing.home.*: sets values inconfigifModuleSystemishome. Otherwise, sets it inconfig.home-manager.users.${homeManagerUser}.darwin.*: sets values inconfigifmoduleSystemisdarwin. Otherwise, does nothing.[myconfig|nixos|home|darwin].ifEnabled: executed only if thecfg.enableoption (see Passed Arguments - cfg) exists and istrue.[myconfig|nixos|home|darwin].ifDisabled: executed only if thecfg.enableoption exists and isfalse.[myconfig|nixos|home|darwin].always: always executed, even if thecfg.enableoption doesn't exist.
Passed Arguments
A list of arguments passed to options and [myconfig|nixos|home|darwin].[ifEnabled|ifDisabled|always], if their type is a lambda:
name: the same name from thedelib.modulearguments.myconfig: equalsconfig.${myConfigName}.cfg: essentially, the config values (assigned options) of the current module. In other words, equalsconfig.${myConfigName}.${name}, wherenameis the argument fromdelib.moduleand is "expanded" (converted to a valid attribute path).parent: equal to the "parent" module (attribute set) ofcfg. Example:parentisconfig.${myConfigName}.programsifcfgisconfig.${myConfigName}.programs.example.
Pseudocode
nix
delib.module {
name = "";
# options.${myConfigName} = ...
options = {name, cfg, parent, myconfig, ...}: {};
# config.${myConfigName} = ...
myconfig.ifEnabled = {name, cfg, parent, myconfig, ...}: {};
myconfig.ifDisabled = {name, cfg, parent, myconfig, ...}: {};
myconfig.always = {name, cfg, parent, myconfig, ...}: {};
# if moduleSystem == "nixos"
# then {config = ...;}
# else {}
nixos.ifEnabled = {name, cfg, parent, myconfig, ...}: {};
nixos.ifDisabled = {name, cfg, parent, myconfig, ...}: {};
nixos.always = {name, cfg, parent, myconfig, ...}: {};
# if moduleSystem == "home"
# then {config = ...;}
# else {config.home-manager.users.${homeManagerUser} = ...;}
home.ifEnabled = {name, cfg, parent, myconfig, ...}: {};
home.ifDisabled = {name, cfg, parent, myconfig, ...}: {};
home.always = {name, cfg, parent, myconfig, ...}: {};
# if moduleSystem == "darwin"
# then {config = ...;}
# else {}
darwin.ifEnabled = {name, cfg, parent, myconfig, ...}: {};
darwin.ifDisabled = {name, cfg, parent, myconfig, ...}: {};
darwin.always = {name, cfg, parent, myconfig, ...}: {};
}