From dbb732a8f25ba08339fdbf74534a7036f95a927d Mon Sep 17 00:00:00 2001 From: Paul Dettorer Hervot Date: Sun, 5 Jun 2022 17:50:16 +0200 Subject: [PATCH] digital: init at 0.29 --- .../science/electronics/digital/default.nix | 99 +++++++++++++++++++ .../science/electronics/digital/pom.xml.patch | 30 ++++++ pkgs/top-level/all-packages.nix | 2 + 3 files changed, 131 insertions(+) create mode 100644 pkgs/applications/science/electronics/digital/default.nix create mode 100644 pkgs/applications/science/electronics/digital/pom.xml.patch diff --git a/pkgs/applications/science/electronics/digital/default.nix b/pkgs/applications/science/electronics/digital/default.nix new file mode 100644 index 000000000000..0515809dffeb --- /dev/null +++ b/pkgs/applications/science/electronics/digital/default.nix @@ -0,0 +1,99 @@ +{ lib, stdenv, fetchFromGitHub, makeDesktopItem, copyDesktopItems, makeWrapper +, jre, maven, git +}: + +let + pkgDescription = "A digital logic designer and circuit simulator."; + version = "0.29"; + buildDate = "2022-02-11T18:10:34+01:00"; # v0.29 commit date + + desktopItem = makeDesktopItem { + type = "Application"; + name = "Digital"; + desktopName = pkgDescription; + comment = "Easy-to-use digital logic designer and circuit simulator"; + exec = "digital"; + icon = "digital"; + categories = [ "Education" "Electronics" ]; + mimeTypes = [ "text/x-digital" ]; + terminal = false; + keywords = [ "simulator" "digital" "circuits" ]; + }; + + # Use the "no-git-rev" maven profile, which deactivates the plugin that + # inspect the .git folder to find the version number we are building, we then + # provide that version number manually as a property. + # (see https://github.com/hneemann/Digital/issues/289#issuecomment-513721481) + mvnOptions = "-Pno-git-rev -Dgit.commit.id.describe=${version} -Dproject.build.outputTimestamp=${buildDate}"; +in +stdenv.mkDerivation rec { + pname = "digital"; + inherit version jre; + + src = fetchFromGitHub { + owner = "hneemann"; + repo = "Digital"; + rev = "287dd939d6f2d4d02c0d883c6178c3425c28d39c"; + sha256 = "o5gaExUTTbk6WgQVw7/IeXhpNkj1BLkwD752snQqjIg="; + }; + + # Use fixed dates in the pom.xml and upgrade the jar and assembly plugins to + # a version where they support reproducible builds + patches = [ ./pom.xml.patch ]; + + # Fetching maven dependencies from "central" needs the network at build phase, + # we do that in this extra derivation that explicitely specifies its + # outputHash to ensure determinism. + mavenDeps = stdenv.mkDerivation { + name = "${pname}-${version}-maven-deps"; + inherit src nativeBuildInputs version patches postPatch; + dontFixup = true; + buildPhase = '' + mvn package ${mvnOptions} -Dmaven.repo.local=$out + ''; + # keep only *.{pom,jar,sha1,nbm} and delete all ephemeral files with + # lastModified timestamps inside + installPhase = '' + find $out -type f \ + -name \*.lastUpdated -or \ + -name resolver-status.properties -or \ + -name _remote.repositories \ + -delete + ''; + outputHashAlgo = "sha256"; + outputHashMode = "recursive"; + outputHash = "X5ppGUVwNQrMnjzD4Kin1Xmt4O3x+qr7jK4jr6E8tCI="; + }; + + nativeBuildInputs = [ copyDesktopItems maven makeWrapper ]; + + postPatch = '' + substituteInPlace pom.xml --subst-var-by buildDate "${buildDate}" + ''; + + buildPhase = '' + mvn package --offline ${mvnOptions} -Dmaven.repo.local=${mavenDeps} + ''; + + installPhase = '' + mkdir -p $out/bin + mkdir -p $out/share/java + + classpath=$(find ${mavenDeps} -name "*.jar" -printf ':%h/%f'); + install -Dm644 target/Digital.jar $out/share/java + + makeWrapper ${jre}/bin/java $out/bin/${pname} \ + --add-flags "-classpath $out/share/java/${pname}-${version}.jar:''${classpath#:}" \ + --add-flags "-jar $out/share/java/Digital.jar" + ''; + + desktopItems = [ desktopItem ]; + + meta = with lib; { + homepage = "https://github.com/hneemann/Digital"; + description = pkgDescription; + license = licenses.gpl3Only; + platforms = [ "x86_64-linux" "x86_64-darwin" ]; + maintainers = with maintainers; [ Dettorer ]; + }; +} diff --git a/pkgs/applications/science/electronics/digital/pom.xml.patch b/pkgs/applications/science/electronics/digital/pom.xml.patch new file mode 100644 index 000000000000..cdc5a777c49d --- /dev/null +++ b/pkgs/applications/science/electronics/digital/pom.xml.patch @@ -0,0 +1,30 @@ +diff --git a/pom.xml b/pom.xml +index d5f8330b4..58ed18b63 100644 +--- a/pom.xml ++++ b/pom.xml +@@ -129,7 +130,7 @@ + + org.apache.maven.plugins + maven-jar-plugin +- 2.5 ++ 3.2.0 + + + +@@ -188,6 +189,7 @@ + + org.apache.maven.plugins + maven-assembly-plugin ++ 3.2.0 + + Digital + false +@@ -202,7 +204,7 @@ + + + ${git.commit.id.describe} +- ${maven.build.timestamp} ++ @buildDate@ + icons/splash.png + + diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 957705e129e0..a93055d076bb 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -28321,6 +28321,8 @@ with pkgs; dia = callPackage ../applications/graphics/dia { }; + digital = callPackage ../applications/science/electronics/digital {}; + direwolf = callPackage ../applications/radio/direwolf { hamlib = hamlib_4; };