Skip to content

Commit 83d8edb

Browse files
committed
signald: convert to gradle setup hook
1 parent 6d3d966 commit 83d8edb

File tree

4 files changed

+546
-184
lines changed

4 files changed

+546
-184
lines changed

pkgs/applications/networking/instant-messengers/signald/0001-Fetch-buildconfig-during-gradle-build-inside-Nix-FOD.patch

Lines changed: 0 additions & 42 deletions
This file was deleted.

pkgs/applications/networking/instant-messengers/signald/0002-buildconfig-local-deps-fixes.patch

Lines changed: 0 additions & 71 deletions
This file was deleted.
Lines changed: 18 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
{ lib, stdenv, fetchFromGitLab, jdk17_headless, coreutils, findutils, gnused,
2-
gradle, git, perl, makeWrapper, substituteAll, jre_minimal
2+
gradle, git, makeWrapper, jre_minimal
33
}:
44

5-
# NOTE: when updating the package, please check if some of the hacks in `deps.installPhase`
6-
# can be removed again!
7-
85
let
96
pname = "signald";
107
version = "0.23.2";
@@ -16,8 +13,6 @@ let
1613
sha256 = "sha256-EofgwZSDp2ZFhlKL2tHfzMr3EsidzuY4pkRZrV2+1bA=";
1714
};
1815

19-
gradleWithJdk = gradle.override { java = jdk17_headless; };
20-
2116
jre' = jre_minimal.override {
2217
jdk = jdk17_headless;
2318
# from https://gitlab.com/signald/signald/-/blob/0.23.0/build.gradle#L173
@@ -37,76 +32,19 @@ let
3732
];
3833
};
3934

40-
# fake build to pre-download deps into fixed-output derivation
41-
deps = stdenv.mkDerivation {
42-
pname = "${pname}-deps";
43-
inherit src version;
44-
nativeBuildInputs = [ gradleWithJdk perl ];
45-
patches = [ ./0001-Fetch-buildconfig-during-gradle-build-inside-Nix-FOD.patch ];
46-
buildPhase = ''
47-
export GRADLE_USER_HOME=$(mktemp -d)
48-
gradle --no-daemon build
49-
'';
50-
installPhase = ''
51-
find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(jar\|pom\)' \
52-
| perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \
53-
| sh -x
54-
55-
# WARNING: don't try this at home and wear safety-goggles while working with this!
56-
# We patch around in the dependency tree to resolve some spurious dependency resolution errors.
57-
# Whenever this package gets updated, please check if some of these hacks are obsolete!
58-
59-
# Mimic existence of okio-3.2.0.jar. Originally known as okio-jvm-3.2.0 (and renamed),
60-
# but gradle doesn't detect such renames, only fetches the latter and then fails
61-
# in `signald.buildPhase` because it cannot find `okio-3.2.0.jar`.
62-
pushd $out/com/squareup/okio/okio/3.2.0 &>/dev/null
63-
cp -v ../../okio-jvm/3.2.0/okio-jvm-3.2.0.jar okio-3.2.0.jar
64-
popd &>/dev/null
65-
66-
# For some reason gradle fetches 2.14.1 instead of 2.14.0 here even though 2.14.0 is required
67-
# according to `./gradlew -q dependencies`, so we pretend to have 2.14.0 available here.
68-
# According to the diff in https://github.com/FasterXML/jackson-dataformats-text/compare/jackson-dataformats-text-2.14.0...jackson-dataformats-text-2.14.1
69-
# the only relevant change is in the code itself (and in the tests/docs), so this seems
70-
# binary-compatible.
71-
cp -v \
72-
$out/com/fasterxml/jackson/dataformat/jackson-dataformat-toml/2.14.1/jackson-dataformat-toml-2.14.1.jar \
73-
$out/com/fasterxml/jackson/dataformat/jackson-dataformat-toml/2.14.0/jackson-dataformat-toml-2.14.0.jar
74-
'';
75-
# Don't move info to share/
76-
forceShare = [ "dummy" ];
77-
outputHashAlgo = "sha256";
78-
outputHashMode = "recursive";
79-
# Downloaded jars differ by platform
80-
outputHash = {
81-
x86_64-linux = "sha256-9DHykkvazVBN2kfw1Pbejizk/R18v5w8lRBHZ4aXL5Q=";
82-
aarch64-linux = "sha256-RgAiRbUojBc+9RN/HpAzzpTjkjZ6q+jebDsqvah5XBw=";
83-
}.${stdenv.system} or (throw "Unsupported system: ${stdenv.system}");
84-
};
85-
8635
in stdenv.mkDerivation {
8736
inherit pname src version;
8837

89-
patches = [
90-
(substituteAll {
91-
src = ./0002-buildconfig-local-deps-fixes.patch;
92-
inherit deps;
93-
})
94-
];
95-
96-
passthru = {
97-
# Mostly for debugging purposes.
98-
inherit deps;
38+
mitmCache = gradle.fetchDeps {
39+
inherit pname;
40+
data = ./deps.json;
9941
};
10042

101-
buildPhase = ''
102-
runHook preBuild
103-
104-
export GRADLE_USER_HOME=$(mktemp -d)
43+
__darwinAllowLocalNetworking = true;
10544

106-
gradle --offline --no-daemon distTar
45+
gradleFlags = [ "-Dorg.gradle.java.home=${jdk17_headless}" ];
10746

108-
runHook postBuild
109-
'';
47+
gradleBuildTask = "distTar";
11048

11149
installPhase = ''
11250
runHook preInstall
@@ -120,10 +58,19 @@ in stdenv.mkDerivation {
12058
runHook postInstall
12159
'';
12260

123-
nativeBuildInputs = [ git gradleWithJdk makeWrapper ];
61+
nativeBuildInputs = [ git gradle makeWrapper ];
12462

12563
doCheck = true;
12664

65+
gradleUpdateScript = ''
66+
runHook preBuild
67+
68+
SIGNALD_TARGET=x86_64-unknown-linux-gnu gradle nixDownloadDeps
69+
SIGNALD_TARGET=aarch64-unknown-linux-gnu gradle nixDownloadDeps
70+
SIGNALD_TARGET=x86_64-apple-darwin gradle nixDownloadDeps
71+
SIGNALD_TARGET=aarch64-apple-darwin gradle nixDownloadDeps
72+
'';
73+
12774
meta = with lib; {
12875
description = "Unofficial daemon for interacting with Signal";
12976
longDescription = ''
@@ -138,6 +85,6 @@ in stdenv.mkDerivation {
13885
];
13986
license = licenses.gpl3Plus;
14087
maintainers = with maintainers; [ expipiplus1 ];
141-
platforms = [ "x86_64-linux" "aarch64-linux" ];
88+
platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
14289
};
14390
}

0 commit comments

Comments
 (0)