{...}: final: prev: let inherit (prev) lib stdenv; version = "1.37.0"; sources = { x86_64-linux = { target = "x86_64-unknown-linux-gnu"; hash = "sha256-qoBCt5ReDxACdvAcIoOAOaUMw65s0R/g8eDu+5AMIGc="; }; aarch64-linux = { target = "aarch64-unknown-linux-gnu"; hash = "sha256-iGvQVvwWKsoRXBVugClyyTzlJYNspzDoGZJtK6LcOTA="; }; x86_64-darwin = { target = "x86_64-apple-darwin"; hash = "sha256-elONn7u9ATFvPZYSssEj/o5Nwc1vZTxeO0soEGvpk7s="; }; aarch64-darwin = { target = "aarch64-apple-darwin"; hash = "sha256-2L81shQh+4JH7DAL+dmAXkqeD5mfMKyI0vMLOIEXTXI="; }; }; source = sources.${stdenv.hostPlatform.system} or (throw "goose-ai is unsupported on ${stdenv.hostPlatform.system}"); gooseDesktopRuntimeDependencies = with prev; [ libGL libgbm libxkbcommon vulkan-loader ]; in { goose-ai = stdenv.mkDerivation { pname = "goose-ai"; inherit version; src = prev.fetchurl { url = "https://github.com/aaif-goose/goose/releases/download/v${version}/goose-${source.target}.tar.bz2"; inherit (source) hash; }; sourceRoot = "."; nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [ prev.autoPatchelfHook ]; buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ stdenv.cc.cc.lib ]; installPhase = '' runHook preInstall install -Dm755 goose $out/bin/goose runHook postInstall ''; meta = { description = "Open source, extensible AI agent CLI"; homepage = "https://github.com/aaif-goose/goose"; license = lib.licenses.asl20; mainProgram = "goose"; platforms = builtins.attrNames sources; }; }; # The desktop bundle also contains `goosed`, the agent server used by the # mobile tunnel API. Keep the CLI package above as `goose`; this package's app # launcher is named `goose-desktop` to avoid a Home Manager collision. goose-desktop = stdenv.mkDerivation { pname = "goose-desktop"; inherit version; src = prev.fetchurl { url = "https://github.com/aaif-goose/goose/releases/download/v${version}/goose_${version}_amd64.deb"; hash = "sha256-dkzYCE5ZDNBwJUQ9Kj2ZSkEdfbMZiwDRfGc6WMpYTrA="; }; nativeBuildInputs = [ prev.dpkg prev.autoPatchelfHook prev.makeWrapper ]; buildInputs = with prev; [ alsa-lib at-spi2-atk at-spi2-core atk cairo cups dbus expat gdk-pixbuf glib gtk3 libdrm libgbm libGL libnotify libsecret libuuid libx11 libxcb libxcomposite libxdamage libxext libxfixes libxkbfile libxkbcommon libxrandr libxscrnsaver libxshmfence mesa nspr nss pango stdenv.cc.cc.lib systemd ]; runtimeDependencies = gooseDesktopRuntimeDependencies; dontConfigure = true; dontBuild = true; # `dpkg-deb -x` tries to preserve the setuid bit on chrome-sandbox. Extract # via tar instead and run Electron with --no-sandbox from the wrapper. unpackPhase = '' runHook preUnpack dpkg-deb --fsys-tarfile $src | tar -x --no-same-owner --no-same-permissions runHook postUnpack ''; installPhase = '' runHook preInstall mkdir -p $out/bin $out/lib $out/share cp -r usr/lib/goose $out/lib/ cp -r usr/share/doc $out/share/ cp -r usr/share/pixmaps $out/share/ install -Dm644 usr/share/applications/goose.desktop \ $out/share/applications/goose.desktop substituteInPlace $out/share/applications/goose.desktop \ --replace-fail "Exec=/usr/lib/goose/Goose %U" "Exec=$out/bin/goose-desktop %U" \ --replace-fail "Icon=/usr/share/pixmaps/goose.png" "Icon=$out/share/pixmaps/goose.png" makeWrapper $out/lib/goose/Goose $out/bin/goose-desktop \ --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath gooseDesktopRuntimeDependencies}" \ --prefix PATH : "$out/lib/goose/resources/bin:${lib.makeBinPath [prev.glib prev.xdg-utils]}" \ --add-flags "--no-sandbox" makeWrapper $out/lib/goose/resources/bin/goosed $out/bin/goosed \ --prefix PATH : "$out/lib/goose/resources/bin:${lib.makeBinPath [prev.glib prev.xdg-utils]}" runHook postInstall ''; meta = { description = "Open source, extensible AI agent desktop app"; homepage = "https://github.com/aaif-goose/goose"; license = lib.licenses.asl20; sourceProvenance = with lib.sourceTypes; [binaryNativeCode]; mainProgram = "goose-desktop"; platforms = ["x86_64-linux"]; }; }; }