]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - pkgs/signald/default.nix
Add signal
[perso/Immae/Config/Nix.git] / pkgs / signald / default.nix
CommitLineData
a3ef18ac
IB
1{ lib, stdenv, fetchurl, fetchgit, jre, coreutils, gradle_6, git, perl
2, makeWrapper }:
3
4let
5 pname = "signald";
6
7 version = "0.13.1";
8
9 # This package uses the .git directory
10 src = fetchgit {
11 url = "https://gitlab.com/signald/signald";
12 rev = version;
13 sha256 = "1ilmg0i1kw2yc7m3hxw1bqdpl3i9wwbj8623qmz9cxhhavbcd5i7";
14 leaveDotGit = true;
15 };
16
17 buildConfigJar = fetchurl {
18 url = "https://dl.bintray.com/mfuerstenau/maven/gradle/plugin/de/fuerstenau/BuildConfigPlugin/1.1.8/BuildConfigPlugin-1.1.8.jar";
19 sha256 = "0y1f42y7ilm3ykgnm6s3ks54d71n8lsy5649xgd9ahv28lj05x9f";
20 };
21
22 patches = [ ./git-describe-always.patch ./gradle-plugin.patch ];
23
24 postPatch = ''
25 patchShebangs gradlew
26 sed -i -e 's|BuildConfig.jar|${buildConfigJar}|' build.gradle
27 '';
28
29 # fake build to pre-download deps into fixed-output derivation
30 deps = stdenv.mkDerivation {
31 name = "${pname}-deps";
32 inherit src version postPatch patches;
33 nativeBuildInputs = [ gradle_6 perl ];
34 buildPhase = ''
35 export GRADLE_USER_HOME=$(mktemp -d)
36 gradle --no-daemon build
37 '';
38 # 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)
39 installPhase = ''
40 find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(jar\|pom\)' \
41 | perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/''${\($5 =~ s/-jvm//r)}" #e' \
42 | sh
43 '';
44 # Don't move info to share/
45 forceShare = [ "dummy" ];
46 outputHashAlgo = "sha256";
47 outputHashMode = "recursive";
48 outputHash = "0w8ixp1l0ch1jc2dqzxdx3ljlh17hpgns2ba7qvj43nr4prl71l7";
49 };
50
51in stdenv.mkDerivation rec {
52 inherit pname src version postPatch patches;
53
54 buildPhase = ''
55 export GRADLE_USER_HOME=$(mktemp -d)
56
57 # Use the local packages from -deps
58 sed -i -e 's|mavenCentral()|mavenLocal(); maven { url uri("${deps}") }|' build.gradle
59
60 gradle --offline --no-daemon distTar
61 '';
62
63 installPhase = ''
64 mkdir -p $out
65 tar xvf ./build/distributions/signald.tar --strip-components=1 --directory $out/
66 wrapProgram $out/bin/signald \
67 --prefix PATH : ${lib.makeBinPath [ coreutils ]} \
68 --set JAVA_HOME "${jre}"
69 '';
70
71 nativeBuildInputs = [ git gradle_6 makeWrapper ];
72
73 doCheck = true;
74
75 meta = with lib; {
76 description = "Unofficial daemon for interacting with Signal";
77 longDescription = ''
78 Signald is a daemon that facilitates communication over Signal. It is
79 unofficial, unapproved, and not nearly as secure as the real Signal
80 clients.
81 '';
82 homepage = "https://signald.org";
83 license = licenses.gpl3Plus;
84 maintainers = with maintainers; [ expipiplus1 ];
85 platforms = platforms.unix;
86 };
87}