mucommander: convert to gradle setup hook

This commit is contained in:
chayleaf 2023-12-15 12:07:02 +07:00
parent 7b1a794bc2
commit e7aa9a3aeb
No known key found for this signature in database
GPG Key ID: 78171AD46227E68E
2 changed files with 1078 additions and 65 deletions

View File

@ -2,20 +2,22 @@
, stdenv , stdenv
, fetchFromGitHub , fetchFromGitHub
, gradle_7 , gradle_7
, perl
, makeWrapper , makeWrapper
, writeText
, jdk , jdk
, gsettings-desktop-schemas , gsettings-desktop-schemas
}: }:
let let
gradle = gradle_7;
in
stdenv.mkDerivation (finalAttrs: {
pname = "mucommander";
version = "1.3.0-1"; version = "1.3.0-1";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "mucommander"; owner = "mucommander";
repo = "mucommander"; repo = "mucommander";
rev = version; rev = finalAttrs.version;
sha256 = "sha256-rSHHv96L2EHQuKBSAdpfi1XGP2u9o2y4g1+65FHWFMw="; sha256 = "sha256-rSHHv96L2EHQuKBSAdpfi1XGP2u9o2y4g1+65FHWFMw=";
}; };
@ -23,72 +25,19 @@ let
# there is no .git anyway # there is no .git anyway
substituteInPlace build.gradle \ substituteInPlace build.gradle \
--replace "git = grgit.open(dir: project.rootDir)" "" \ --replace "git = grgit.open(dir: project.rootDir)" "" \
--replace "id 'org.ajoberstar.grgit' version '3.1.1'" "" \ --replace "revision = git.head().id" "revision = '${finalAttrs.version}'"
--replace "revision = git.head().id" "revision = '${version}'"
''; '';
# fake build to pre-download deps into fixed-output derivation nativeBuildInputs = [ gradle makeWrapper ];
deps = stdenv.mkDerivation {
pname = "mucommander-deps"; mitmCache = gradle.fetchDeps {
inherit version src postPatch; inherit (finalAttrs) pname;
nativeBuildInputs = [ gradle_7 perl ]; data = ./deps.json;
buildPhase = ''
export GRADLE_USER_HOME=$(mktemp -d)
gradle --no-daemon tgz
'';
# perl code mavenizes pathes (com.squareup.okio/okio/1.13.0/a9283170b7305c8d92d25aff02a6ab7e45d06cbe/okio-1.13.0.jar -> com/squareup/okio/okio/1.13.0/okio-1.13.0.jar)
# reproducible by sorting
installPhase = ''
find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(jar\|pom\)' \
| LC_ALL=C sort \
| perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \
| sh
# copy maven-metadata.xml for commons-codec
# thankfully there is only one xml
cp $GRADLE_USER_HOME/caches/modules-2/resources-2.1/*/*/maven-metadata.xml $out/commons-codec/commons-codec/maven-metadata.xml
'';
outputHashAlgo = "sha256";
outputHashMode = "recursive";
outputHash = "sha256-9tCcUg7hDNbkZiQEWtVRsUUfms73aU+vt5tQsfknM+E=";
}; };
in __darwinAllowLocalNetworking = true;
stdenv.mkDerivation rec {
pname = "mucommander";
inherit version src postPatch;
nativeBuildInputs = [ gradle_7 perl makeWrapper ];
# Point to our local deps repo gradleBuildTask = "tgz";
gradleInit = writeText "init.gradle" ''
logger.lifecycle 'Replacing Maven repositories with ${deps}...'
gradle.projectsLoaded {
rootProject.allprojects {
buildscript {
repositories {
clear()
maven { url '${deps}' }
}
}
repositories {
clear()
maven { url '${deps}' }
}
}
}
settingsEvaluated { settings ->
settings.pluginManagement {
repositories {
maven { url '${deps}' }
}
}
}
'';
buildPhase = ''
export GRADLE_USER_HOME=$(mktemp -d)
gradle --offline --init-script ${gradleInit} --no-daemon tgz
'';
installPhase = '' installPhase = ''
mkdir -p $out/share/mucommander mkdir -p $out/share/mucommander
@ -107,4 +56,4 @@ stdenv.mkDerivation rec {
platforms = platforms.all; platforms = platforms.all;
mainProgram = "mucommander"; mainProgram = "mucommander";
}; };
} })

File diff suppressed because it is too large Load Diff