22 pname = "cie-middleware-linux";
25 src = fetchFromGitHub {
28 rev = "${version}-podofo";
29 sha256 = "sha256-Kyr9OTiY6roJ/wVJS/1aWfrrzDNQbuRTJQqo0akbMUU=";
32 # Shared libraries needed by the Java application
33 libraries = lib.makeLibraryPath [ ghostscript ];
35 # Fixed-output derivation that fetches the Java dependencies
36 javaDeps = stdenv.mkDerivation {
37 pname = "cie-java-deps";
40 nativeBuildInputs = [ gradle ];
43 # Run the fetchDeps task
44 export GRADLE_USER_HOME=$(mktemp -d)
45 gradle --no-daemon -b cie-java/build.gradle fetchDeps
49 # Build a tree compatible with the maven repository format
50 pushd "$GRADLE_USER_HOME/caches/modules-2/files-2.1"
51 find -type f | awk -F/ -v OFS=/ -v out="$out" '{
54 system("install -m644 -D "infile" "out"/"$2"/"$3"/"$4"/"$6)
59 outputHashAlgo = "sha256";
60 outputHashMode = "recursive";
61 outputHash = "sha256-WzT5vYF9yCMU2A7EkLZyjgWrN3gD7pnkPXc3hDFqpD8=";
67 inherit pname src version;
69 hardeningDisable = [ "format" ];
71 outputs = [ "out" "dev" ];
93 # substitute the cieid command with this $out/bin/cieid
94 substituteInPlace libs/pkcs11/src/CSP/AbilitaCIE.cpp \
95 --replace 'file = "cieid"' 'file = "'$out'/bin/cieid"'
98 # Note: we use pushd/popd to juggle between the
99 # libraries and the Java application builds.
100 preConfigure = "pushd libs";
105 # Use the packages in javaDeps for both plugins and dependencies
106 localRepo="maven { url uri('${javaDeps}') }"
107 sed -i cie-java/settings.gradle -e "1i \
108 pluginManagement { repositories { $localRepo } }"
109 substituteInPlace cie-java/build.gradle \
110 --replace 'mavenCentral()' "$localRepo"
112 # Build the Java application
113 export GRADLE_USER_HOME=$(mktemp -d)
118 --info -Dorg.gradle.java.home=${jre} \
119 --build-file cie-java/build.gradle
127 # Install the Java application
128 install -Dm755 cie-java/build/libs/CIEID-standalone.jar \
129 "$out/share/cieid/cieid.jar"
133 makeWrapper "${jre}/bin/java" "$out/bin/cieid" \
134 --add-flags "-Djna.library.path='$out/lib:${libraries}'" \
135 --add-flags '-Dawt.useSystemAAFontSettings=on' \
136 --add-flags "-cp $out/share/cieid/cieid.jar" \
137 --add-flags "it.ipzs.cieid.MainApplication"
139 # Install other files
140 install -Dm644 data/cieid.desktop "$out/share/applications/cieid.desktop"
141 install -Dm755 data/logo.png "$out/share/pixmaps/cieid.png"
142 install -Dm644 LICENSE "$out/share/licenses/cieid/LICENSE"
146 # Move static libraries to the dev output
147 mv -t "$dev/lib" "$out/lib/"*.a
149 # Make the jar deterministic (mainly, sorting its files)
150 strip-nondeterminism "$out/share/cieid/cieid.jar"
153 passthru = { inherit javaDeps; };
156 homepage = "https://github.com/M0Rf30/cie-middleware-linux";
157 description = "Middleware for the Italian Electronic Identity Card (CIE)";
159 Software for the usage of the Italian Electronic Identity Card (CIE).
160 Access to PA services, signing and verification of documents
162 Warning: this is an unofficial fork because the original software, as
163 distributed by the Italian government, is essentially lacking a build
164 system and is in violation of the license of the PoDoFo library.
166 license = licenses.bsd3;
167 platforms = platforms.unix;
168 # Note: fails due to a lot of broken type conversions
169 badPlatforms = platforms.darwin;
170 maintainers = with maintainers; [ rnhmjoj ];