@@ -786,6 +786,18 @@ in
786786 '';
787787 };
788788
789+ systemd.suppressedSystemUnits = mkOption {
790+ default = [ ];
791+ type = types.listOf types.str;
792+ example = [ "systemd-backlight@.service" ];
793+ description = ''
794+ A list of units to suppress when generating system systemd configuration directory. This has
795+ priority over upstream units, <option>systemd.units</option>, and
796+ <option>systemd.additionalUpstreamSystemUnits</option>. The main purpose of this is to
797+ suppress a upstream systemd unit with any modifications made to it by other NixOS modules.
798+ '';
799+ };
800+
789801 };
790802
791803
@@ -818,8 +830,11 @@ in
818830 done
819831 ${concatStrings (mapAttrsToList (exec: target: "ln -s ${target} $out/${exec};\n") links)}
820832 '';
833+
834+ enabledUpstreamSystemUnits = filter (n: ! elem n cfg.suppressedSystemUnits) upstreamSystemUnits;
835+ enabledUnits = filterAttrs (n: v: ! elem n cfg.suppressedSystemUnits) cfg.units;
821836 in ({
822− "systemd/system".source = generateUnits "system" cfg.units upstreamSystemUnits upstreamSystemWants;
837+ "systemd/system".source = generateUnits "system" enabledUnits enabledUpstreamSystemUnits upstreamSystemWants;
823838
824839 "systemd/user".source = generateUnits "user" cfg.user.units upstreamUserUnits [];
825840