diff --git a/modules/programs/ghostty.nix b/modules/programs/ghostty.nix index 38cfadf1..a8102a5a 100644 --- a/modules/programs/ghostty.nix +++ b/modules/programs/ghostty.nix @@ -224,8 +224,15 @@ in message = "Ghostty systemd integration cannot be enabled for non-linux platforms"; } ]; + xdg.configFile."systemd/user/app-com.mitchellh.ghostty.service".source = "${cfg.package}/share/systemd/user/app-com.mitchellh.ghostty.service"; + + xdg.configFile."systemd/user/app-com.mitchellh.ghostty.service.d/overrides.conf".text = '' + [Unit] + X-SwitchMethod=keep-old + ''; + dbus.packages = [ cfg.package ]; }) diff --git a/tests/modules/programs/ghostty/default.nix b/tests/modules/programs/ghostty/default.nix index e9db62d5..b5bfe911 100644 --- a/tests/modules/programs/ghostty/default.nix +++ b/tests/modules/programs/ghostty/default.nix @@ -1,5 +1,10 @@ +{ lib, pkgs, ... }: + { - ghostty-example-settings = ./example-settings.nix; ghostty-empty-settings = ./empty-settings.nix; + ghostty-example-settings = ./example-settings.nix; ghostty-example-theme = ./example-theme.nix; } +// lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { + ghostty-systemd-service = ./systemd-service.nix; +} diff --git a/tests/modules/programs/ghostty/example-settings.nix b/tests/modules/programs/ghostty/example-settings.nix index b45094d2..6d048e5d 100644 --- a/tests/modules/programs/ghostty/example-settings.nix +++ b/tests/modules/programs/ghostty/example-settings.nix @@ -11,6 +11,9 @@ }; nmt.script = '' + servicePath=home-files/.config/systemd/user/app-com.mitchellh.ghostty.service + assertPathNotExists $servicePath + assertFileContent \ home-files/.config/ghostty/config \ ${./example-config-expected} diff --git a/tests/modules/programs/ghostty/systemd-service.nix b/tests/modules/programs/ghostty/systemd-service.nix new file mode 100644 index 00000000..6efaa902 --- /dev/null +++ b/tests/modules/programs/ghostty/systemd-service.nix @@ -0,0 +1,28 @@ +{ config, ... }: +{ + programs.ghostty = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = null; }; + systemd.enable = true; + settings = { + theme = "catppuccin-mocha"; + font-size = 10; + }; + }; + + nmt.script = '' + servicePath=home-files/.config/systemd/user/app-com.mitchellh.ghostty.service + serviceOverridesPath=$servicePath.d/overrides.conf + + assertFileExists $serviceOverridesPath + assertFileContent $serviceOverridesPath \ + ${builtins.toFile "ghostty-service-overrides" '' + [Unit] + X-SwitchMethod=keep-old + ''} + + assertFileContent \ + home-files/.config/ghostty/config \ + ${./example-config-expected} + ''; +}