git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/systemd: add an option to suppress system units
commit0017a06717bb18706ac3cb99432034caad0c8b91 authorJan Malakhovski <oxij@oxij.org> dateThu 18 Apr 2019, 10:40 (8 years ago) parent9289a39
1 file changed+16−1
nixos/modules/system/boot/systemd.nix+16−1
nixos/modules/system/boot/systemd.nix+16−1
@@ -742,6 +742,18 @@ in
742742 '';
743743 };
744744
745+ systemd.suppressedSystemUnits = mkOption {
746+ default = [ ];
747+ type = types.listOf types.str;
748+ example = [ "systemd-backlight@.service" ];
749+ description = ''
750+ A list of units to suppress when generating system systemd configuration directory. This has
751+ priority over upstream units, <option>systemd.units</option>, and
752+ <option>systemd.additionalUpstreamSystemUnits</option>. The main purpose of this is to
753+ suppress a upstream systemd unit with any modifications made to it by other NixOS modules.
754+ '';
755+ };
756+
745757 };
746758
747759
@@ -771,8 +783,11 @@ in
771783 done;
772784 ${concatStrings (mapAttrsToList (generator: target: "ln -s ${target} $out/${generator};\n") cfg.generators)}
773785 '';
786+
787+ enabledUpstreamSystemUnits = filter (n: ! elem n cfg.suppressedSystemUnits) upstreamSystemUnits;
788+ enabledUnits = filterAttrs (n: v: ! elem n cfg.suppressedSystemUnits) cfg.units;
774789 in ({
775− "systemd/system".source = generateUnits "system" cfg.units upstreamSystemUnits upstreamSystemWants;
790+ "systemd/system".source = generateUnits "system" enabledUnits enabledUpstreamSystemUnits upstreamSystemWants;
776791
777792 "systemd/user".source = generateUnits "user" cfg.user.units upstreamUserUnits [];
778793