From ebd79d5ca5ff5e8143770ca43486199260c0d880 Mon Sep 17 00:00:00 2001 From: m3ta-chiron Date: Sun, 11 Oct 2026 14:01:12 +0200 Subject: [PATCH] feat(pkgs): add photocraft 0.7.0 Native buildRustPackage for PhotoCraft, the open-source clean-room Photoshop reimplementation in pure Rust (https://github.com/storytold/photocraft). - builds desktop app + photocraft-cli (convert/batch/MCP) from the v0.7.0 release tag - heif feature enabled for parity with official release builds (pure-Rust heic-rs, no native C deps) - zero buildInputs: the workspace has no native *-sys crates; all windowing/graphics/D-Bus access is dlopen'd at runtime and provided via LD_LIBRARY_PATH (neovide pattern), incl. dbus.lib so rfd's xdg-desktop-portal file dialogs work instead of the zenity fallback - installs upstream .desktop, hicolor icons (16-512 + svg), AppStream metainfo (version/date substituted) and MIME registrations - passthru.updateScript = nix-update-script; verified with 'nix-update -F photocraft' (handles version + src hash + cargoHash) GPU verified on RX 7900 XTX / Wayland after the flake input update. --- pkgs/AGENTS.md | 1 + pkgs/default.nix | 1 + pkgs/photocraft/default.nix | 110 ++++++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 pkgs/photocraft/default.nix diff --git a/pkgs/AGENTS.md b/pkgs/AGENTS.md index d442442..d837776 100644 --- a/pkgs/AGENTS.md +++ b/pkgs/AGENTS.md @@ -10,6 +10,7 @@ Custom package registry using `callPackage` pattern for flake-wide availability. - `launch-webapp/`: Webapp wrapper - `mem0/`: Python package + custom `server.py` - `msty-studio/`: AppImage wrapper +- `photocraft/`: Rust package (Photoshop reimplementation, built from source) - `pomodoro-timer/`: Timer utility - `tuxedo-backlight/`: Hardware control - `zellij-ps/`: Gitea-hosted package diff --git a/pkgs/default.nix b/pkgs/default.nix index 26a466d..96cdd20 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -21,6 +21,7 @@ in { launch-webapp = pkgs.callPackage ./launch-webapp {}; mem0 = pkgs.callPackage ./mem0 {}; msty-studio = pkgs.callPackage ./msty-studio {}; + photocraft = pkgs.callPackage ./photocraft {}; pomodoro-timer = pkgs.callPackage ./pomodoro-timer {}; rofi-project-opener = pkgs.callPackage ./rofi-project-opener {}; stt-ptt = pkgs.callPackage ./stt-ptt {}; diff --git a/pkgs/photocraft/default.nix b/pkgs/photocraft/default.nix new file mode 100644 index 0000000..192ab3d --- /dev/null +++ b/pkgs/photocraft/default.nix @@ -0,0 +1,110 @@ +{ + lib, + rustPlatform, + fetchFromGitHub, + makeWrapper, + nix-update-script, + # Not linked at build time — dlopen'd by the app at runtime (see postFixup). + dbus, + libglvnd, + libx11, + libxcursor, + libxi, + libxrandr, + libxkbcommon, + vulkan-loader, + wayland, +}: let + # PhotoCraft reaches the windowing/graphics stack exclusively through + # dlopen (wayland-sys, x11-dl, ash → libvulkan, glutin → libEGL/libGL): + # Cargo.lock contains no native *-sys crate, so the build needs zero + # buildInputs and these libraries are provided via LD_LIBRARY_PATH instead + # (same pattern as neovide). dbus.lib is dlopen'd by rfd's xdg-desktop-portal + # backend — without it, file dialogs fall back to zenity. + runtimeLibs = [ + dbus.lib + libglvnd + libx11 + libxcursor + libxi + libxrandr + libxkbcommon + vulkan-loader + wayland + ]; +in + rustPlatform.buildRustPackage (finalAttrs: { + pname = "photocraft"; + version = "0.7.0"; + + # AppStream date of the GitHub release — bump together with `version`. + releaseDate = "2026-10-11"; + + src = fetchFromGitHub { + owner = "storytold"; + repo = "photocraft"; + tag = "v${finalAttrs.version}"; + hash = "sha256-XyRDSkGAw1W9kF61nujHkgIR7TkTjrQbbcu+tSxWjXU="; + }; + + cargoHash = "sha256-kpNg04RP5XbtW2rMaXUmGIKRJIqJmi7fmTbs5qHTLto="; + + # Match the official release builds (CI builds with `--features heif`): + # HEIC/HEIF reading via pure-Rust heic-rs — no native C dependency. + # Scoped per binary so the CLI ships the same codec set as the app. + buildFeatures = [ + "photocraft/heif" + "photocraft-cli/heif" + ]; + + # The workspace default also builds xtask; ship only the two user-facing + # binaries (desktop app + headless CLI with batch and MCP support). + cargoBuildFlags = [ + "-p" + "photocraft" + "-p" + "photocraft-cli" + ]; + + # ~260 test binaries, and the corpus tests additionally fetch external + # files (cargo xtask corpus). Skip the suite in the package build. + doCheck = false; + + nativeBuildInputs = [makeWrapper]; + + postInstall = '' + install -Dm644 packaging/linux/ai.storyteller.photocraft.desktop \ + -t $out/share/applications + + mkdir -p $out/share/metainfo + substitute packaging/linux/ai.storyteller.photocraft.metainfo.xml.in \ + $out/share/metainfo/ai.storyteller.photocraft.metainfo.xml \ + --replace-fail @VERSION@ ${finalAttrs.version} \ + --replace-fail @DATE@ ${finalAttrs.releaseDate} + + install -Dm644 packaging/linux/ai.storyteller.photocraft.mime.xml \ + $out/share/mime/packages/ai.storyteller.photocraft.xml + + mkdir -p $out/share/icons + cp -R assets/app-icon/hicolor $out/share/icons + chmod -R u+w $out/share/icons + ''; + + postFixup = '' + wrapProgram $out/bin/photocraft \ + --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath runtimeLibs} + ''; + + # Update with: nix run github:NixOS/nixpkgs#nix-update -- --flake photocraft + # (bumps version, src hash and cargoHash in one run) + passthru.updateScript = nix-update-script {}; + + meta = { + description = "Open-source, clean-room reimplementation of Adobe Photoshop in pure Rust"; + homepage = "https://getartcraft.com/apps/photocraft"; + changelog = "https://github.com/storytold/photocraft/releases/tag/v${finalAttrs.version}"; + license = with lib.licenses; [asl20 mit]; + mainProgram = "photocraft"; + platforms = lib.platforms.linux; + }; + })