1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-30 15:09:46 +01:00
home-manager/modules/services/kdeconnect.nix
Liassica 29c69d9a46
kdeconnect: fix service with 24.05 package version
The 24.05 update for KDE Connect moved the kdeconnectd binary from
`/libexec` to `/bin`, so this fix will check the version of the
package used and set the path accordingly.
2024-05-30 09:05:10 +02:00

91 lines
2.4 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.kdeconnect;
in {
meta.maintainers = [ maintainers.adisbladis ];
options = {
services.kdeconnect = {
enable = mkEnableOption "KDE connect";
package = mkOption {
type = types.package;
default = pkgs.plasma5Packages.kdeconnect-kde;
example = literalExpression "pkgs.kdePackages.kdeconnect-kde";
description = "The KDE connect package to use";
};
indicator = mkOption {
type = types.bool;
default = false;
description = "Whether to enable kdeconnect-indicator service.";
};
};
};
config = mkMerge [
(mkIf cfg.enable {
home.packages = [ cfg.package ];
assertions = [
(hm.assertions.assertPlatform "services.kdeconnect" pkgs
platforms.linux)
];
systemd.user.services.kdeconnect = {
Unit = {
Description =
"Adds communication between your desktop and your smartphone";
After = [ "graphical-session-pre.target" ];
PartOf = [ "graphical-session.target" ];
};
Install = { WantedBy = [ "graphical-session.target" ]; };
Service = {
Environment = "PATH=${config.home.profileDirectory}/bin";
ExecStart =
if strings.versionAtLeast (versions.majorMinor cfg.package.version)
"24.05" then
"${cfg.package}/bin/kdeconnectd"
else
"${cfg.package}/libexec/kdeconnectd";
Restart = "on-abort";
};
};
})
(mkIf cfg.indicator {
assertions = [
(hm.assertions.assertPlatform "services.kdeconnect" pkgs
platforms.linux)
];
systemd.user.services.kdeconnect-indicator = {
Unit = {
Description = "kdeconnect-indicator";
After = [
"graphical-session-pre.target"
"polybar.service"
"taffybar.service"
"stalonetray.service"
];
PartOf = [ "graphical-session.target" ];
Requires = [ "tray.target" ];
};
Install = { WantedBy = [ "graphical-session.target" ]; };
Service = {
Environment = "PATH=${config.home.profileDirectory}/bin";
ExecStart = "${cfg.package}/bin/kdeconnect-indicator";
Restart = "on-abort";
};
};
})
];
}