Merge pull request #268997 from nbraud/nixos/systemd/refactor

nixos/systemd: Refactor & link manpages in option descriptions

authored by Maciej Krüger and committed by GitHub 1aeb6d14 0663331e

+99 -91
+99 -91
nixos/modules/system/boot/systemd.nix
··· 177 { 178 ###### interface 179 180 - options = { 181 182 - systemd.package = mkOption { 183 - default = pkgs.systemd; 184 - defaultText = literalExpression "pkgs.systemd"; 185 - type = types.package; 186 - description = lib.mdDoc "The systemd package."; 187 - }; 188 189 - systemd.units = mkOption { 190 - description = lib.mdDoc "Definition of systemd units."; 191 default = {}; 192 type = systemdUtils.types.units; 193 }; 194 195 - systemd.packages = mkOption { 196 default = []; 197 type = types.listOf types.package; 198 example = literalExpression "[ pkgs.systemd-cryptsetup-generator ]"; 199 - description = lib.mdDoc "Packages providing systemd units and hooks."; 200 }; 201 202 - systemd.targets = mkOption { 203 default = {}; 204 type = systemdUtils.types.targets; 205 - description = lib.mdDoc "Definition of systemd target units."; 206 }; 207 208 - systemd.services = mkOption { 209 default = {}; 210 type = systemdUtils.types.services; 211 - description = lib.mdDoc "Definition of systemd service units."; 212 }; 213 214 - systemd.sockets = mkOption { 215 default = {}; 216 type = systemdUtils.types.sockets; 217 - description = lib.mdDoc "Definition of systemd socket units."; 218 }; 219 220 - systemd.timers = mkOption { 221 default = {}; 222 type = systemdUtils.types.timers; 223 - description = lib.mdDoc "Definition of systemd timer units."; 224 }; 225 226 - systemd.paths = mkOption { 227 default = {}; 228 type = systemdUtils.types.paths; 229 - description = lib.mdDoc "Definition of systemd path units."; 230 }; 231 232 - systemd.mounts = mkOption { 233 default = []; 234 type = systemdUtils.types.mounts; 235 - description = lib.mdDoc '' 236 - Definition of systemd mount units. 237 - This is a list instead of an attrSet, because systemd mandates the names to be derived from 238 - the 'where' attribute. 239 ''; 240 }; 241 242 - systemd.automounts = mkOption { 243 default = []; 244 type = systemdUtils.types.automounts; 245 - description = lib.mdDoc '' 246 - Definition of systemd automount units. 247 - This is a list instead of an attrSet, because systemd mandates the names to be derived from 248 - the 'where' attribute. 249 ''; 250 }; 251 252 - systemd.slices = mkOption { 253 default = {}; 254 type = systemdUtils.types.slices; 255 - description = lib.mdDoc "Definition of slice configurations."; 256 }; 257 258 - systemd.generators = mkOption { 259 type = types.attrsOf types.path; 260 default = {}; 261 example = { systemd-gpt-auto-generator = "/dev/null"; }; 262 - description = lib.mdDoc '' 263 - Definition of systemd generators. 264 For each `NAME = VALUE` pair of the attrSet, a link is generated from 265 `/etc/systemd/system-generators/NAME` to `VALUE`. 266 ''; 267 }; 268 269 - systemd.shutdown = mkOption { 270 type = types.attrsOf types.path; 271 default = {}; 272 - description = lib.mdDoc '' 273 Definition of systemd shutdown executables. 274 For each `NAME = VALUE` pair of the attrSet, a link is generated from 275 `/etc/systemd/system-shutdown/NAME` to `VALUE`. 276 ''; 277 }; 278 279 - systemd.defaultUnit = mkOption { 280 default = "multi-user.target"; 281 type = types.str; 282 - description = lib.mdDoc "Default unit started when the system boots."; 283 }; 284 285 - systemd.ctrlAltDelUnit = mkOption { 286 default = "reboot.target"; 287 type = types.str; 288 example = "poweroff.target"; 289 - description = lib.mdDoc '' 290 - Target that should be started when Ctrl-Alt-Delete is pressed. 291 ''; 292 }; 293 294 - systemd.globalEnvironment = mkOption { 295 type = with types; attrsOf (nullOr (oneOf [ str path package ])); 296 default = {}; 297 example = { TZ = "CET"; }; 298 - description = lib.mdDoc '' 299 Environment variables passed to *all* systemd units. 300 ''; 301 }; 302 303 - systemd.managerEnvironment = mkOption { 304 type = with types; attrsOf (nullOr (oneOf [ str path package ])); 305 default = {}; 306 example = { SYSTEMD_LOG_LEVEL = "debug"; }; 307 - description = lib.mdDoc '' 308 Environment variables of PID 1. These variables are 309 *not* passed to started units. 310 ''; 311 }; 312 313 - systemd.enableCgroupAccounting = mkOption { 314 default = true; 315 type = types.bool; 316 - description = lib.mdDoc '' 317 - Whether to enable cgroup accounting. 318 ''; 319 }; 320 321 - systemd.enableUnifiedCgroupHierarchy = mkOption { 322 default = true; 323 type = types.bool; 324 - description = lib.mdDoc '' 325 - Whether to enable the unified cgroup hierarchy (cgroupsv2). 326 ''; 327 }; 328 329 - systemd.extraConfig = mkOption { 330 default = ""; 331 type = types.lines; 332 example = "DefaultLimitCORE=infinity"; 333 - description = lib.mdDoc '' 334 - Extra config options for systemd. See systemd-system.conf(5) man page 335 for available options. 336 ''; 337 }; 338 339 - systemd.sleep.extraConfig = mkOption { 340 default = ""; 341 type = types.lines; 342 example = "HibernateDelaySec=1h"; 343 - description = lib.mdDoc '' 344 Extra config options for systemd sleep state logic. 345 - See sleep.conf.d(5) man page for available options. 346 ''; 347 }; 348 349 - systemd.additionalUpstreamSystemUnits = mkOption { 350 default = [ ]; 351 type = types.listOf types.str; 352 example = [ "debug-shell.service" "systemd-quotacheck.service" ]; 353 - description = lib.mdDoc '' 354 Additional units shipped with systemd that shall be enabled. 355 ''; 356 }; 357 358 - systemd.suppressedSystemUnits = mkOption { 359 default = [ ]; 360 type = types.listOf types.str; 361 example = [ "systemd-backlight@.service" ]; 362 - description = lib.mdDoc '' 363 A list of units to skip when generating system systemd configuration directory. This has 364 priority over upstream units, {option}`systemd.units`, and 365 {option}`systemd.additionalUpstreamSystemUnits`. The main purpose of this is to ··· 368 ''; 369 }; 370 371 - systemd.watchdog.device = mkOption { 372 type = types.nullOr types.path; 373 default = null; 374 example = "/dev/watchdog"; 375 - description = lib.mdDoc '' 376 The path to a hardware watchdog device which will be managed by systemd. 377 - If not specified, systemd will default to /dev/watchdog. 378 ''; 379 }; 380 381 - systemd.watchdog.runtimeTime = mkOption { 382 type = types.nullOr types.str; 383 default = null; 384 example = "30s"; 385 - description = lib.mdDoc '' 386 The amount of time which can elapse before a watchdog hardware device 387 - will automatically reboot the system. Valid time units include "ms", 388 - "s", "min", "h", "d", and "w". 389 ''; 390 }; 391 392 - systemd.watchdog.rebootTime = mkOption { 393 type = types.nullOr types.str; 394 default = null; 395 example = "10m"; 396 - description = lib.mdDoc '' 397 The amount of time which can elapse after a reboot has been triggered 398 before a watchdog hardware device will automatically reboot the system. 399 - Valid time units include "ms", "s", "min", "h", "d", and "w". If left 400 - `null`, systemd will use its default of `10min`; see also {command}`man 401 - 5 systemd-system.conf`. 402 ''; 403 }; 404 405 - systemd.watchdog.kexecTime = mkOption { 406 type = types.nullOr types.str; 407 default = null; 408 example = "10m"; 409 - description = lib.mdDoc '' 410 - The amount of time which can elapse when kexec is being executed before 411 a watchdog hardware device will automatically reboot the system. This 412 - option should only be enabled if reloadTime is also enabled. Valid 413 - time units include "ms", "s", "min", "h", "d", and "w". 414 ''; 415 }; 416 }; ··· 493 "systemd/system.conf".text = '' 494 [Manager] 495 ManagerEnvironment=${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "${n}=${lib.escapeShellArg v}") cfg.managerEnvironment)} 496 - ${optionalString config.systemd.enableCgroupAccounting '' 497 DefaultCPUAccounting=yes 498 DefaultIOAccounting=yes 499 DefaultBlockIOAccounting=yes 500 DefaultIPAccounting=yes 501 ''} 502 DefaultLimitCORE=infinity 503 - ${optionalString (config.systemd.watchdog.device != null) '' 504 - WatchdogDevice=${config.systemd.watchdog.device} 505 ''} 506 - ${optionalString (config.systemd.watchdog.runtimeTime != null) '' 507 - RuntimeWatchdogSec=${config.systemd.watchdog.runtimeTime} 508 ''} 509 - ${optionalString (config.systemd.watchdog.rebootTime != null) '' 510 - RebootWatchdogSec=${config.systemd.watchdog.rebootTime} 511 ''} 512 - ${optionalString (config.systemd.watchdog.kexecTime != null) '' 513 - KExecWatchdogSec=${config.systemd.watchdog.kexecTime} 514 ''} 515 516 - ${config.systemd.extraConfig} 517 ''; 518 519 "systemd/sleep.conf".text = '' 520 [Sleep] 521 - ${config.systemd.sleep.extraConfig} 522 ''; 523 524 "systemd/system-generators" = { source = hooks "generators" cfg.generators; };
··· 177 { 178 ###### interface 179 180 + options.systemd = { 181 182 + package = mkPackageOption pkgs "systemd" {}; 183 184 + units = mkOption { 185 + description = "Definition of systemd units; see {manpage}`systemd.unit(5)`."; 186 default = {}; 187 type = systemdUtils.types.units; 188 }; 189 190 + packages = mkOption { 191 default = []; 192 type = types.listOf types.package; 193 example = literalExpression "[ pkgs.systemd-cryptsetup-generator ]"; 194 + description = "Packages providing systemd units and hooks."; 195 }; 196 197 + targets = mkOption { 198 default = {}; 199 type = systemdUtils.types.targets; 200 + description = "Definition of systemd target units; see {manpage}`systemd.target(5)`"; 201 }; 202 203 + services = mkOption { 204 default = {}; 205 type = systemdUtils.types.services; 206 + description = "Definition of systemd service units; see {manpage}`systemd.service(5)`."; 207 }; 208 209 + sockets = mkOption { 210 default = {}; 211 type = systemdUtils.types.sockets; 212 + description = "Definition of systemd socket units; see {manpage}`systemd.socket(5)`."; 213 }; 214 215 + timers = mkOption { 216 default = {}; 217 type = systemdUtils.types.timers; 218 + description = "Definition of systemd timer units; see {manpage}`systemd.timer(5)`."; 219 }; 220 221 + paths = mkOption { 222 default = {}; 223 type = systemdUtils.types.paths; 224 + description = "Definition of systemd path units; see {manpage}`systemd.path(5)`."; 225 }; 226 227 + mounts = mkOption { 228 default = []; 229 type = systemdUtils.types.mounts; 230 + description = '' 231 + Definition of systemd mount units; see {manpage}`systemd.mount(5)`. 232 + 233 + This is a list instead of an attrSet, because systemd mandates 234 + the names to be derived from the `where` attribute. 235 ''; 236 }; 237 238 + automounts = mkOption { 239 default = []; 240 type = systemdUtils.types.automounts; 241 + description = '' 242 + Definition of systemd automount units; see {manpage}`systemd.automount(5)`. 243 + 244 + This is a list instead of an attrSet, because systemd mandates 245 + the names to be derived from the `where` attribute. 246 ''; 247 }; 248 249 + slices = mkOption { 250 default = {}; 251 type = systemdUtils.types.slices; 252 + description = "Definition of slice configurations; see {manpage}`systemd.slice(5)`."; 253 }; 254 255 + generators = mkOption { 256 type = types.attrsOf types.path; 257 default = {}; 258 example = { systemd-gpt-auto-generator = "/dev/null"; }; 259 + description = '' 260 + Definition of systemd generators; see {manpage}`systemd.generator(5)`. 261 + 262 For each `NAME = VALUE` pair of the attrSet, a link is generated from 263 `/etc/systemd/system-generators/NAME` to `VALUE`. 264 ''; 265 }; 266 267 + shutdown = mkOption { 268 type = types.attrsOf types.path; 269 default = {}; 270 + description = '' 271 Definition of systemd shutdown executables. 272 For each `NAME = VALUE` pair of the attrSet, a link is generated from 273 `/etc/systemd/system-shutdown/NAME` to `VALUE`. 274 ''; 275 }; 276 277 + defaultUnit = mkOption { 278 default = "multi-user.target"; 279 type = types.str; 280 + description = '' 281 + Default unit started when the system boots; see {manpage}`systemd.special(7)`. 282 + ''; 283 }; 284 285 + ctrlAltDelUnit = mkOption { 286 default = "reboot.target"; 287 type = types.str; 288 example = "poweroff.target"; 289 + description = '' 290 + Target that should be started when Ctrl-Alt-Delete is pressed; 291 + see {manpage}`systemd.special(7)`. 292 ''; 293 }; 294 295 + globalEnvironment = mkOption { 296 type = with types; attrsOf (nullOr (oneOf [ str path package ])); 297 default = {}; 298 example = { TZ = "CET"; }; 299 + description = '' 300 Environment variables passed to *all* systemd units. 301 ''; 302 }; 303 304 + managerEnvironment = mkOption { 305 type = with types; attrsOf (nullOr (oneOf [ str path package ])); 306 default = {}; 307 example = { SYSTEMD_LOG_LEVEL = "debug"; }; 308 + description = '' 309 Environment variables of PID 1. These variables are 310 *not* passed to started units. 311 ''; 312 }; 313 314 + enableCgroupAccounting = mkOption { 315 default = true; 316 type = types.bool; 317 + description = '' 318 + Whether to enable cgroup accounting; see {manpage}`cgroups(7)`. 319 ''; 320 }; 321 322 + enableUnifiedCgroupHierarchy = mkOption { 323 default = true; 324 type = types.bool; 325 + description = '' 326 + Whether to enable the unified cgroup hierarchy (cgroupsv2); see {manpage}`cgroups(7)`. 327 ''; 328 }; 329 330 + extraConfig = mkOption { 331 default = ""; 332 type = types.lines; 333 example = "DefaultLimitCORE=infinity"; 334 + description = '' 335 + Extra config options for systemd. See {manpage}`systemd-system.conf(5)` man page 336 for available options. 337 ''; 338 }; 339 340 + sleep.extraConfig = mkOption { 341 default = ""; 342 type = types.lines; 343 example = "HibernateDelaySec=1h"; 344 + description = '' 345 Extra config options for systemd sleep state logic. 346 + See {manpage}`sleep.conf.d(5)` man page for available options. 347 ''; 348 }; 349 350 + additionalUpstreamSystemUnits = mkOption { 351 default = [ ]; 352 type = types.listOf types.str; 353 example = [ "debug-shell.service" "systemd-quotacheck.service" ]; 354 + description = '' 355 Additional units shipped with systemd that shall be enabled. 356 ''; 357 }; 358 359 + suppressedSystemUnits = mkOption { 360 default = [ ]; 361 type = types.listOf types.str; 362 example = [ "systemd-backlight@.service" ]; 363 + description = '' 364 A list of units to skip when generating system systemd configuration directory. This has 365 priority over upstream units, {option}`systemd.units`, and 366 {option}`systemd.additionalUpstreamSystemUnits`. The main purpose of this is to ··· 369 ''; 370 }; 371 372 + watchdog.device = mkOption { 373 type = types.nullOr types.path; 374 default = null; 375 example = "/dev/watchdog"; 376 + description = '' 377 The path to a hardware watchdog device which will be managed by systemd. 378 + If not specified, systemd will default to `/dev/watchdog`. 379 ''; 380 }; 381 382 + watchdog.runtimeTime = mkOption { 383 type = types.nullOr types.str; 384 default = null; 385 example = "30s"; 386 + description = '' 387 The amount of time which can elapse before a watchdog hardware device 388 + will automatically reboot the system. 389 + 390 + Valid time units include "ms", "s", "min", "h", "d", and "w"; 391 + see {manpage}`systemd.time(7)`. 392 ''; 393 }; 394 395 + watchdog.rebootTime = mkOption { 396 type = types.nullOr types.str; 397 default = null; 398 example = "10m"; 399 + description = '' 400 The amount of time which can elapse after a reboot has been triggered 401 before a watchdog hardware device will automatically reboot the system. 402 + If left `null`, systemd will use its default of 10 minutes; 403 + see {manpage}`systemd-system.conf(5)`. 404 + 405 + Valid time units include "ms", "s", "min", "h", "d", and "w"; 406 + see also {manpage}`systemd.time(7)`. 407 ''; 408 }; 409 410 + watchdog.kexecTime = mkOption { 411 type = types.nullOr types.str; 412 default = null; 413 example = "10m"; 414 + description = '' 415 + The amount of time which can elapse when `kexec` is being executed before 416 a watchdog hardware device will automatically reboot the system. This 417 + option should only be enabled if `reloadTime` is also enabled; 418 + see {manpage}`kexec(8)`. 419 + 420 + Valid time units include "ms", "s", "min", "h", "d", and "w"; 421 + see also {manpage}`systemd.time(7)`. 422 ''; 423 }; 424 }; ··· 501 "systemd/system.conf".text = '' 502 [Manager] 503 ManagerEnvironment=${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "${n}=${lib.escapeShellArg v}") cfg.managerEnvironment)} 504 + ${optionalString cfg.enableCgroupAccounting '' 505 DefaultCPUAccounting=yes 506 DefaultIOAccounting=yes 507 DefaultBlockIOAccounting=yes 508 DefaultIPAccounting=yes 509 ''} 510 DefaultLimitCORE=infinity 511 + ${optionalString (cfg.watchdog.device != null) '' 512 + WatchdogDevice=${cfg.watchdog.device} 513 ''} 514 + ${optionalString (cfg.watchdog.runtimeTime != null) '' 515 + RuntimeWatchdogSec=${cfg.watchdog.runtimeTime} 516 ''} 517 + ${optionalString (cfg.watchdog.rebootTime != null) '' 518 + RebootWatchdogSec=${cfg.watchdog.rebootTime} 519 ''} 520 + ${optionalString (cfg.watchdog.kexecTime != null) '' 521 + KExecWatchdogSec=${cfg.watchdog.kexecTime} 522 ''} 523 524 + ${cfg.extraConfig} 525 ''; 526 527 "systemd/sleep.conf".text = '' 528 [Sleep] 529 + ${cfg.sleep.extraConfig} 530 ''; 531 532 "systemd/system-generators" = { source = hooks "generators" cfg.generators; };