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..3d513b1 --- /dev/null +++ b/flake.nix @@ -0,0 +1,86 @@ +{ + 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; }; + 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"; + 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/ + 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 <