From a3ef18acd6c73b943f9f54e618f9e72e017ff748 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 17 May 2021 15:10:49 +0200 Subject: [PATCH] Add signal --- environments/immae-eu.nix | 1 + pkgs/default.nix | 2 + pkgs/signald/default.nix | 87 ++++++++++++++++++++++++++ pkgs/signald/git-describe-always.patch | 9 +++ pkgs/signald/gradle-plugin.patch | 26 ++++++++ pkgs/signaldctl/default.nix | 13 ++++ 6 files changed, 138 insertions(+) create mode 100644 pkgs/signald/default.nix create mode 100644 pkgs/signald/git-describe-always.patch create mode 100644 pkgs/signald/gradle-plugin.patch create mode 100644 pkgs/signaldctl/default.nix diff --git a/environments/immae-eu.nix b/environments/immae-eu.nix index 7a52a28..f54e876 100644 --- a/environments/immae-eu.nix +++ b/environments/immae-eu.nix @@ -60,6 +60,7 @@ let # messaging/forums/news flrn slrn + signal-cli signaldctl telegram-cli telegram-history-dump telegramircd weechat profanity newsboat irssi diff --git a/pkgs/default.nix b/pkgs/default.nix index fcc92d1..25ff9d7 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -28,6 +28,8 @@ rec { pgloader = callPackage ./pgloader {}; predixy = callPackage ./predixy { inherit mylibs; }; rrsync_sudo = callPackage ./rrsync_sudo {}; + signald = callPackage ./signald {}; + signaldctl = callPackage ./signaldctl {}; telegram-cli = callPackage ./telegram-cli { inherit mylibs; }; telegram-history-dump = callPackage ./telegram-history-dump { inherit mylibs; }; telegramircd = callPackage ./telegramircd { inherit mylibs; telethon = callPackage ./telethon_sync {}; }; diff --git a/pkgs/signald/default.nix b/pkgs/signald/default.nix new file mode 100644 index 0000000..593e63d --- /dev/null +++ b/pkgs/signald/default.nix @@ -0,0 +1,87 @@ +{ lib, stdenv, fetchurl, fetchgit, jre, coreutils, gradle_6, git, perl +, makeWrapper }: + +let + pname = "signald"; + + version = "0.13.1"; + + # This package uses the .git directory + src = fetchgit { + url = "https://gitlab.com/signald/signald"; + rev = version; + sha256 = "1ilmg0i1kw2yc7m3hxw1bqdpl3i9wwbj8623qmz9cxhhavbcd5i7"; + leaveDotGit = true; + }; + + buildConfigJar = fetchurl { + url = "https://dl.bintray.com/mfuerstenau/maven/gradle/plugin/de/fuerstenau/BuildConfigPlugin/1.1.8/BuildConfigPlugin-1.1.8.jar"; + sha256 = "0y1f42y7ilm3ykgnm6s3ks54d71n8lsy5649xgd9ahv28lj05x9f"; + }; + + patches = [ ./git-describe-always.patch ./gradle-plugin.patch ]; + + postPatch = '' + patchShebangs gradlew + sed -i -e 's|BuildConfig.jar|${buildConfigJar}|' build.gradle + ''; + + # fake build to pre-download deps into fixed-output derivation + deps = stdenv.mkDerivation { + name = "${pname}-deps"; + inherit src version postPatch patches; + nativeBuildInputs = [ gradle_6 perl ]; + buildPhase = '' + export GRADLE_USER_HOME=$(mktemp -d) + gradle --no-daemon build + ''; + # 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) + installPhase = '' + find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(jar\|pom\)' \ + | perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/''${\($5 =~ s/-jvm//r)}" #e' \ + | sh + ''; + # Don't move info to share/ + forceShare = [ "dummy" ]; + outputHashAlgo = "sha256"; + outputHashMode = "recursive"; + outputHash = "0w8ixp1l0ch1jc2dqzxdx3ljlh17hpgns2ba7qvj43nr4prl71l7"; + }; + +in stdenv.mkDerivation rec { + inherit pname src version postPatch patches; + + buildPhase = '' + export GRADLE_USER_HOME=$(mktemp -d) + + # Use the local packages from -deps + sed -i -e 's|mavenCentral()|mavenLocal(); maven { url uri("${deps}") }|' build.gradle + + gradle --offline --no-daemon distTar + ''; + + installPhase = '' + mkdir -p $out + tar xvf ./build/distributions/signald.tar --strip-components=1 --directory $out/ + wrapProgram $out/bin/signald \ + --prefix PATH : ${lib.makeBinPath [ coreutils ]} \ + --set JAVA_HOME "${jre}" + ''; + + nativeBuildInputs = [ git gradle_6 makeWrapper ]; + + doCheck = true; + + meta = with lib; { + description = "Unofficial daemon for interacting with Signal"; + longDescription = '' + Signald is a daemon that facilitates communication over Signal. It is + unofficial, unapproved, and not nearly as secure as the real Signal + clients. + ''; + homepage = "https://signald.org"; + license = licenses.gpl3Plus; + maintainers = with maintainers; [ expipiplus1 ]; + platforms = platforms.unix; + }; +} diff --git a/pkgs/signald/git-describe-always.patch b/pkgs/signald/git-describe-always.patch new file mode 100644 index 0000000..2f4830e --- /dev/null +++ b/pkgs/signald/git-describe-always.patch @@ -0,0 +1,9 @@ +diff --git a/version.sh b/version.sh +index 7aeeb3c..060cba3 100755 +--- a/version.sh ++++ b/version.sh +@@ -1,3 +1,3 @@ + #!/bin/sh +-VERSION=$(git describe --exact-match 2> /dev/null) || VERSION=$(git describe --abbrev=0)+git$(date +%Y-%m-%d)r$(git rev-parse --short=8 HEAD).$(git rev-list $(git describe --abbrev=0)..HEAD --count) ++VERSION=$(git describe --exact-match 2> /dev/null) || VERSION=$(git describe --always --abbrev=0)+git$(date +%Y-%m-%d)r$(git rev-parse --short=8 HEAD).$(git rev-list $(git describe --always --abbrev=0)..HEAD --count) + echo $VERSION diff --git a/pkgs/signald/gradle-plugin.patch b/pkgs/signald/gradle-plugin.patch new file mode 100644 index 0000000..6952654 --- /dev/null +++ b/pkgs/signald/gradle-plugin.patch @@ -0,0 +1,26 @@ +diff --git a/build.gradle b/build.gradle +index 11d7a99..66805bb 100644 +--- a/build.gradle ++++ b/build.gradle +@@ -3,9 +3,12 @@ import org.gradle.nativeplatform.platform.internal.OperatingSystemInternal + import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform + import org.xml.sax.SAXParseException + +-plugins { +- id 'de.fuerstenau.buildconfig' version '1.1.8' ++buildscript { ++ dependencies { ++ classpath files ("BuildConfig.jar") ++ } + } ++apply plugin: 'de.fuerstenau.buildconfig' + + apply plugin: 'java' + apply plugin: 'application' +@@ -185,4 +188,4 @@ task integrationTest(type: Test) { + testClassesDirs = sourceSets.integrationTest.output.classesDirs + classpath = sourceSets.integrationTest.runtimeClasspath + outputs.upToDateWhen { false } +-} +\ No newline at end of file ++} diff --git a/pkgs/signaldctl/default.nix b/pkgs/signaldctl/default.nix new file mode 100644 index 0000000..3ae85d8 --- /dev/null +++ b/pkgs/signaldctl/default.nix @@ -0,0 +1,13 @@ +{ buildGoModule, fetchgit, lib }: + +buildGoModule { + pname = "signaldctl"; + version = "main-3ca2d6f6"; + src = fetchgit { + url = "https://gitlab.com/signald/signald-go.git"; + branchName = "main"; + rev = "3ca2d6f6c91d44f34fca3221c430d1c47fa31a5a"; + sha256 = "0hh2jqfdsvclilqllyfxswpw6fk0ncyhbiy08mwfp3dnk8nlz5vk"; + }; + vendorSha256 = "0m3spzv79fgnrg0sxhi3nrpdrvmrznwdca6rrz8qxgqb7a58qcxv"; +} -- 2.41.0