From 6b99c0f7716bff9bee9bb40a3c3752a711d0feea Mon Sep 17 00:00:00 2001 From: Jan-Bulthuis Date: Fri, 18 Apr 2025 21:49:36 +0200 Subject: [PATCH] Added a module for Xpra --- user-modules/default.nix | 1 + user-modules/wprs/default.nix | 6 ++-- user-modules/xpra/default.nix | 63 +++++++++++++++++++++++++++++++++++ users/jan.nix | 9 ++++- 4 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 user-modules/xpra/default.nix diff --git a/user-modules/default.nix b/user-modules/default.nix index 6ce7e68..4c3ccad 100644 --- a/user-modules/default.nix +++ b/user-modules/default.nix @@ -33,6 +33,7 @@ ./whatsapp/default.nix ./wprs/default.nix ./winbox/default.nix + ./xpra/default.nix ./zathura/default.nix # Import unfree helper diff --git a/user-modules/wprs/default.nix b/user-modules/wprs/default.nix index 58139d9..8f23b94 100644 --- a/user-modules/wprs/default.nix +++ b/user-modules/wprs/default.nix @@ -58,18 +58,18 @@ in commands = entry.value; hostEntries = [ { - name = "Attach"; + name = "Wprs - Attach"; comment = host; exec = "wprs --pulseaudio-forwarding False ${host} attach"; } { - name = "Detach"; + name = "Wprs - Detach"; comment = host; exec = "wprs ${host} detach"; } ]; commandEntries = map (command: { - name = "${command.name}"; + name = "Wprs - ${command.name}"; comment = host; exec = "wprs --pulseaudio-forwarding False ${host} run \"${command.command}\""; }) commands; diff --git a/user-modules/xpra/default.nix b/user-modules/xpra/default.nix new file mode 100644 index 0000000..2653f4e --- /dev/null +++ b/user-modules/xpra/default.nix @@ -0,0 +1,63 @@ +{ + lib, + config, + pkgs, + ... +}: + +with lib; +let + cfg = config.modules.xpra; +in +{ + options.modules.xpra = { + enable = mkEnableOption "Enable xpra"; + hosts = mkOption { + type = types.listOf types.str; + default = { }; + description = "xpra hosts"; + }; + }; + + config = mkIf cfg.enable { + home.packages = with pkgs; [ + xpra + ]; + + xdg.desktopEntries = ( + listToAttrs ( + map + (entry: { + name = "xpra${ + builtins.substring 0 12 (builtins.hashString "sha256" "${entry.name} (${entry.comment})") + }"; + value = entry // { + type = "Application"; + terminal = false; + genericName = entry.comment; + }; + }) + ( + concatMap ( + host: + let + uri = "tcp://${host}:15151/7"; + in + [ + { + name = "Xpra - Attach"; + comment = host; + exec = "xpra attach --min-quality=100 --min-speed=100 --encoding=png --speaker=off ${uri}"; + } + { + name = "Xpra - Detach"; + comment = host; + exec = "xpra detach ${uri}"; + } + ] + ) cfg.hosts + ) + ) + ); + }; +} diff --git a/users/jan.nix b/users/jan.nix index 6ee8d04..4469bcc 100644 --- a/users/jan.nix +++ b/users/jan.nix @@ -24,6 +24,7 @@ inkscape ente-auth bitwarden + carla ]; # desktop.development = "river-light"; @@ -369,11 +370,17 @@ "mixer@10.20.60.251" = [ { name = "Carla"; - command = "carla -platform wayland"; + command = "carla -platform xcb"; } ]; }; }; + xpra = { + enable = true; + hosts = [ + "mixer@10.20.60.251" + ]; + }; # Development neovim.enable = true;