about summary refs log tree commit diff
path: root/pkgs/by-name/i2
diff options
context:
space:
mode:
authorlinsui <linsui@inbox.lv>2024-04-08 22:31:23 +0800
committerlinsui <linsui@inbox.lv>2024-04-08 22:32:27 +0800
commita09ac6605320f3cdee544cc16f748ad436355e11 (patch)
tree7696866ee61e95a769d5e3aa6e8ea2525b8783ed /pkgs/by-name/i2
parentd16233cc92371b1797e4509b97b9ef43be0790f6 (diff)
i2p: move to by-name
Diffstat (limited to 'pkgs/by-name/i2')
-rw-r--r--pkgs/by-name/i2/i2p/package.nix122
1 files changed, 122 insertions, 0 deletions
diff --git a/pkgs/by-name/i2/i2p/package.nix b/pkgs/by-name/i2/i2p/package.nix
new file mode 100644
index 0000000000000..88d3041ffd65c
--- /dev/null
+++ b/pkgs/by-name/i2/i2p/package.nix
@@ -0,0 +1,122 @@
+{ lib
+, stdenv
+, fetchzip
+, jdk
+, ant
+, gettext
+, which
+, dbip-country-lite
+, java-service-wrapper
+, makeWrapper
+, gmp
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "i2p";
+  version = "2.4.0";
+
+  src = fetchzip {
+    urls = map (mirror: "${mirror}${finalAttrs.version}/i2psource_${finalAttrs.version}.tar.bz2") [
+      "https://github.com/i2p/i2p.i2p/releases/download/i2p-"
+      "https://download.i2p2.de/releases/"
+      "https://files.i2p-projekt.de/"
+      "https://download.i2p2.no/releases/"
+    ];
+    hash = "sha256-RESN1qA/SD9MajUSJyXssNZnph2XZge7xr2kTgOp5V4=";
+  };
+
+  strictDeps = true;
+
+  nativeBuildInputs = [
+    makeWrapper
+    ant
+    gettext
+    jdk
+    which
+  ];
+
+  buildInputs = [ gmp ];
+
+  postConfigure = ''
+    rm -r installer/lib
+    mkdir -p installer/lib/wrapper/all/
+    # The java-service-wrapper is needed for build but not really used in runtime
+    ln -s ${java-service-wrapper}/lib/wrapper.jar installer/lib/wrapper/all/wrapper.jar
+    # Don't use the bundled geoip data
+    echo "with-geoip-database=true" >> override.properties
+  '';
+
+  buildPhase = ''
+    # When this variable exists we can build the .so files only.
+    export DEBIANVERSION=1
+    pushd core/c/jcpuid
+    ./build.sh
+    popd
+    pushd core/c/jbigi
+    ./build_jbigi.sh dynamic
+    popd
+    export JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8"
+    SOURCE_DATE_EPOCH=0 ant preppkg-unix
+  '';
+
+  installPhase = ''
+    mkdir -p $out/{bin,share,geoip}
+    mv pkg-temp/* $out
+    mv core/c/jbigi/*.so $out/lib
+    mv $out/man $out/share/
+    rm $out/{osid,postinstall.sh,INSTALL-headless.txt}
+
+    for jar in $out/lib/*.jar; do
+      if [ ! -z $CP ]; then
+        CP=$CP:$jar;
+      else
+        CP=$jar
+      fi
+    done
+
+    makeWrapper ${jdk}/bin/java $out/bin/i2prouter \
+      --add-flags "-cp $CP -Djava.library.path=$out/lib/ -Di2p.dir.base=$out -DloggerFilenameOverride=logs/log-router-@.txt" \
+      --add-flags "net.i2p.router.RouterLaunch"
+
+    ln -s ${dbip-country-lite.mmdb} $out/geoip/GeoLite2-Country.mmdb
+  '';
+
+  doInstallCheck = true;
+
+  installCheckPhase = ''
+    runHook preInstallCheck
+
+    # Check if jbigi is used
+    java -cp $out/lib/i2p.jar -Djava.library.path=$out/lib/ net.i2p.util.NativeBigInteger \
+      | tee /dev/stderr | grep -Fw "Found native library" || exit 1
+
+    runHook postInstallCheck
+  '';
+
+  meta = with lib; {
+    description = "Applications and router for I2P, anonymity over the Internet";
+    homepage = "https://geti2p.net";
+    sourceProvenance = with sourceTypes; [
+      fromSource
+      binaryBytecode # source bundles dependencies as jars
+    ];
+    license = with licenses; [
+      asl20
+      boost
+      bsd2
+      bsd3
+      cc-by-30
+      cc0
+      epl10
+      gpl2
+      gpl3
+      lgpl21Only
+      lgpl3Only
+      mit
+      publicDomain
+    ];
+    platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
+    maintainers = with maintainers; [ linsui ];
+    mainProgram = "i2prouter-plain";
+  };
+})