diff --git a/overlays/computer-use-linux.nix b/overlays/computer-use-linux.nix new file mode 100644 index 00000000..f67d3d12 --- /dev/null +++ b/overlays/computer-use-linux.nix @@ -0,0 +1,3 @@ +_: _final: prev: { + computer-use-linux = prev.callPackage ../pkgs/computer-use-linux { }; +} diff --git a/overlays/cua-driver.nix b/overlays/cua-driver.nix new file mode 100644 index 00000000..1af0d79d --- /dev/null +++ b/overlays/cua-driver.nix @@ -0,0 +1,3 @@ +_: _final: prev: { + cua-driver = prev.callPackage ../pkgs/cua-driver { }; +} diff --git a/pkgs/computer-use-linux/default.nix b/pkgs/computer-use-linux/default.nix new file mode 100644 index 00000000..0612c4ef --- /dev/null +++ b/pkgs/computer-use-linux/default.nix @@ -0,0 +1,56 @@ +{ + lib, + stdenv, + fetchurl, + autoPatchelfHook, +}: +let + version = "0.7.1"; + + # Prebuilt release binaries; the crate is not packaged in nixpkgs. + assets = { + x86_64-linux = { + target = "x86_64-unknown-linux-gnu"; + hash = "sha256-Wp91gQrUKBjIoxIeEsRug4MYgZ6o6bcaDJoqq+RmmbQ="; + }; + aarch64-linux = { + target = "aarch64-unknown-linux-gnu"; + hash = "sha256-e376naC15EyNGfDN3ERTmvCPzd97v7WPzzVYq4zCjps="; + }; + }; + + asset = + assets.${stdenv.hostPlatform.system} + or (throw "computer-use-linux: unsupported system ${stdenv.hostPlatform.system}"); +in +stdenv.mkDerivation { + pname = "computer-use-linux"; + inherit version; + + src = fetchurl { + url = "https://github.com/agent-sh/computer-use-linux/releases/download/v${version}/computer-use-linux-${asset.target}"; + inherit (asset) hash; + }; + + nativeBuildInputs = [ autoPatchelfHook ]; + buildInputs = [ stdenv.cc.cc.lib ]; + + dontUnpack = true; + + installPhase = '' + runHook preInstall + install -Dm755 $src $out/bin/computer-use-linux + runHook postInstall + ''; + + meta = { + description = "MCP server and CLI to control a Linux desktop"; + homepage = "https://github.com/agent-sh/computer-use-linux"; + license = lib.licenses.mit; + platforms = [ + "x86_64-linux" + "aarch64-linux" + ]; + mainProgram = "computer-use-linux"; + }; +} diff --git a/pkgs/cua-driver/default.nix b/pkgs/cua-driver/default.nix new file mode 100644 index 00000000..f6c66165 --- /dev/null +++ b/pkgs/cua-driver/default.nix @@ -0,0 +1,55 @@ +{ + lib, + stdenv, + fetchurl, + autoPatchelfHook, + libxkbcommon, + xorg, +}: +let + version = "0.24.0"; + + # Prebuilt release binary; the crate is not packaged in nixpkgs. + asset = { + url = "https://github.com/trycua/cua/releases/download/cua-driver-rs-v${version}/cua-driver-rs-${version}-linux-x86_64-binary.tar.gz"; + hash = "sha256-s7j/Ullf6xESGaoKyQ47NmGMxoaqggWu1PPn4aZ8e2Q="; + }; +in +stdenv.mkDerivation { + pname = "cua-driver"; + inherit version; + + src = fetchurl asset; + + nativeBuildInputs = [ autoPatchelfHook ]; + buildInputs = [ + stdenv.cc.cc.lib + xorg.libX11 + xorg.libXi + libxkbcommon + ]; + + sourceRoot = "."; + dontConfigure = true; + dontBuild = true; + + installPhase = '' + runHook preInstall + install -Dm755 cua-driver $out/bin/cua-driver + install -Dm755 cua-cursor-theme $out/lib/cua-driver/cua-cursor-theme + install -Dm755 libcua_driver_sdk.so $out/lib/cua-driver/libcua_driver_sdk.so + install -Dm755 cua_driver_node_runtime.node $out/lib/cua-driver/cua_driver_node_runtime.node + install -Dm644 cua_driver_abi.h $out/include/cua-driver/cua_driver_abi.h + mkdir -p $out/share/cua-driver + cp -r wayland-helper $out/share/cua-driver/wayland-helper + runHook postInstall + ''; + + meta = { + description = "Desktop-automation driver for computer-use agents (MCP/CLI)"; + homepage = "https://github.com/trycua/cua"; + license = lib.licenses.mit; + platforms = [ "x86_64-linux" ]; + mainProgram = "cua-driver"; + }; +}