diff --git a/modules/services/swayosd.nix b/modules/services/swayosd.nix index ac766cf23..4ac2f08ec 100644 --- a/modules/services/swayosd.nix +++ b/modules/services/swayosd.nix @@ -18,6 +18,14 @@ in { meta.maintainers = [ lib.hm.maintainers.pltanton ]; + imports = [ + (lib.mkRemovedOptionModule [ + "services" + "swayosd" + "display" + ] "The --display flag is no longer available in swayosd-server.") + ]; + options.services.swayosd = { enable = lib.mkEnableOption '' swayosd, a GTK based on screen display for keyboard shortcuts like @@ -45,15 +53,6 @@ in Use a custom Stylesheet file instead of looking for one. ''; }; - - display = mkOption { - type = types.nullOr types.str; - default = null; - example = "eDP-1"; - description = '' - X display to use. - ''; - }; }; config = lib.mkIf cfg.enable { @@ -79,7 +78,6 @@ in Type = "simple"; ExecStart = "${cfg.package}/bin/swayosd-server" - + (optionalString (cfg.display != null) " --display ${cfg.display}") + (optionalString (cfg.stylePath != null) " --style ${lib.escapeShellArg cfg.stylePath}") + (optionalString (cfg.topMargin != null) " --top-margin ${toString cfg.topMargin}"); Restart = "always"; diff --git a/tests/modules/services/swayosd/default.nix b/tests/modules/services/swayosd/default.nix index e1e2e7635..85e9f6dae 100644 --- a/tests/modules/services/swayosd/default.nix +++ b/tests/modules/services/swayosd/default.nix @@ -2,4 +2,5 @@ lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { swayosd = ./swayosd.nix; + swayosd-with-deprecated-options = ./deprecated-options.nix; } diff --git a/tests/modules/services/swayosd/deprecated-options.nix b/tests/modules/services/swayosd/deprecated-options.nix new file mode 100644 index 000000000..890cb0034 --- /dev/null +++ b/tests/modules/services/swayosd/deprecated-options.nix @@ -0,0 +1,50 @@ +{ + lib, + config, + options, + ... +}: + +{ + services.swayosd = { + enable = true; + package = config.lib.test.mkStubPackage { + name = "swayosd"; + outPath = "@swayosd@"; + }; + display = "DISPLAY"; + stylePath = "/etc/xdg/swayosd/style.css"; + topMargin = 0.1; + }; + + test.asserts.assertions.expected = [ + '' + The option definition `services.swayosd.display' in ${lib.showFiles options.services.swayosd.display.files} no longer has any effect; please remove it. + The --display flag is no longer available in swayosd-server. + '' + ]; + + nmt.script = '' + assertFileContent \ + home-files/.config/systemd/user/swayosd.service \ + ${builtins.toFile "swayosd.service" '' + [Install] + WantedBy=graphical-session.target + + [Service] + ExecStart=@swayosd@/bin/swayosd-server --style /etc/xdg/swayosd/style.css --top-margin 0.100000 + Restart=always + RestartSec=2s + Type=simple + + [Unit] + After=graphical-session.target + ConditionEnvironment=WAYLAND_DISPLAY + Description=Volume/backlight OSD indicator + Documentation=man:swayosd(1) + PartOf=graphical-session.target + StartLimitBurst=5 + StartLimitIntervalSec=10 + ''} + ''; +} diff --git a/tests/modules/services/swayosd/swayosd.nix b/tests/modules/services/swayosd/swayosd.nix index 80547a191..e0bdaedd0 100644 --- a/tests/modules/services/swayosd/swayosd.nix +++ b/tests/modules/services/swayosd/swayosd.nix @@ -7,7 +7,6 @@ name = "swayosd"; outPath = "@swayosd@"; }; - display = "DISPLAY"; stylePath = "/etc/xdg/swayosd/style.css"; topMargin = 0.1; }; @@ -20,7 +19,7 @@ WantedBy=graphical-session.target [Service] - ExecStart=@swayosd@/bin/swayosd-server --display DISPLAY --style /etc/xdg/swayosd/style.css --top-margin 0.100000 + ExecStart=@swayosd@/bin/swayosd-server --style /etc/xdg/swayosd/style.css --top-margin 0.100000 Restart=always RestartSec=2s Type=simple