2022-05-09 13:20:43 +02:00
dirname : inputs @ { self , nixpkgs , . . . }: let
inherit ( nixpkgs ) lib ;
inherit ( import " ${ dirname } / v a r s . n i x " dirname inputs ) startsWith ;
in rec {
## Logic Flow
notNull = value : value != null ;
ifNull = value : default : ( if value == null then default else value ) ;
withDefault = default : value : ( if value == null then default else value ) ;
passNull = mayNull : expression : ( if mayNull == null then null else expression ) ;
## Misc
# Creates a package for `config.systemd.packages` that adds an `override.conf` to the specified `unit` (which is the only way to modify a single service template instance).
mkSystemdOverride = pkgs : unit : text : ( pkgs . runCommandNoCC unit { preferLocalBuild = true ; allowSubstitutes = false ; } ''
mkdir - p $ out / $ { lib . escapeShellArg " / e t c / s y s t e m d / s y s t e m / ${ unit } . d / " }
< < < $ { lib . escapeShellArg text } cat > $ out / $ { lib . escapeShellArg " / e t c / s y s t e m d / s y s t e m / ${ unit } . d / o v e r r i d e . c o n f " }
'' ) ;
# Given a message and any value, traces both the message and the value, and returns the value.
2022-05-18 16:06:27 +02:00
trace = message : value : ( builtins . trace ( message + " : " + ( lib . generators . toPretty { } value ) ) value ) ;
2022-05-09 13:20:43 +02:00
}