44 lines
1 KiB
Nix
44 lines
1 KiB
Nix
|
{
|
||
|
lib,
|
||
|
config,
|
||
|
pkgs,
|
||
|
system,
|
||
|
...
|
||
|
}: let
|
||
|
inherit (lib) mkEnableOption mkIf getExe;
|
||
|
inherit (lib.snowfall.system) is-darwin;
|
||
|
|
||
|
cfg = config.marleyos.services.kanata;
|
||
|
isGenericLinux = config.targets.genericLinux.enable;
|
||
|
isNotNixOS = isGenericLinux || (is-darwin system);
|
||
|
in {
|
||
|
options.marleyos.services.kanata.enable = mkEnableOption "kanata";
|
||
|
|
||
|
# Kanata is available as a module for nixOS and that should be preferred when
|
||
|
# possible.
|
||
|
config = mkIf (cfg.enable && isNotNixOS) {
|
||
|
home.packages = with pkgs; [
|
||
|
kanata
|
||
|
];
|
||
|
|
||
|
systemd.user.services.kanata = {
|
||
|
Unit = {
|
||
|
Description = "Kanata keyboard remapper";
|
||
|
Documentation = "https://github.com/jtroo/kanata";
|
||
|
};
|
||
|
|
||
|
Service = {
|
||
|
Environment = [
|
||
|
"PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/bin"
|
||
|
"DISPLAY=:0"
|
||
|
];
|
||
|
Type = "simple";
|
||
|
ExecStart = "/bin/sh -c 'exec ${getExe pkgs.kanata} --cfg ${./config.kbd}'";
|
||
|
Restart = "no";
|
||
|
};
|
||
|
|
||
|
Install.WantedBy = ["default.target"];
|
||
|
};
|
||
|
};
|
||
|
}
|