diff options
Diffstat (limited to 'pkgs/athena-bccr')
| -rw-r--r-- | pkgs/athena-bccr/default.nix | 46 | ||||
| -rw-r--r-- | pkgs/athena-bccr/firmador.nix | 85 | ||||
| -rw-r--r-- | pkgs/athena-bccr/gaudi-env.nix | 97 | ||||
| -rw-r--r-- | pkgs/athena-bccr/unwrapped.nix | 157 |
4 files changed, 192 insertions, 193 deletions
diff --git a/pkgs/athena-bccr/default.nix b/pkgs/athena-bccr/default.nix index f9276c1..a5f79ca 100644 --- a/pkgs/athena-bccr/default.nix +++ b/pkgs/athena-bccr/default.nix @@ -1,32 +1,30 @@ -{ callPackage -, lib -}: -let +{ + callPackage, + lib, +}: let latest = "deb64-rev26"; - releases = lib.mapAttrs (name: release: release // { name = name; }) (import ./releases.nix); + releases = lib.mapAttrs (name: release: release // {name = name;}) (import ./releases.nix); - overrideUnwrapped = default: new: - let - args = default // new; - unwrappedPkgs = lib.filterAttrs (name: _: ! lib.elem name [ "override" "overrideDerivation" ]) (callPackage ./unwrapped.nix args); - in - lib.fix (unwrapped: lib.mapAttrs (_: pkg: callPackage pkg unwrapped) unwrappedPkgs) // { + overrideUnwrapped = default: new: let + args = default // new; + unwrappedPkgs = lib.filterAttrs (name: _: ! lib.elem name ["override" "overrideDerivation"]) (callPackage ./unwrapped.nix args); + in + lib.fix (unwrapped: lib.mapAttrs (_: pkg: callPackage pkg unwrapped) unwrappedPkgs) + // { override = overrideUnwrapped args; }; - pkgsForRelease = release: - let - ase-pkcs11 = unwrapped.ase-idprotect.lib; - libasep11 = "${ase-pkcs11}/lib/x64-athena/libASEP11.so"; - unwrapped = overrideUnwrapped { inherit release; } { }; - in - { - inherit ase-pkcs11 libasep11; - inherit (unwrapped) ase-idprotect bccr-cacerts; + pkgsForRelease = release: let + ase-pkcs11 = unwrapped.ase-idprotect.lib; + libasep11 = "${ase-pkcs11}/lib/x64-athena/libASEP11.so"; + unwrapped = overrideUnwrapped {inherit release;} {}; + in { + inherit ase-pkcs11 libasep11; + inherit (unwrapped) ase-idprotect bccr-cacerts; - gaudi = callPackage ./gaudi-env.nix { inherit unwrapped; }; - firmador = callPackage ./firmador.nix { inherit libasep11; }; - }; + gaudi = callPackage ./gaudi-env.nix {inherit unwrapped;}; + firmador = callPackage ./firmador.nix {inherit libasep11;}; + }; in -lib.mapAttrs (_: pkgsForRelease) (releases // { latest = releases.${latest}; }) + lib.mapAttrs (_: pkgsForRelease) (releases // {latest = releases.${latest};}) diff --git a/pkgs/athena-bccr/firmador.nix b/pkgs/athena-bccr/firmador.nix index eef413b..d280b56 100644 --- a/pkgs/athena-bccr/firmador.nix +++ b/pkgs/athena-bccr/firmador.nix @@ -1,58 +1,57 @@ -{ fetchgit -, lib -, makeWrapper -, maven -, openjdk -, wrapGAppsHook - -, libasep11 ? null -}: -let +{ + fetchgit, + lib, + makeWrapper, + maven, + openjdk, + wrapGAppsHook, + libasep11 ? null, +}: let jdk = openjdk.override { enableJavaFX = true; }; version = "1.9.8"; in -maven.buildMavenPackage { - pname = "firmador"; - inherit version; - - src = fetchgit { - url = "https://codeberg.org/firmador/firmador"; - rev = version; - hash = "sha256-xdiVPjihRADPK4nG+WQHWsDzVYLCeN6ouQ6SDtjf1qQ="; - }; + maven.buildMavenPackage { + pname = "firmador"; + inherit version; - patches = [ - ./0001-Remove-CheckUpdatePlugin-from-default-list.patch - ]; + src = fetchgit { + url = "https://codeberg.org/firmador/firmador"; + rev = version; + hash = "sha256-xdiVPjihRADPK4nG+WQHWsDzVYLCeN6ouQ6SDtjf1qQ="; + }; - mvnHash = "sha256-h1zoStTgaE7toWWKq0Y0ahOORyltChwjmaMYjLgs1VE="; + patches = [ + ./0001-Remove-CheckUpdatePlugin-from-default-list.patch + ]; - nativeBuildInputs = [ - makeWrapper - wrapGAppsHook - ]; + mvnHash = "sha256-h1zoStTgaE7toWWKq0Y0ahOORyltChwjmaMYjLgs1VE="; - postPatch = lib.optionalString (libasep11 != null) '' - sed -i 's@/usr/lib/x64-athena/libASEP11.so@${libasep11}@g' src/main/java/cr/libre/firmador/CRSigner.java - ''; + nativeBuildInputs = [ + makeWrapper + wrapGAppsHook + ]; - installPhase = '' - runHook preInstall + postPatch = lib.optionalString (libasep11 != null) '' + sed -i 's@/usr/lib/x64-athena/libASEP11.so@${libasep11}@g' src/main/java/cr/libre/firmador/CRSigner.java + ''; - mkdir -p $out/bin $out/share/java - install -Dm644 target/firmador.jar $out/share/java + installPhase = '' + runHook preInstall - makeWrapper ${jdk}/bin/java $out/bin/firmador \ - --add-flags "-jar $out/share/java/firmador.jar" + mkdir -p $out/bin $out/share/java + install -Dm644 target/firmador.jar $out/share/java - runHook postInstall - ''; + makeWrapper ${jdk}/bin/java $out/bin/firmador \ + --add-flags "-jar $out/share/java/firmador.jar" - meta = { - homepage = "https://firmador.libre.cr"; - license = lib.licenses.gpl3Plus; - }; -} + runHook postInstall + ''; + + meta = { + homepage = "https://firmador.libre.cr"; + license = lib.licenses.gpl3Plus; + }; + } diff --git a/pkgs/athena-bccr/gaudi-env.nix b/pkgs/athena-bccr/gaudi-env.nix index 1ced54e..0ca1b82 100644 --- a/pkgs/athena-bccr/gaudi-env.nix +++ b/pkgs/athena-bccr/gaudi-env.nix @@ -1,63 +1,62 @@ -{ buildFHSEnv -, curl -, lib -, writeShellScriptBin - -, gaudiHash ? null -, unwrapped -}: -let - unwrappedWithGaudi = unwrapped.override { inherit gaudiHash; }; +{ + buildFHSEnv, + curl, + lib, + writeShellScriptBin, + gaudiHash ? null, + unwrapped, +}: let + unwrappedWithGaudi = unwrapped.override {inherit gaudiHash;}; in -buildFHSEnv { - name = "gaudi"; + buildFHSEnv { + name = "gaudi"; - targetPkgs = pkgs: [ - unwrappedWithGaudi.ase-idprotect.lib - unwrappedWithGaudi.gaudi + targetPkgs = pkgs: [ + unwrappedWithGaudi.ase-idprotect.lib + unwrappedWithGaudi.gaudi - (writeShellScriptBin "launch-gaudi" '' - set -o errexit - set -o pipefail - set -o nounset + (writeShellScriptBin "launch-gaudi" '' + set -o errexit + set -o pipefail + set -o nounset - PATH="${lib.makeBinPath [ curl ]}:$PATH" + PATH="${lib.makeBinPath [curl]}:$PATH" - echo "$0: testing for incompatible releases..." >&2 + echo "$0: testing for incompatible releases..." >&2 - jar_name=bccr-firma-fva-clienteMultiplataforma.jar - url="https://www.firmadigital.go.cr/Bccr.Firma.Fva.Actualizador.ClienteFirmadorJava//recursosLiberica17/actualizador/$jar_name" - ca_file="${unwrappedWithGaudi.bccr-cacerts}/root-ca.pem" - url_hash=$(curl -sS --cacert "$ca_file" "$url" | sha256sum | cut -d' ' -f1) - jar_path="${unwrappedWithGaudi.gaudi}/share/java/$jar_name" - jar_hash=$(sha256sum "$jar_path" | cut -d' ' -f1) + jar_name=bccr-firma-fva-clienteMultiplataforma.jar + url="https://www.firmadigital.go.cr/Bccr.Firma.Fva.Actualizador.ClienteFirmadorJava//recursosLiberica17/actualizador/$jar_name" + ca_file="${unwrappedWithGaudi.bccr-cacerts}/root-ca.pem" + url_hash=$(curl -sS --cacert "$ca_file" "$url" | sha256sum | cut -d' ' -f1) + jar_path="${unwrappedWithGaudi.gaudi}/share/java/$jar_name" + jar_hash=$(sha256sum "$jar_path" | cut -d' ' -f1) - if [ "$url_hash" != "$jar_hash" ]; then - last_modified=$(curl -sS --head --cacert "$ca_file" "$url" | grep -i '^last-modified:' | head -1) + if [ "$url_hash" != "$jar_hash" ]; then + last_modified=$(curl -sS --head --cacert "$ca_file" "$url" | grep -i '^last-modified:' | head -1) - echo "$0: sha256 mismatch for $jar_path due to server-side update" >&2 - echo "$0: expected: $url_hash" >&2 - echo "$0: actual: $jar_hash" >&2 - echo "$0: $last_modified" >&2 - echo "$0: run the following to download the new client JAR, then update your derivation:" >&2 - echo "$0: \$ ${unwrappedWithGaudi.update-gaudi}" >&2 + echo "$0: sha256 mismatch for $jar_path due to server-side update" >&2 + echo "$0: expected: $url_hash" >&2 + echo "$0: actual: $jar_hash" >&2 + echo "$0: $last_modified" >&2 + echo "$0: run the following to download the new client JAR, then update your derivation:" >&2 + echo "$0: \$ ${unwrappedWithGaudi.update-gaudi}" >&2 - exit 1 - fi + exit 1 + fi - cache_path_1="''${XDG_CACHE_HOME:-$HOME/.cache}/Agente-GAUDI" - cache_path_2="''${XDG_CACHE_HOME:-$HOME/.cache}/Firmador-BCCR" + cache_path_1="''${XDG_CACHE_HOME:-$HOME/.cache}/Agente-GAUDI" + cache_path_2="''${XDG_CACHE_HOME:-$HOME/.cache}/Firmador-BCCR" - for cache_path in "$cache_path_1" "$cache_path_2"; do - mkdir -p "$cache_path" - ln -sf -- ${unwrappedWithGaudi.gaudi}/share/java/bccr-firma-fva-clienteMultiplataforma.jar "$cache_path" - done + for cache_path in "$cache_path_1" "$cache_path_2"; do + mkdir -p "$cache_path" + ln -sf -- ${unwrappedWithGaudi.gaudi}/share/java/bccr-firma-fva-clienteMultiplataforma.jar "$cache_path" + done - cp -f --no-preserve=mode -t "$cache_path_1" -- "${unwrappedWithGaudi.gaudi}/share/java/config.properties" + cp -f --no-preserve=mode -t "$cache_path_1" -- "${unwrappedWithGaudi.gaudi}/share/java/config.properties" - exec gaudi - '') - ]; + exec gaudi + '') + ]; - runScript = "launch-gaudi"; -} + runScript = "launch-gaudi"; + } diff --git a/pkgs/athena-bccr/unwrapped.nix b/pkgs/athena-bccr/unwrapped.nix index 55ef107..d6f3f38 100644 --- a/pkgs/athena-bccr/unwrapped.nix +++ b/pkgs/athena-bccr/unwrapped.nix @@ -1,11 +1,10 @@ -{ lib -, requireFile - -, release -, gaudiHash ? null -, ... -}: -let +{ + lib, + requireFile, + release, + gaudiHash ? null, + ... +}: let inherit (release) srcPaths; src = requireFile { @@ -15,40 +14,47 @@ let inherit (release) hash; }; - gaudiUpdateSrc = { update-gaudi }: requireFile { - url = "${update-gaudi}"; - name = "gaudi-update-${release.name}.zip"; + gaudiUpdateSrc = {update-gaudi}: + requireFile { + url = "${update-gaudi}"; + name = "gaudi-update-${release.name}.zip"; - hash = gaudiHash; - }; + hash = gaudiHash; + }; - moduleFromDeb = name: args@{ stdenv, dpkg, unzip, srcPath, ... }: + moduleFromDeb = name: args @ { + stdenv, + dpkg, + unzip, + srcPath, + ... + }: stdenv.mkDerivation ({ - pname = "${name}-unwrapped"; - version = release.name; - - inherit src; - - nativeBuildInputs = [ dpkg unzip ] ++ (args.nativeBuildInputs or [ ]); - - postUnpack = '' - dpkg -x ${lib.escapeShellArg "${release.basename}/${srcPath}"} ${lib.escapeShellArg release.basename} - ''; - } // lib.removeAttrs args [ "stdenv" "dpkg" "unzip" "srcPath" "nativeBuildInputs" ]); -in -{ - ase-idprotect = - { autoPatchelfHook - , dpkg - , fontconfig - , freetype - , pcsclite - , stdenv - , unzip - , xorg - , zlib - , ... - }: + pname = "${name}-unwrapped"; + version = release.name; + + inherit src; + + nativeBuildInputs = [dpkg unzip] ++ (args.nativeBuildInputs or []); + + postUnpack = '' + dpkg -x ${lib.escapeShellArg "${release.basename}/${srcPath}"} ${lib.escapeShellArg release.basename} + ''; + } + // lib.removeAttrs args ["stdenv" "dpkg" "unzip" "srcPath" "nativeBuildInputs"]); +in { + ase-idprotect = { + autoPatchelfHook, + dpkg, + fontconfig, + freetype, + pcsclite, + stdenv, + unzip, + xorg, + zlib, + ... + }: moduleFromDeb "ase-idprotect" { inherit dpkg stdenv unzip; srcPath = srcPaths.idprotect; @@ -67,7 +73,7 @@ in autoPatchelfHook ]; - outputs = [ "out" "lib" ]; + outputs = ["out" "lib"]; installPhase = '' runHook preInstall @@ -85,28 +91,26 @@ in ''; }; - gaudi = - { autoPatchelfHook - , dpkg - , makeWrapper - , openjdk - , pkgs - , stdenv - , unzip - , writeShellScriptBin - - , update-gaudi - , ... - }: - let - jdk = openjdk.override { - enableJavaFX = true; - openjfx_jdk = pkgs."openjfx${lib.head (lib.splitString "." openjdk.version)}".override { withWebKit = true; }; - }; - - fakeSudo = writeShellScriptBin "sudo" ""; - gaudiUpdate = gaudiUpdateSrc { inherit update-gaudi; }; - in + gaudi = { + autoPatchelfHook, + dpkg, + makeWrapper, + openjdk, + pkgs, + stdenv, + unzip, + writeShellScriptBin, + update-gaudi, + ... + }: let + jdk = openjdk.override { + enableJavaFX = true; + openjfx_jdk = pkgs."openjfx${lib.head (lib.splitString "." openjdk.version)}".override {withWebKit = true;}; + }; + + fakeSudo = writeShellScriptBin "sudo" ""; + gaudiUpdate = gaudiUpdateSrc {inherit update-gaudi;}; + in moduleFromDeb "gaudi" { inherit dpkg stdenv unzip; srcPath = srcPaths.gaudi; @@ -159,12 +163,12 @@ in ''; }; - bccr-cacerts = - { openssl - , stdenv - , unzip - , ... - }: + bccr-cacerts = { + openssl, + stdenv, + unzip, + ... + }: stdenv.mkDerivation { pname = "bccr-cacerts"; version = release.name; @@ -182,14 +186,13 @@ in ''; }; - update-gaudi = - { wget - , writeShellScript - , zip - - , bccr-cacerts - , ... - }: + update-gaudi = { + wget, + writeShellScript, + zip, + bccr-cacerts, + ... + }: writeShellScript "update-gaudi" '' set -o errexit set -o pipefail @@ -199,7 +202,7 @@ in trap 'cd / && rm -rf -- "$temp_dir"' EXIT cd "$temp_dir" - PATH="${lib.makeBinPath [ wget zip ]}:$PATH" + PATH="${lib.makeBinPath [wget zip]}:$PATH" ca_cert="${bccr-cacerts}/root-ca.pem" base_url="https://www.firmadigital.go.cr/Bccr.Firma.Fva.Actualizador.ClienteFirmadorJava//recursosLiberica17/actualizador" |
