From 812646625eccb22da811679b45af9e677547b7db Mon Sep 17 00:00:00 2001 From: Reasel Date: Tue, 10 Nov 2026 10:52:25 -0800 Subject: [PATCH 1/2] Add NixOS flake for OpenMouse Bridge --- README.md | 2 ++ flake.lock | 27 +++++++++++++++++++ flake.nix | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/games.rs | 5 +++- 4 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/README.md b/README.md index 024d042..e08d532 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,8 @@ On Linux, install the system libraries for the window first (Ubuntu 22.04 or sudo apt-get update && sudo apt-get install -y build-essential clang cmake pkg-config libudev-dev libssl-dev libwayland-dev libxkbcommon-dev libxkbcommon-x11-dev libx11-xcb-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libvulkan-dev libgl1-mesa-dev libfontconfig-dev libfreetype-dev libasound2-dev ``` +NixOS users can build and run Bridge with `nix run` from this checkout (or `nix run github:OpenMouse-Project/openmouse-bridge` after this support is merged). The flake builds against NixOS libraries and exposes the system Vulkan ICD. HID access still needs a udev rule; see the installer help and configure the rule declaratively in NixOS. + Linux notes: the tray uses StatusNotifierItem/DBusMenu on the session bus (KDE Plasma and other compatible hosts; GNOME needs an AppIndicator/SNI extension). It shows the battery glyph, charge colour and the same battery diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..14c839e --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1794042290, + "narHash": "sha256-ziZn2PvCJE5JEEpqTdxXwJpPB+L3YqoCpTAMCzyaP3U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f4a03c008967841f2a0b3cb7c436fc6fc31671f6", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..b1bebb2 --- /dev/null +++ b/flake.nix @@ -0,0 +1,73 @@ +{ + description = "OpenMouse Bridge for NixOS"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + outputs = { self, nixpkgs }: + let + systems = [ "x86_64-linux" "aarch64-linux" ]; + eachSystem = nixpkgs.lib.genAttrs systems; + in { + packages = eachSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + bridge = pkgs.rustPlatform.buildRustPackage { + pname = "openmouse-bridge"; + version = "1.0.0"; + src = self; + cargoLock.lockFile = ./Cargo.lock; + nativeBuildInputs = with pkgs; [ pkg-config cmake clang makeWrapper ]; + buildInputs = with pkgs; [ + openssl systemd wayland libxkbcommon + libX11 libxcb libGL fontconfig freetype alsa-lib vulkan-loader + ]; + preCheck = '' + export OPENMOUSE_TEST_SLEEP=${pkgs.coreutils}/bin/sleep + ''; + postInstall = '' + mkdir -p $out/bin/native-hid $out/share/openmouse-bridge $out/share/icons/hicolor/512x512/apps $out/share/applications + cp -r ${self}/native-hid/. $out/bin/native-hid/ + mkdir -p $out/bin/native-hid/node/bin + cp -r ${self}/assets/. $out/share/openmouse-bridge/ + ln -s ${pkgs.nodejs_24}/bin/node $out/bin/native-hid/node/bin/node + cp ${self}/assets/openmouse-app-icon.png $out/share/icons/hicolor/512x512/apps/io.openmouse.bridge.png + cat > $out/share/applications/io.openmouse.bridge.desktop <<'DESKTOP' + [Desktop Entry] + Type=Application + Name=OpenMouse Bridge + Comment=Local companion for the OpenMouse control panel + Exec=$out/bin/openmouse-bridge + Icon=io.openmouse.bridge + Categories=Utility; + Terminal=false + DESKTOP + wrapProgram $out/bin/openmouse-bridge \ + --prefix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath [ + pkgs.systemd pkgs.wayland pkgs.libxkbcommon + pkgs.libX11 pkgs.libxcb pkgs.libGL pkgs.fontconfig pkgs.freetype + pkgs.alsa-lib pkgs.vulkan-loader + ]} \ + --prefix XDG_DATA_DIRS : /run/opengl-driver/share + ''; + nativeHID = null; + meta = with pkgs.lib; { + description = "Local native HID and desktop companion for OpenMouse"; + homepage = "https://openmouse.app/"; + license = licenses.mit; + platforms = platforms.linux; + mainProgram = "openmouse-bridge"; + }; + }; + in { + default = bridge; + openmouse-bridge = bridge; + }); + + apps = eachSystem (system: { + default = { + type = "app"; + program = "${self.packages.${system}.default}/bin/openmouse-bridge"; + }; + }); + }; +} diff --git a/src/games.rs b/src/games.rs index 464bb38..3dd7188 100644 --- a/src/games.rs +++ b/src/games.rs @@ -360,7 +360,10 @@ mod tests { let directory = std::env::temp_dir().join(format!("openmouse-wine-{}", std::process::id())); std::fs::create_dir_all(&directory).unwrap(); let loader = directory.join("wine64-preloader"); - std::fs::copy("/bin/sleep", &loader).unwrap(); + let sleep = std::env::var_os("OPENMOUSE_TEST_SLEEP") + .map(std::path::PathBuf::from) + .unwrap_or_else(|| "/bin/sleep".into()); + std::fs::copy(sleep, &loader).unwrap(); let mut child = std::process::Command::new(&loader) .arg0(r"Z:\home\me\Steam\steamapps\common\Overwatch\Overwatch.exe") .arg("30") From c9381c676b4d76a33b47ef1d36476fbb251ce09a Mon Sep 17 00:00:00 2001 From: Reasel Date: Tue, 10 Nov 2026 11:47:11 -0800 Subject: [PATCH 2/2] Package native HID dependencies on NixOS --- flake.nix | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index b1bebb2..3d513b1 100644 --- a/flake.nix +++ b/flake.nix @@ -11,6 +11,18 @@ packages = eachSystem (system: let pkgs = import nixpkgs { inherit system; }; + nativeHid = pkgs.buildNpmPackage { + pname = "openmouse-bridge-native-hid"; + version = "0.1.0"; + src = "${self}/native-hid"; + npmDepsHash = "sha256-JMsspevf1MunaufbYZY2t8kCX6WuxowlFi4wKn/F1Qw="; + makeCacheWritable = true; + forceGitDeps = true; + npmInstallFlags = [ "--ignore-scripts=false" ]; + nativeBuildInputs = with pkgs; [ nodejs_24 pkg-config python3 ]; + buildInputs = with pkgs; [ libusb1 systemd ]; + dontNpmBuild = true; + }; bridge = pkgs.rustPlatform.buildRustPackage { pname = "openmouse-bridge"; version = "1.0.0"; @@ -27,11 +39,12 @@ postInstall = '' mkdir -p $out/bin/native-hid $out/share/openmouse-bridge $out/share/icons/hicolor/512x512/apps $out/share/applications cp -r ${self}/native-hid/. $out/bin/native-hid/ + cp -r ${nativeHid}/lib/node_modules/openmouse-bridge-native-hid/node_modules $out/bin/native-hid/ mkdir -p $out/bin/native-hid/node/bin cp -r ${self}/assets/. $out/share/openmouse-bridge/ ln -s ${pkgs.nodejs_24}/bin/node $out/bin/native-hid/node/bin/node cp ${self}/assets/openmouse-app-icon.png $out/share/icons/hicolor/512x512/apps/io.openmouse.bridge.png - cat > $out/share/applications/io.openmouse.bridge.desktop <<'DESKTOP' + cat > $out/share/applications/io.openmouse.bridge.desktop <