Skip to content

Commit 11f81a0

Browse files
committed
ghostty: Add systemd integration
The systemd unit already exists on the system, this gives the option to enable it.
1 parent b5ed4af commit 11f81a0

File tree

5 files changed

+53
-2
lines changed

5 files changed

+53
-2
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{ config, pkgs, ... }:
2+
{
3+
time = "2025-11-03T21:56:50+00:00";
4+
condition = config.programs.ghostty.enable && pkgs.stdenv.hostPlatform.isLinux;
5+
message = ''
6+
Ghostty: now enables the user systemd service by default.
7+
8+
Running Ghostty via these systemd units is the recommended way to run
9+
Ghostty. The two most important benefits provided by Ghostty's systemd
10+
integrations are: instantaneous launching and centralized logging.
11+
12+
See https://ghostty.org/docs/linux/systemd for all details
13+
'';
14+
}

modules/programs/ghostty.nix

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,24 @@ in
114114
defaultText = lib.literalMD "`true` if programs.ghostty.package is not null";
115115
};
116116

117+
systemd = lib.mkOption {
118+
type = lib.types.submodule {
119+
options = {
120+
enable = lib.mkEnableOption "the Ghostty systemd user service" // {
121+
default = pkgs.stdenv.hostPlatform.isLinux;
122+
};
123+
};
124+
};
125+
default = { };
126+
defaultText = lib.literalMD "`true` on Linux, `false` otherwise";
127+
description = ''
128+
Configuration for Ghostty's systemd integration.
129+
This enables additional speed and features.
130+
131+
See <https://ghostty.org/docs/linux/systemd> for more information.
132+
'';
133+
};
134+
117135
enableBashIntegration = mkShellIntegrationOption (
118136
lib.hm.shell.mkBashIntegrationOption { inherit config; }
119137
);
@@ -195,6 +213,18 @@ in
195213
};
196214
})
197215

216+
(lib.mkIf (cfg.systemd.enable && pkgs.stdenv.hostPlatform.isLinux) {
217+
assertions = [
218+
{
219+
assertion = cfg.systemd.enable -> cfg.package != null;
220+
message = "programs.ghostty.systemd.enable cannot be true when programs.ghostty.package is null";
221+
}
222+
];
223+
xdg.configFile."systemd/user/app-com.mitchellh.ghostty.service".source =
224+
"${cfg.package}/share/systemd/user/app-com.mitchellh.ghostty.service";
225+
dbus.packages = [ cfg.package ];
226+
})
227+
198228
(lib.mkIf cfg.enableBashIntegration {
199229
# Make order 101 to be placed exactly after bash completions, as Ghostty
200230
# documentation suggests sourcing the script as soon as possible

tests/modules/programs/ghostty/empty-settings.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
{ realPkgs, ... }:
12
{
3+
nixpkgs.overlays = [ (_: _: { inherit (realPkgs) ghostty; }) ];
4+
25
programs.ghostty.enable = true;
36

47
nmt.script = ''

tests/modules/programs/ghostty/example-settings.nix

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
{ config, ... }:
1+
{ realPkgs, ... }:
22
{
3+
nixpkgs.overlays = [ (_: _: { inherit (realPkgs) ghostty; }) ];
4+
35
programs.ghostty = {
46
enable = true;
5-
package = config.lib.test.mkStubPackage { };
7+
package = realPkgs.ghostty;
68

79
settings = {
810
theme = "catppuccin-mocha";

tests/modules/programs/ghostty/example-theme.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
{ realPkgs, ... }:
12
{
3+
nixpkgs.overlays = [ (_: _: { inherit (realPkgs) ghostty; }) ];
24
programs.ghostty = {
35
enable = true;
46

0 commit comments

Comments
 (0)