Skip to content

Instantly share code, notes, and snippets.

@orzklv
Created February 12, 2025 22:22
Show Gist options
  • Save orzklv/f69a8c005041c39dc6d38e911d9f23ad to your computer and use it in GitHub Desktop.
Save orzklv/f69a8c005041c39dc6d38e911d9f23ad to your computer and use it in GitHub Desktop.
{
lib,
stdenv,
jre8,
curl,
ccid,
fetchurl,
pcsclite,
pcsc-tools,
writeShellScript,
}:
let
isApple = builtins.elem system [
"aarch64-darwin"
"x86_64-darwin"
];
ext = if isApple then ".dylib" else ".so";
exec = writeShellScript "e-imzo" ''
# Change working directory to script
cd "$(dirname "$0")/../lib"
# Let's parse these args like a pro
POSITIONAL_ARGS=()
# While params go brrr...
while [[ $# -gt 0 ]]; do
case $1 in
-id|--id-card)
IDCARD=YES
shift # past argument
;;
-*|--*)
echo "Unknown option or parameter: $1"
exit 1
;;
*)
POSITIONAL_ARGS+=("$1") # save positional arg
shift # past argument
;;
esac
done
# Start the damned server depending on args
if [[ -n $IDCARD ]]; then
${jre8}/bin/java -Dsun.security.smartcardio.library=${pcsclite.lib}/lib/libpcsclite.${ext} -jar ../lib/E-IMZO.jar
else
${jre8}/bin/java -jar ../lib/E-IMZO.jar
fi
exit 0
'';
in
stdenv.mkDerivation rec {
pname = "e-imzo";
version = "4.64";
src = fetchurl {
url = "https://dls.yt.uz/E-IMZO-v${version}.tar.gz";
hash = "sha256-ej99PJrO9ufJ8+VlC/HpfvS/bGBtKqUWcsRyiZRlU4c=";
};
buildInputs = [
jre8
curl
ccid
pcsclite
pcsc-tools
];
installPhase = ''
# Executables folder
mkdir -p $out/bin
# Library folder
mkdir -p $out/lib
# Copy java thingies to lib
cp -r ./lib $out/lib/
cp ./E-IMZO.jar $out/lib/
cp ./E-IMZO.pem $out/lib/
cp ./truststore.jks $out/lib/
# Copy the shell script to bin
cp -r "${exec}" $out/bin/e-imzo
'';
meta = with lib; {
description = "E-IMZO for uzbek state web identity proving & key signing";
mainProgram = "e-imzo";
licencse = lib.licenses.unfree;
platforms = with platforms; linux ++ darwin;
homepage = "https://github.com/xinux-org/e-imzo";
license = with licenses; [ unfree ];
maintainers = with maintainers; [ orzklv ];
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment