1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

ghostty: Add systemd integration

The systemd unit already exists on the system, this gives the
option to enable it.
This commit is contained in:
Martijn Boers 2025-11-03 21:33:55 +01:00 committed by Austin Horstman
parent 1c75dd7022
commit 34fe48801d
5 changed files with 56 additions and 2 deletions

View file

@ -114,6 +114,24 @@ in
defaultText = lib.literalMD "`true` if programs.ghostty.package is not null";
};
systemd = lib.mkOption {
type = lib.types.submodule {
options = {
enable = lib.mkEnableOption "the Ghostty systemd user service" // {
default = pkgs.stdenv.hostPlatform.isLinux;
defaultText = lib.literalMD "`true` on Linux, `false` otherwise";
};
};
};
default = { };
description = ''
Configuration for Ghostty's systemd integration.
This enables additional speed and features.
See <https://ghostty.org/docs/linux/systemd> for more information.
'';
};
enableBashIntegration = mkShellIntegrationOption (
lib.hm.shell.mkBashIntegrationOption { inherit config; }
);
@ -195,6 +213,22 @@ in
};
})
(lib.mkIf cfg.systemd.enable {
assertions = [
{
assertion = cfg.systemd.enable -> cfg.package != null;
message = "programs.ghostty.systemd.enable cannot be true when programs.ghostty.package is null";
}
{
assertion = cfg.systemd.enable -> pkgs.stdenv.hostPlatform.isLinux;
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";
dbus.packages = [ cfg.package ];
})
(lib.mkIf cfg.enableBashIntegration {
# Make order 101 to be placed exactly after bash completions, as Ghostty
# documentation suggests sourcing the script as soon as possible