sxmo.bonsaid: make it a proper nix module

This commit is contained in:
Colin 2023-11-20 02:31:23 +00:00
parent 9cc72c09dc
commit b7247f6082
2 changed files with 28 additions and 14 deletions

View File

@ -1,13 +1,24 @@
{ sxmoPath, sxmoEnvSetup, pkgs }:
{ config, lib, pkgs, ... }:
let
cfg = config.sane.gui.sxmo.bonsaid;
in
{
description = "programmable input dispatcher";
path = sxmoPath;
script = ''
${sxmoEnvSetup}
${pkgs.coreutils}/bin/rm -f $XDG_RUNTIME_DIR/bonsai
exec ${pkgs.bonsai}/bin/bonsaid -t $XDG_CONFIG_HOME/sxmo/bonsai_tree.json
'';
serviceConfig.Type = "simple";
serviceConfig.Restart = "always";
serviceConfig.RestartSec = "5s";
options = with lib; {
sane.gui.sxmo.bonsaid.package = mkOption {
type = types.package;
default = pkgs.bonsai;
};
};
config = {
sane.user.services.bonsaid = {
description = "programmable input dispatcher";
script = ''
${pkgs.coreutils}/bin/rm -f $XDG_RUNTIME_DIR/bonsai
exec ${cfg.package}/bin/bonsaid -t $XDG_CONFIG_HOME/sxmo/bonsai_tree.json
'';
serviceConfig.Type = "simple";
serviceConfig.Restart = "always";
serviceConfig.RestartSec = "5s";
};
};
}

View File

@ -251,6 +251,10 @@ in
};
};
imports = [
./bonsai.nix
];
config = lib.mkMerge [
{
sane.programs.sxmoApps = {
@ -535,9 +539,8 @@ in
sxmo_wob = sxmoService "wob";
sxmo-x11-status = sxmoService "status_xsetroot";
bonsaid = import ./bonsai.nix {
inherit sxmoPath sxmoEnvSetup pkgs;
};
bonsaid.path = sxmoPath;
bonsaid.script = lib.mkBefore sxmoEnvSetup;
};
}