From 0c04a03e26cb8309e04782c5eaabc540233511ce Mon Sep 17 00:00:00 2001 From: Sebastian Moser Date: Sun, 7 Sep 2025 03:41:22 +0200 Subject: [PATCH] streaming from imac now works --- common/nixos-wayland.nix | 72 +++++++++++++++++++---- hosts/fusu.nix | 6 +- hosts/mac.nix | 101 ++++++++++++++++++++++++++++++--- hosts/main.nix | 17 +++--- mods/eGTouch-driver/module.nix | 2 + mods/eGTouch-driver/pkg.nix | 52 +++++++++++++++++ nur.nix | 2 + programs/bash.nix | 7 +++ users/me/gui-home.nix | 10 ++++ 9 files changed, 242 insertions(+), 27 deletions(-) create mode 100644 mods/eGTouch-driver/module.nix create mode 100644 mods/eGTouch-driver/pkg.nix diff --git a/common/nixos-wayland.nix b/common/nixos-wayland.nix index b4ca334..115ca96 100644 --- a/common/nixos-wayland.nix +++ b/common/nixos-wayland.nix @@ -8,7 +8,27 @@ # - win + D command # - kernel output for luks pwd on all displays -{ lib, pkgs, nur, unstable, ... }: { +{ lib, pkgs, nur, unstable, ... }: let + + # use sway from unstable, to have swayfx 0.5.3 to have sway 1.11 to have wlroots 0.19.0 to have ability to share individual windows +mySway = unstable.sway.overrideAttrs (prev: { + /* + src = pkgs.fetchFromGitHub { + owner = "WillPower3309"; + repo = "swayfx"; + rev = ""; + hash = ""; + }; + */ + src = pkgs.fetchFromGitHub { + owner = "swaywm"; + repo = "sway"; + rev = "73c244fb4807a29c6599d42c15e8a8759225b2d6"; + hash = "sha256-P2w1oRVUNBWajt8jZOxPXvBE29urbrhtORy+lfYqnF8="; + }; + }); + +in { services.greetd = { enable = true; @@ -22,7 +42,7 @@ export QT_QPA_PLATFORM=wayland export XDG_CURRENT_DESKTOP=sway export XDG_SESSION_DESKTOP=sway - exec sway + exec ${pkgs.lib.getExe mySway} ''}/bin/run-sway"; user = "me"; }; @@ -30,6 +50,32 @@ }; }; + systemd.user.services.xdg-desktop-portal-wlr.serviceConfig.ExecStart = let + settingsFormat = pkgs.formats.ini { }; + configFile = settingsFormat.generate "xdg-desktop-portal-wlr.ini" { + screencast = { + output_name = "eDP-1"; + + # to make streaming of individual windows work + chooser_type = "dmenu"; + chooser_cmd = "${lib.getExe pkgs.bemenu}"; + }; + }; + package = pkgs.xdg-desktop-portal-wlr.overrideAttrs (prev: { + src = pkgs.fetchFromGitHub { + owner = "emersion"; + repo = "xdg-desktop-portal-wlr"; + rev = "b3703cceea485972b139c22342bdc2ed7b80c1c2"; + sha256 = "sha256-nFAp/9ofRH4kIFgg2SjzZNXYu8r0BBjO5VPFc3jKeas="; + }; + }); + in [ + # Empty ExecStart value to override the field + "" + "${package}/libexec/xdg-desktop-portal-wlr --config=${configFile}" + ]; + + security.rtkit.enable = true; services.pipewire = { enable = true; @@ -48,13 +94,10 @@ default = "wlr"; }; }; - wlr.enable = true; - wlr.settings.screencast = { - output_name = "eDP-1"; - chooser_type = "simple"; - chooser_cmd = "${pkgs.slurp}/bin/slurp -f %o -or"; - }; - extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; + extraPortals = [ + pkgs.xdg-desktop-portal-gtk + pkgs.xdg-desktop-portal-wlr + ]; }; fonts.packages = with pkgs; [ @@ -105,11 +148,12 @@ })) */ + bemenu + xdg-desktop-portal wlr-randr rofi-wayland wev - swayfx wl-clipboard zoxide @@ -285,8 +329,12 @@ ### Key bindings - #bindsym Mod4+Shift+Return exec $term - bindsym $mod exec alacritty + # QuickLaunch + bindsym $mod+i mode "QuickLaunch" + mode QuickLaunch { + bindsym $mod+f exec alacritty; mode "default" + bindsym Escape mode "default" + } bindsym --locked $mod+d exec wlr-randr --output eDP-1 --on bindsym --locked $mod+Shift+d exec wlr-randr --output eDP-1 --off diff --git a/hosts/fusu.nix b/hosts/fusu.nix index 36f289e..32a5638 100644 --- a/hosts/fusu.nix +++ b/hosts/fusu.nix @@ -430,6 +430,10 @@ user = "server"; port = 49388; }; + ocih = { + hostname = "152.67.70.13"; + user = "ubuntu"; + }; }; }; }; @@ -505,7 +509,7 @@ }; path = with pkgs; [ curl bash socat borgbackup openssh ]; serviceConfig = { - ExecStart = "/home/borgs/backups/fusu-ocih.sh"; + ExecStart = "/home/borgs/backups/ocih.sh"; User = "borgs"; Group = "borgs"; WorkingDirectory = "/home/borgs/backups"; diff --git a/hosts/mac.nix b/hosts/mac.nix index 318cbc8..a603c36 100644 --- a/hosts/mac.nix +++ b/hosts/mac.nix @@ -1,4 +1,4 @@ -{ lib, secretsDir, pkgs, inputs, ... }: let +{ lib, secretsDir, pkgs, inputs, unstable, ... }: let myobs = pkgs.wrapOBS { plugins = with pkgs.obs-studio-plugins; [ @@ -22,6 +22,7 @@ in { ../common/nixos-wayland.nix ]; services.tailscale.enable = true; + programs.nix-ld.enable = true; networking.hostName = "mac"; networking.firewall.enable = false; @@ -172,20 +173,56 @@ in { ]; - #services.greetd.enable = lib.mkForce false; services.greetd = lib.mkForce { enable = true; settings = rec { - terminal.vt = 2; - initial_session = { - command = "${pkgs.writeScriptBin "run-sway" '' + terminal.vt = 1; + initial_session = let + + newerUnstableSrc = builtins.getFlake "nixpkgs/d0fc30899600b9b3466ddb260fd83deb486c32f1"; + newerUnstable = import newerUnstableSrc.outPath {}; + + mySway = newerUnstable.sway.override { + sway-unwrapped = (newerUnstable.sway-unwrapped.overrideAttrs (prev: { + /* + src = pkgs.fetchFromGitHub { + owner = "WillPower3309"; + repo = "swayfx"; + rev = ""; + hash = ""; + }; + */ + src = pkgs.fetchFromGitHub { + owner = "swaywm"; + repo = "sway"; + rev = "73c244fb4807a29c6599d42c15e8a8759225b2d6"; + hash = "sha256-P2w1oRVUNBWajt8jZOxPXvBE29urbrhtORy+lfYqnF8="; + }; + })).override { + wlroots = newerUnstable.wlroots.overrideAttrs (prev: { + version = "master"; + src = pkgs.fetchFromGitLab { + domain = "gitlab.freedesktop.org"; + owner = "wlroots"; + repo = "wlroots"; + rev = "master"; + sha256 = "sha256-2FK6FGRpgf/YYqwJST0LVA/pnNRSUDrfrrp6mSwA0Fk="; + }; + + }); + }; + }; + + in { + #command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time -d --env WLR_RENDERER_ALLOW_SOFTWARE=1 --cmd sway"; + command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --cmd ${pkgs.writeScriptBin "run-sway" '' export WLR_RENDERER_ALLOW_SOFTWARE=1 export SDL_VIDEODRIVER=wayland export _JAVA_AWT_WM_NONREPARENTING=1 export QT_QPA_PLATFORM=wayland export XDG_CURRENT_DESKTOP=sway export XDG_SESSION_DESKTOP=sway - exec sway > /tmp/sway-log 2>&1 + exec ${pkgs.lib.getExe mySway} ''}/bin/run-sway"; user = "me"; }; @@ -193,6 +230,56 @@ in { }; }; + systemd.services."sway@" = let + mySway = unstable.sway.overrideAttrs (prev: { + /* + src = pkgs.fetchFromGitHub { + owner = "WillPower3309"; + repo = "swayfx"; + rev = ""; + hash = ""; + }; + */ + src = pkgs.fetchFromGitHub { + owner = "swaywm"; + repo = "sway"; + rev = "73c244fb4807a29c6599d42c15e8a8759225b2d6"; + hash = "sha256-P2w1oRVUNBWajt8jZOxPXvBE29urbrhtORy+lfYqnF8="; + }; + }); + in { + enable = false; + after = [ "systemd-user-sessions.service" "dbus.socket" "systemd-logind.service" "getty@%i.service" "plymouth-deactivate.service" "plymouth-quit.service" ]; + before = [ "graphical.target" ]; + wants = [ "dbus.socket" "systemd-logind.service" "plymouth-deactivate.service" ]; + wantedBy = [ "graphical.target" ]; + conflicts = [ "getty@%i.service" ]; # "plymouth-quit.service" "plymouth-quit-wait.service" + + restartIfChanged = false; + serviceConfig = { + ExecStart = "${lib.getExe mySway}"; + User = "me"; + + # ConditionPathExists = "/dev/tty0"; + IgnoreSIGPIPE = "no"; + + # Log this user with utmp, letting it show up with commands 'w' and + # 'who'. This is needed since we replace (a)getty. + UtmpIdentifier = "%I"; + UtmpMode = "user"; + # A virtual terminal is needed. + TTYPath = "/dev/%I"; + TTYReset = "yes"; + TTYVHangup = "yes"; + TTYVTDisallocate = "yes"; + # Fail to start if not controlling the virtual terminal. + #StandardInput = "tty-fail"; + #StandardOutput = "syslog"; + #StandardError = "syslog"; + # Set up a full (custom) user session for the user, required by Cage. + PAMName = "cage"; + }; + }; systemd.extraConfig = "DefaultLimitNOFILE=2048"; @@ -210,7 +297,7 @@ in { hardware.enableRedistributableFirmware = true; systemd.services."cage@" = { - enable = true; + enable = false; after = [ "systemd-user-sessions.service" "dbus.socket" "systemd-logind.service" "getty@%i.service" "plymouth-deactivate.service" "plymouth-quit.service" ]; before = [ "graphical.target" ]; wants = [ "dbus.socket" "systemd-logind.service" "plymouth-deactivate.service" ]; diff --git a/hosts/main.nix b/hosts/main.nix index 16dc28f..a24ff5b 100644 --- a/hosts/main.nix +++ b/hosts/main.nix @@ -35,6 +35,16 @@ #services.openssh.enable = true; + programs.obs-studio = { + enable = true; + enableVirtualCamera = true; + plugins = with pkgs.obs-studio-plugins; [ + droidcam-obs + obs-ndi + obs-teleport + ]; + }; + # virtual display hardware.display = { @@ -257,13 +267,6 @@ slurp # screenshot functionality wl-clipboard # wl-copy and wl-paste for copy/paste from stdin / stdout mako # notification system developed by swaywm maintainer - (pkgs.wrapOBS { - plugins = with obs-studio-plugins; [ - obs-ndi - obs-teleport - ]; - }) - (writeShellScriptBin "davinci" '' NIXPKGS_ALLOW_UNFREE=1 OCL_ICD_ENABLE_TRACE=True QT_QPA_PLATFORM=xcb nix run nixpkgs#davinci-resolve --impure -L '') diff --git a/mods/eGTouch-driver/module.nix b/mods/eGTouch-driver/module.nix new file mode 100644 index 0000000..0222734 --- /dev/null +++ b/mods/eGTouch-driver/module.nix @@ -0,0 +1,2 @@ +{ pkgs, ... }: { +} diff --git a/mods/eGTouch-driver/pkg.nix b/mods/eGTouch-driver/pkg.nix new file mode 100644 index 0000000..b14daf5 --- /dev/null +++ b/mods/eGTouch-driver/pkg.nix @@ -0,0 +1,52 @@ + +{ stdenv +, fetchurl +, p7zip + +# wether to build the version to be used with Xorg or not Xorg (eg wayland) +, forXorg ? false +, ... +}: let + + nameExtension = ( + if stdenv.isx86_64 or stdenv.isx86_32 + then "x" + else if stdenv.isAarch64 or stdenv.isAarch32 or stdenv.isMips + then "ma" + else builtins.throw "unsupported system" "" + ); + fileName = "eGTouch_v2.5.13219.L-${nameExtension}"; + pathArch = + if stdenv.isAarch64 then "eGTouchAARCH64" + else builtins.throw "unsupported arch..." ""; + pathBackend = + if forXorg then "${pathArch}withX" + else "${pathArch}nonX"; + +in stdenv.mkDerivation rec { + version = "2.5"; + pname = "eGTouch"; + + nativeBuildInputs = [ + p7zip # to unpack the src + ]; + + # there are seperate tarballs... one for x86 and one for arm andmips + src = fetchurl { + url = "https://www.eeti.com/touch_driver/Linux/20240510/${fileName}.7z"; + hash = + if nameExtension == "x" + then "sha256-zZlM4finrnvtxBmqKm4Sl0zQeFz/7yCTuTjXEwmolVI=" + else ""; + }; + + unpackPhase = '' + 7z x $src + ''; + + installPhase = '' + mkdir -p $out/bin + cp ./${fileName}/${pathArch}/${pathBackend}/eGTouch $out/bin + ''; + +} diff --git a/nur.nix b/nur.nix index 881e96c..9deba63 100644 --- a/nur.nix +++ b/nur.nix @@ -14,6 +14,8 @@ in pkgs.lib.attrsets.genAttrs names (name: (pkgs.callPackage "${pwd}/mods/nurPkg imap-backup = pkgs.callPackage ./mods/imap-backup/package.nix {}; + eGTouch = pkgs.callPackage ./mods/eGTouch-driver/pkg.nix {}; + /* fails for nur evaluations iio-hyprland = let repo = pkgs.fetchFromGitHub { diff --git a/programs/bash.nix b/programs/bash.nix index 7a4e179..3dfbc05 100644 --- a/programs/bash.nix +++ b/programs/bash.nix @@ -46,6 +46,8 @@ mize="~/work/mize/mize"; m="~/work/mize/mize"; + c2="~/work/c2-system/target/debug/system-c2-cli"; + ports = "${pkgs.lsof}/bin/lsof -i -P -n"; losetup = "${pkgs.util-linux}/bin/losetup"; u = "sudo umount ~/mnt"; @@ -154,6 +156,11 @@ then xfreerdp /u:"me" /v:192.168.122.141 /p:$(cat /home/me/secrets/win-vm-pwd) /dynamic-resolution +clipboard +auto-reconnect +home-drive /wm-class:"Microsoft Windows"; + elif [[ "$host" == "phone" ]] + then + ssh phone "source ~/.bashrc && on" + ${pkgs.rustdesk}/bin/rustdesk --connect 100.77.80.77 + fi } complete -W "mosatop acern" rp diff --git a/users/me/gui-home.nix b/users/me/gui-home.nix index 4c2604b..ecea2ea 100755 --- a/users/me/gui-home.nix +++ b/users/me/gui-home.nix @@ -14,7 +14,16 @@ ../../programs/zathura.nix ../../programs/firefox/default.nix inputs.lan-mouse.homeManagerModules.default + + "${inputs.vscode-server}/modules/vscode-server/home.nix" ]; + services.vscode-server.enable = true; + + programs.vscode.enable = true; + programs.vscode.extensions = with pkgs.vscode-extensions; [ + ms-vscode-remote.remote-ssh + ms-vscode-remote.remote-ssh-edit + ]; programs.lan-mouse.systemd = true; @@ -81,6 +90,7 @@ # gui packages + songrec obsidian eog xorg.xkbcomp