bonsai: lift out of sxmo

This commit is contained in:
2024-02-23 02:52:35 +00:00
parent 0ff8154e96
commit 4a316d4b91
3 changed files with 34 additions and 68 deletions

View File

@@ -1,7 +1,7 @@
# bonsai docs: <https://sr.ht/~stacyharper/bonsai/>
{ config, lib, pkgs, ... }:
let
cfg = config.sane.gui.sxmo.bonsaid;
cfg = config.sane.programs.bonsai.config;
delayType = with lib; types.submodule {
options = {
@@ -88,74 +88,43 @@ let
mergeOneOption loc defs
;
};
# transitionType = with lib; types.submodule {
# options = {
# type = mkOption {
# type = types.enum [ "delay" "event" "exec" ];
# };
# delay_duration = mkOption {
# type = types.nullOr types.int;
# default = null;
# description = ''
# used for "delay" types only.
# nanoseconds until the event is finalized.
# '';
# };
# event_name = mkOption {
# type = types.nullOr types.str;
# default = null;
# description = ''
# name of event which this transition applies to.
# '';
# };
# transitions = mkOption {
# type = types.nullOr (types.listOf transitionType);
# default = null;
# description = ''
# list of transitions out of this state.
# '';
# };
# command = mkOption {
# type = types.nullOr (types.listOf types.str);
# default = null;
# description = ''
# used for "exec" types only.
# command to run when the event is triggered.
# '';
# };
# };
# };
in
{
options = with lib; {
sane.gui.sxmo.bonsaid.package = mkOption {
type = types.package;
default = pkgs.bonsai;
sane.programs.bonsai = {
configOption = with lib; mkOption {
default = {};
type = types.submodule {
options = {
transitions = mkOption {
type = types.listOf transitionType;
default = [];
};
configFile = mkOption {
type = types.path;
default = pkgs.writeText "bonsai_tree.json" (builtins.toJSON cfg.transitions);
description = ''
configuration file to pass to bonsai.
usually auto-generated from the sibling options; exposed mainly for debugging or convenience.
'';
};
};
};
};
sane.gui.sxmo.bonsaid.transitions = mkOption {
type = types.listOf transitionType;
default = [];
};
sane.gui.sxmo.bonsaid.configFile = mkOption {
type = types.path;
default = pkgs.writeText "bonsai_tree.json" (builtins.toJSON cfg.transitions);
description = ''
configuration file to pass to bonsai.
usually auto-generated from the sibling options; exposed mainly for debugging or convenience.
'';
};
};
config = lib.mkIf config.sane.gui.sxmo.enable {
sane.user.services.bonsaid = {
description = "programmable input dispatcher";
services.bonsaid = {
description = "bonsai: programmable input dispatcher";
after = [ "graphical-session.target" ];
wantedBy = [ "graphical-session.target" ];
script = ''
${pkgs.coreutils}/bin/rm -f $XDG_RUNTIME_DIR/bonsai
exec ${cfg.package}/bin/bonsaid -t ${cfg.configFile}
'';
serviceConfig.Type = "simple";
serviceConfig.Restart = "always";
serviceConfig.RestartSec = "5s";
serviceConfig = {
Type = "simple";
Restart = "always";
RestartSec = "5s";
};
};
};
}

View File

@@ -9,6 +9,7 @@
./assorted.nix
./audacity.nix
./bemenu.nix
./bonsai.nix
./brave.nix
./bubblewrap.nix
./calls.nix

View File

@@ -256,10 +256,6 @@ in
};
};
imports = [
./bonsai.nix
];
config = lib.mkMerge [
{
sane.programs.sxmoApps = {
@@ -267,6 +263,7 @@ in
suggestedPrograms = [
"guiApps"
"bemenu" # specifically to import its theming
"bonsai"
"sfeed" # want this here so that the user's ~/.sfeed/sfeedrc gets created
# "superd" # make superctl (used by sxmo) be on PATH
# "sway-autoscaler"
@@ -403,7 +400,6 @@ in
# TODO: could use `displayManager.sessionPackages`?
environment.systemPackages = [
package
pkgs.bonsai # sway (not sxmo) needs to exec `bonsaictl` by name (sxmo_swayinitconf.sh)
] ++ lib.optionals (cfg.terminal != null) [ pkgs."${cfg.terminal}" ]
++ lib.optionals (cfg.keyboard != null) [ pkgs."${cfg.keyboard}" ];
@@ -420,7 +416,7 @@ in
);
sane.gui.sxmo.bonsaid.transitions = let
sane.programs.bonsai.config.transitions = let
doExec = inputName: transitions: {
type = "exec";
command = [