modules/lan-mouse: add settings and disable by default
This commit is contained in:
parent
df41cd9697
commit
e3fae636e9
7 changed files with 108 additions and 12 deletions
5
Makefile
5
Makefile
|
@ -36,12 +36,13 @@ define machine_rule
|
||||||
.PHONY: $(1)
|
.PHONY: $(1)
|
||||||
$(1): ;
|
$(1): ;
|
||||||
systemctl --user reset-failed
|
systemctl --user reset-failed
|
||||||
sudo nix run $(NIX_ARGS) .#switch/$(1)
|
sudo nix run $(NIX_ARGS) .#switch/$(1) -- $(BUILD_ARGS)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define vps_rule
|
define vps_rule
|
||||||
.PHONY: $(1)
|
.PHONY: $(1)
|
||||||
$(1): ; nix run .#deploy/$(1)
|
$(1): ; nix run .#deploy/$(1) -- $(BUILD_ARGS)
|
||||||
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(foreach machine,$(MACHINES),$(eval $(call machine_rule,$(machine))))
|
$(foreach machine,$(MACHINES),$(eval $(call machine_rule,$(machine))))
|
||||||
|
|
BIN
hosts/asus-gl553vd/data.secret.nix
Normal file
BIN
hosts/asus-gl553vd/data.secret.nix
Normal file
Binary file not shown.
|
@ -1,5 +1,9 @@
|
||||||
{ ... }:
|
{ ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
asusData = import ../data.secret.nix;
|
||||||
|
homeData = import ../../home/data.secret.nix;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [ ../../../users/jan ];
|
imports = [ ../../../users/jan ];
|
||||||
|
|
||||||
|
@ -11,5 +15,14 @@
|
||||||
# local.programs.dev-tools.k8s.enable = true;
|
# local.programs.dev-tools.k8s.enable = true;
|
||||||
|
|
||||||
local.programs.libreoffice.enable = true;
|
local.programs.libreoffice.enable = true;
|
||||||
|
|
||||||
|
local.services.lan-mouse.settings = {
|
||||||
|
port = asusData.lan-mouse.port;
|
||||||
|
connections.left = {
|
||||||
|
hostname = "home";
|
||||||
|
ips = [ homeData.addr ];
|
||||||
|
port = homeData.lan-mouse.port;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
BIN
hosts/home/data.secret.nix
Normal file
BIN
hosts/home/data.secret.nix
Normal file
Binary file not shown.
|
@ -1,5 +1,9 @@
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
homeData = import ../data.secret.nix;
|
||||||
|
asusData = import ../../asus-gl553vd/data.secret.nix;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [ ../../../users/jan ];
|
imports = [ ../../../users/jan ];
|
||||||
|
|
||||||
|
@ -8,6 +12,15 @@
|
||||||
xmonad.projects = import ./xmonad-projects.secret.nix;
|
xmonad.projects = import ./xmonad-projects.secret.nix;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
local.services.lan-mouse.settings = {
|
||||||
|
port = homeData.lan-mouse.port;
|
||||||
|
connections.left = {
|
||||||
|
hostname = "asus";
|
||||||
|
ips = [ asusData.addr ];
|
||||||
|
port = asusData.lan-mouse.port;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
local.programs.editors.arduino-ide.enable = true;
|
local.programs.editors.arduino-ide.enable = true;
|
||||||
|
|
||||||
local.programs.dev-tools.k8s.enable = true;
|
local.programs.dev-tools.k8s.enable = true;
|
||||||
|
|
|
@ -3,24 +3,88 @@
|
||||||
let
|
let
|
||||||
cfg = config.local.services.lan-mouse;
|
cfg = config.local.services.lan-mouse;
|
||||||
|
|
||||||
|
connectionSettings = with lib; (types.submodule {
|
||||||
|
options = {
|
||||||
|
hostname = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "";
|
||||||
|
};
|
||||||
|
ips = mkOption {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
default = [ ];
|
||||||
|
};
|
||||||
|
port = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
default = 4242;
|
||||||
|
};
|
||||||
|
activateOnStartup = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
inherit (builtins) concatStringsSep;
|
||||||
|
|
||||||
# See: https://github.com/feschber/lan-mouse/blob/main/src/config.rs#L79
|
# See: https://github.com/feschber/lan-mouse/blob/main/src/config.rs#L79
|
||||||
lanMouseConfig = pkgs.writeText "config.toml" ''
|
lanMouseConfig = pkgs.writeText "config.toml" (
|
||||||
port = ${toString cfg.port}
|
let
|
||||||
'';
|
# List[str] -> str
|
||||||
|
listOfStr = l: concatStringsSep "," (map (val: "\"${val}\"") l);
|
||||||
|
in
|
||||||
|
''
|
||||||
|
port = ${toString cfg.settings.port}
|
||||||
|
frontent = "${cfg.settings.frontend}"
|
||||||
|
''
|
||||||
|
+ lib.optionalString (cfg.settings.releaseBind != [ ]) ''
|
||||||
|
release_bind = [${listOfStr cfg.settings.releaseBind}]
|
||||||
|
''
|
||||||
|
+ (concatStringsSep "\n"
|
||||||
|
(lib.attrValues
|
||||||
|
(lib.mapAttrs
|
||||||
|
(key: value: ''
|
||||||
|
[${key}]
|
||||||
|
ips = [${listOfStr value.ips}]
|
||||||
|
${lib.optionalString (value.hostname != "") ''
|
||||||
|
hostname = "${value.hostname}"
|
||||||
|
''}
|
||||||
|
port = ${toString value.port}
|
||||||
|
activate_on_startup = ${if value.activateOnStartup then "true" else "false"}
|
||||||
|
''
|
||||||
|
)
|
||||||
|
cfg.settings.connections
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.local.services.lan-mouse = with lib; {
|
options.local.services.lan-mouse = with lib; {
|
||||||
enable = mkEnableOption "lan-mouse";
|
enable = mkEnableOption "lan-mouse";
|
||||||
|
settings = {
|
||||||
|
releaseBind = mkOption {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
default = [ ];
|
||||||
|
};
|
||||||
|
frontend = mkOption {
|
||||||
|
type = types.enum [ "cli" "gtk" ];
|
||||||
|
default = "gtk";
|
||||||
|
};
|
||||||
port = mkOption {
|
port = mkOption {
|
||||||
type = types.int;
|
type = types.int;
|
||||||
default = 4242;
|
default = 4242;
|
||||||
};
|
};
|
||||||
|
connections = mkOption {
|
||||||
|
type = types.attrsOf connectionSettings;
|
||||||
|
default = { };
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
programs.lan-mouse = {
|
programs.lan-mouse = {
|
||||||
enable = true;
|
enable = true;
|
||||||
systemd = true;
|
# systemd = true;
|
||||||
package = pkgs.unstable.lan-mouse;
|
package = pkgs.unstable.lan-mouse;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
networking.firewall.allowedUDPPorts =
|
networking.firewall.allowedUDPPorts =
|
||||||
let lanMouseCfg = config.home-manager.users.jan.local.services.lan-mouse;
|
let lanMouseCfg = config.home-manager.users.jan.local.services.lan-mouse;
|
||||||
in lib.optional lanMouseCfg.enable lanMouseCfg.port;
|
in lib.optional lanMouseCfg.enable lanMouseCfg.settings.port;
|
||||||
|
|
||||||
home-manager.users.jan = {
|
home-manager.users.jan = {
|
||||||
imports = [
|
imports = [
|
||||||
|
@ -112,8 +112,13 @@
|
||||||
local.services.wired.enable = lib.mkDefault true;
|
local.services.wired.enable = lib.mkDefault true;
|
||||||
|
|
||||||
local.services.lan-mouse = {
|
local.services.lan-mouse = {
|
||||||
enable = lib.mkDefault true;
|
# x11 input capture not available: not implemented
|
||||||
|
enable = lib.mkDefault false;
|
||||||
|
settings = {
|
||||||
|
# releaseBind = [ "KeyLeftCtrl" "KeyLeftShift" "KeyF1" ];
|
||||||
port = lib.mkDefault 32000;
|
port = lib.mkDefault 32000;
|
||||||
|
frontend = "cli";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
Loading…
Reference in a new issue