@@ -389,13 +389,13 @@ in
389389 systemd.units = mkOption {
390390 description = "Definition of systemd units.";
391391 default = {};
392− type = types.attrsOf types.optionSet;
393− options = { name, config, ... }:
392+ type = with types; attrsOf (submodule (
393+ { name, config, ... }:
394394 { options = concreteUnitOptions;
395395 config = {
396396 unit = mkDefault (makeUnit name config);
397397 };
398− };
398+ }));
399399 };
400400
401401 systemd.packages = mkOption {
@@ -406,43 +406,37 @@ in
406406
407407 systemd.targets = mkOption {
408408 default = {};
409− type = types.attrsOf types.optionSet;
410− options = [ targetOptions unitConfig ];
409+ type = with types; attrsOf (submodule [ { options = targetOptions; } unitConfig] );
411410 description = "Definition of systemd target units.";
412411 };
413412
414413 systemd.services = mkOption {
415414 default = {};
416− type = types.attrsOf types.optionSet;
417− options = [ serviceOptions unitConfig serviceConfig ];
415+ type = with types; attrsOf (submodule [ { options = serviceOptions; } unitConfig serviceConfig ]);
418416 description = "Definition of systemd service units.";
419417 };
420418
421419 systemd.sockets = mkOption {
422420 default = {};
423− type = types.attrsOf types.optionSet;
424− options = [ socketOptions unitConfig ];
421+ type = with types; attrsOf (submodule [ { options = socketOptions; } unitConfig ]);
425422 description = "Definition of systemd socket units.";
426423 };
427424
428425 systemd.timers = mkOption {
429426 default = {};
430− type = types.attrsOf types.optionSet;
431− options = [ timerOptions unitConfig ];
427+ type = with types; attrsOf (submodule [ { options = timerOptions; } unitConfig ]);
432428 description = "Definition of systemd timer units.";
433429 };
434430
435431 systemd.paths = mkOption {
436432 default = {};
437− type = types.attrsOf types.optionSet;
438− options = [ pathOptions unitConfig ];
433+ type = with types; attrsOf (submodule [ { options = pathOptions; } unitConfig ]);
439434 description = "Definition of systemd path units.";
440435 };
441436
442437 systemd.mounts = mkOption {
443438 default = [];
444− type = types.listOf types.optionSet;
445− options = [ mountOptions unitConfig mountConfig ];
439+ type = with types; listOf (submodule [ { options = mountOptions; } unitConfig mountConfig ]);
446440 description = ''
447441 Definition of systemd mount units.
448442 This is a list instead of an attrSet, because systemd mandates the names to be derived from
@@ -452,8 +446,7 @@ in
452446
453447 systemd.automounts = mkOption {
454448 default = [];
455− type = types.listOf types.optionSet;
456− options = [ automountOptions unitConfig automountConfig ];
449+ type = with types; listOf (submodule [ { options = automountOptions; } unitConfig automountConfig ]);
457450 description = ''
458451 Definition of systemd automount units.
459452 This is a list instead of an attrSet, because systemd mandates the names to be derived from
@@ -590,33 +583,30 @@ in
590583 systemd.user.units = mkOption {
591584 description = "Definition of systemd per-user units.";
592585 default = {};
593− type = types.attrsOf types.optionSet;
594− options = { name, config, ... }:
586+ type = with types; attrsOf (submodule (
587+ { name, config, ... }:
595588 { options = concreteUnitOptions;
596589 config = {
597590 unit = mkDefault (makeUnit name config);
598591 };
599− };
592+ }));
600593 };
601594
602595 systemd.user.services = mkOption {
603596 default = {};
604− type = types.attrsOf types.optionSet;
605− options = [ serviceOptions unitConfig serviceConfig ];
597+ type = with types; attrsOf (submodule [ { options = serviceOptions; } unitConfig serviceConfig ] );
606598 description = "Definition of systemd per-user service units.";
607599 };
608600
609601 systemd.user.timers = mkOption {
610602 default = {};
611− type = types.attrsOf types.optionSet;
612− options = [ timerOptions unitConfig ];
603+ type = with types; attrsOf (submodule [ { options = timerOptions; } unitConfig ] );
613604 description = "Definition of systemd per-user timer units.";
614605 };
615606
616607 systemd.user.sockets = mkOption {
617608 default = {};
618− type = types.attrsOf types.optionSet;
619− options = [ socketOptions unitConfig ];
609+ type = with types; attrsOf (submodule [ { options = socketOptions; } unitConfig ] );
620610 description = "Definition of systemd per-user socket units.";
621611 };
622612