{ lib, buildNpmPackage, fetchFromGitHub, electron_44, makeWrapper, copyDesktopItems, makeDesktopItem, git, nodejs_22, }: buildNpmPackage rec { pname = "purpleflow"; version = "0.3.2"; src = fetchFromGitHub { owner = "PurpleSchool"; repo = "purpleflow"; rev = version; hash = "sha256-KfXWP5XMFPEerb7AazbAwfbwmJ5djqh6X0J3FRjxk88="; }; # npm workspaces (core + app). npmDepsFetcherVersion = 2; npmDepsHash = "sha256-dfbC0y6Ot28crCG4qE4jxzlm5puw8F8zgFpiqc88TLA="; # electron-vite only needs the electron package metadata, not the binary. env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1"; nativeBuildInputs = [ makeWrapper copyDesktopItems ]; desktopItems = [ (makeDesktopItem { name = "purpleflow"; desktopName = "PurpleFlow"; comment = "Run Claude Code and Codex through plan, implementation, review and acceptance stages"; exec = "purpleflow %U"; icon = "purpleflow"; categories = [ "Development" ]; terminal = false; }) ]; # Upstream's packaged build bundles the core into the main process and ships # no node_modules; only out/ and the stage prompts are needed at runtime. installPhase = '' runHook preInstall appRoot=$out/lib/purpleflow mkdir -p $appRoot/app $appRoot/core cp -r app/out $appRoot/app/out cp app/package.json $appRoot/app/package.json cp -r core/prompts $appRoot/core/prompts # app.isPackaged stays false because Electron loads the app directory, as # in `npm run dev`. The main process then resolves prompts as # ../core/prompts from the app directory, which this layout satisfies; the # updater and telemetry are disabled in that mode. makeWrapper ${electron_44}/bin/electron $out/bin/purpleflow \ --add-flags "$appRoot/app" \ --add-flags "--no-sandbox" \ --prefix PATH : ${ lib.makeBinPath [ git nodejs_22 ] } mkdir -p $out/share/icons/hicolor/1024x1024/apps cp app/build/icon.png $out/share/icons/hicolor/1024x1024/apps/purpleflow.png runHook postInstall ''; passthru = { category = "AI Coding Agents"; updateScript = [ "nix-update" "--flake" ".#purpleflow" ]; }; meta = with lib; { description = "Desktop orchestrator that runs Claude Code and Codex through plan, implementation, review and acceptance stages"; homepage = "https://github.com/PurpleSchool/purpleflow"; changelog = "https://github.com/PurpleSchool/purpleflow/releases/tag/${version}"; license = licenses.mit; sourceProvenance = with sourceTypes; [ fromSource ]; mainProgram = "purpleflow"; platforms = platforms.linux; }; }