From 0a1a73c8eefa0efe5a7b40224ba9c8347a1869cc Mon Sep 17 00:00:00 2001 From: TomaSajt <62384384+TomaSajt@users.noreply.github.com> Date: Wed, 3 Jan 2024 21:25:41 +0100 Subject: [PATCH] ili2c: make deterministic and clean up --- pkgs/tools/misc/ili2c/default.nix | 63 +++++++++++++------ .../misc/ili2c/dont-use-build-timestamp.patch | 29 +++++++++ 2 files changed, 73 insertions(+), 19 deletions(-) create mode 100644 pkgs/tools/misc/ili2c/dont-use-build-timestamp.patch diff --git a/pkgs/tools/misc/ili2c/default.nix b/pkgs/tools/misc/ili2c/default.nix index f34c73d3b0f7..ac4e3274e308 100644 --- a/pkgs/tools/misc/ili2c/default.nix +++ b/pkgs/tools/misc/ili2c/default.nix @@ -1,30 +1,55 @@ -{ lib, stdenv, fetchFromGitHub, jdk8, ant, makeWrapper, jre8 }: +{ lib +, stdenv +, fetchFromGitHub +, ant +, jdk8 +, jre8 +, makeWrapper +, canonicalize-jars-hook +}: -let jdk = jdk8; jre = jre8; in -stdenv.mkDerivation rec { +let + jdk = jdk8; + jre = jre8; +in +stdenv.mkDerivation (finalAttrs: { pname = "ili2c"; - version = "5.1.1"; + version = "5.1.1"; # There are newer versions, but they use gradle - nativeBuildInputs = [ ant jdk makeWrapper ]; + nativeBuildInputs = [ + ant + jdk + makeWrapper + canonicalize-jars-hook + ]; src = fetchFromGitHub { owner = "claeis"; - repo = pname; - rev = "${pname}-${version}"; - sha256 = "sha256-FHhx+f253+UdbFjd2fOlUY1tpQ6pA2aVu9CBSwUVoKQ="; + repo = "ili2c"; + rev = "ili2c-${finalAttrs.version}"; + hash = "sha256-FHhx+f253+UdbFjd2fOlUY1tpQ6pA2aVu9CBSwUVoKQ="; }; - buildPhase = "ant jar"; + patches = [ + # avoids modifying Version.properties file because that would insert the current timestamp into the file + ./dont-use-build-timestamp.patch + ]; - installPhase = - '' - mkdir -p $out/share/${pname} - cp $build/build/source/build/jar/ili2c.jar $out/share/${pname} + buildPhase = '' + runHook preBuild + ant jar + runHook postBuild + ''; - mkdir -p $out/bin - makeWrapper ${jre}/bin/java $out/bin/ili2c \ - --add-flags "-jar $out/share/${pname}/ili2c.jar" - ''; + installPhase = '' + runHook preInstall + + install -Dm644 build/jar/ili2c.jar -t $out/share/ili2c + makeWrapper ${jre}/bin/java $out/bin/ili2c \ + --add-flags "-jar $out/share/ili2c/ili2c.jar" + + runHook postInstall + ''; meta = with lib; { description = "The INTERLIS Compiler"; @@ -34,11 +59,11 @@ stdenv.mkDerivation rec { homepage = "https://www.interlis.ch/downloads/ili2c"; sourceProvenance = with sourceTypes; [ fromSource - binaryBytecode # source bundles dependencies as jars + binaryBytecode # source bundles dependencies as jars ]; license = licenses.lgpl21Plus; maintainers = [ maintainers.das-g ]; platforms = platforms.linux; mainProgram = "ili2c"; }; -} +}) diff --git a/pkgs/tools/misc/ili2c/dont-use-build-timestamp.patch b/pkgs/tools/misc/ili2c/dont-use-build-timestamp.patch new file mode 100644 index 000000000000..e3388c54ab53 --- /dev/null +++ b/pkgs/tools/misc/ili2c/dont-use-build-timestamp.patch @@ -0,0 +1,29 @@ +diff --git a/build.xml b/build.xml +index d0493d8..50d4286 100644 +--- a/build.xml ++++ b/build.xml +@@ -221,11 +221,6 @@ + + + +- +- +- +- +- + + + +diff --git a/src-core/ch/interlis/ili2c/metamodel/TransferDescription.java b/src-core/ch/interlis/ili2c/metamodel/TransferDescription.java +index 9e165af..86d8f89 100644 +--- a/src-core/ch/interlis/ili2c/metamodel/TransferDescription.java ++++ b/src-core/ch/interlis/ili2c/metamodel/TransferDescription.java +@@ -219,7 +219,7 @@ public static final String MIMETYPE_XTF = "application/interlis+xml;version=2.3" + ret.append(branch); + ret.append('-'); + } +- ret.append(resVersion.getString("versionDate")); ++ ret.append("nixpkgs"); + version = ret.toString(); + } + return version;