From b7247f60824fc76e7f17f9cca5f4b557931f1a6f Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 20 Nov 2023 02:31:23 +0000 Subject: [PATCH] sxmo.bonsaid: make it a proper nix module --- hosts/modules/gui/sxmo/bonsai.nix | 33 ++++++++++++++++++++---------- hosts/modules/gui/sxmo/default.nix | 9 +++++--- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/hosts/modules/gui/sxmo/bonsai.nix b/hosts/modules/gui/sxmo/bonsai.nix index b62270e6..597f1137 100644 --- a/hosts/modules/gui/sxmo/bonsai.nix +++ b/hosts/modules/gui/sxmo/bonsai.nix @@ -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"; + }; + }; } diff --git a/hosts/modules/gui/sxmo/default.nix b/hosts/modules/gui/sxmo/default.nix index 62ad0f09..d38decc0 100644 --- a/hosts/modules/gui/sxmo/default.nix +++ b/hosts/modules/gui/sxmo/default.nix @@ -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; }; }