From 6d7e7b4f56553c8cd62d759895122ed5145746e9 Mon Sep 17 00:00:00 2001 From: paumr Date: Fri, 29 Nov 2024 20:17:42 +0100 Subject: [PATCH] archi: build from source --- pkgs/tools/misc/archi/default.nix | 99 +++++++++++++++---------------- pkgs/tools/misc/archi/update.sh | 25 -------- 2 files changed, 49 insertions(+), 75 deletions(-) delete mode 100755 pkgs/tools/misc/archi/update.sh diff --git a/pkgs/tools/misc/archi/default.nix b/pkgs/tools/misc/archi/default.nix index 500edebad94c6..d29ec9c8f730f 100644 --- a/pkgs/tools/misc/archi/default.nix +++ b/pkgs/tools/misc/archi/default.nix @@ -1,34 +1,29 @@ -{ lib, stdenv -, fetchurl +{ lib +, stdenv +, fetchFromGitHub , autoPatchelfHook -, makeWrapper -, jdk -, libsecret +, stripJavaArchivesHook +, maven +, jre , glib -, webkitgtk_4_0 -, wrapGAppsHook3 -, _7zz +, libsecret +, webkitgtk_4_1 +, makeWrapper , nixosTests }: -stdenv.mkDerivation rec { - pname = "Archi"; +maven.buildMavenPackage rec { + pname = "archi"; version = "5.4.3"; - src = { - "x86_64-linux" = fetchurl { - url = "https://www.archimatetool.com/downloads/archi/${version}/Archi-Linux64-${version}.tgz"; - hash = "sha256-95pm7WMzc25Gbtc73k+z8AJywJg6i6+/YTsx1DaA7sc="; - }; - "x86_64-darwin" = fetchurl { - url = "https://www.archimatetool.com/downloads/archi/${version}/Archi-Mac-${version}.dmg"; - hash = "sha256-Y97wMwza0jR6cxWqnUIjQBvstLtz78QhRA84eQKqk4c="; - }; - "aarch64-darwin" = fetchurl { - url = "https://www.archimatetool.com/downloads/archi/${version}/Archi-Mac-Silicon-${version}.dmg"; - hash = "sha256-Wd3OXMWufs03RyhUkkvoMKG2wI1q40MWaTTkrzio4Is="; - }; - }.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); + src = fetchFromGitHub { + owner = "archimatetool"; + repo = "archi"; + rev = "release_${version}"; + hash = "sha256-+Tl7SyxwoffqlYdQSArDILimPDUWW4lnEpwkCO5OQ3I="; + }; + + mvnHash = "sha256-Bx+Nw4fGQoLr7+flrxPzxiPJC5fr6z3dr/hnlZ553JE="; buildInputs = [ libsecret @@ -36,36 +31,42 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ makeWrapper - wrapGAppsHook3 - ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ - _7zz - ] ++ lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook + stripJavaArchivesHook + ]; + + mvnParameters = lib.escapeShellArgs [ + "-Pproduct" + "-Dproject.build.outputTimestamp=1980-01-01T00:00:02Z" ]; - sourceRoot = if stdenv.hostPlatform.isDarwin then "." else null; + installPhase = '' + p_sys=${if stdenv.hostPlatform.isLinux then "linux/gtk" else "macosx/cocoa"} + p_arch=${if stdenv.hostPlatform.isx86 then "x86_64" else "aarch64"} + p_postfix=${if stdenv.hostPlatform.isLinux then "Archi" else ""} + + cd com.archimatetool.editor.product/target/products/com.archimatetool.editor.product/$p_sys/$p_arch/$p_postfix/ + + '' + (if stdenv.hostPlatform.isLinux then + '' + mkdir -p $out/bin $out/share $out/libexec - installPhase = - if stdenv.hostPlatform.system == "x86_64-linux" then - '' - mkdir -p $out/bin $out/libexec - for f in configuration features p2 plugins Archi.ini; do - cp -r $f $out/libexec - done - install -D -m755 Archi $out/libexec/Archi - makeWrapper $out/libexec/Archi $out/bin/Archi \ - --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath ([ glib webkitgtk_4_0 ])} \ - --set WEBKIT_DISABLE_DMABUF_RENDERER 1 \ - --prefix PATH : ${jdk}/bin - '' - else - '' - mkdir -p "$out/Applications" - mv Archi.app "$out/Applications/" - ''; + for f in configuration features p2 plugins Archi.ini; do + cp -r $f $out/libexec + done - passthru.updateScript = ./update.sh; + install -D -m755 Archi $out/libexec/Archi + makeWrapper $out/libexec/Archi $out/bin/Archi \ + --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath ([ glib webkitgtk_4_1 ])} \ + --set WEBKIT_DISABLE_DMABUF_RENDERER 1 \ + --prefix PATH : ${jre}/bin + '' + else + '' + mkdir -p "$out/Applications" + mv Archi.app "$out/Applications/" + ''); passthru.tests = { inherit (nixosTests) archi; }; @@ -76,9 +77,7 @@ stdenv.mkDerivation rec { models and sketches. ''; homepage = "https://www.archimatetool.com/"; - sourceProvenance = with sourceTypes; [ binaryNativeCode ]; license = licenses.mit; - platforms = platforms.linux ++ platforms.darwin; maintainers = with maintainers; [ earldouglas paumr ]; mainProgram = "Archi"; }; diff --git a/pkgs/tools/misc/archi/update.sh b/pkgs/tools/misc/archi/update.sh deleted file mode 100755 index d405a188d3d09..0000000000000 --- a/pkgs/tools/misc/archi/update.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env nix-shell -#!nix-shell -i bash -p curl jq coreutils common-updater-scripts - -latestVersion=$(curl "https://api.github.com/repos/archimatetool/archi/tags" | jq -r '.[0].name' | tail -c +9) -currentVersion=$(nix-instantiate --eval -E "with import ./. {}; archi.version or (lib.getVersion archi)" | tr -d '"') - -echo "latest version: $latestVersion" -echo "current version: $currentVersion" - -if [[ "$latestVersion" == "$currentVersion" ]]; then - echo "package is up-to-date" - exit 0 -fi - -for i in \ - "aarch64-darwin Archi-Mac-Silicon-$latestVersion.dmg" \ - "x86_64-darwin Archi-Mac-$latestVersion.dmg" \ - "x86_64-linux Archi-Linux64-$latestVersion.tgz" -do - set -- $i - prefetch=$(nix-prefetch-url https://www.archimatetool.com/downloads/archi/$latestVersion/$2) - hash=$(nix-hash --type sha256 --to-sri $prefetch) - - update-source-version archi $latestVersion $hash --system=$1 --ignore-same-version -done