diff --git a/modules/athena-bccr/sys.nix b/modules/athena-bccr/sys.nix index 98ae904..ce63b01 100644 --- a/modules/athena-bccr/sys.nix +++ b/modules/athena-bccr/sys.nix @@ -1,5 +1,4 @@ { - config, pkgs, lib, cfg, @@ -8,9 +7,6 @@ }: let athena = pkgs.${doctrine.prefix}.athena-bccr.${cfg.release}; inherit (athena) vendor; - - driver = athena.card-driver.lib; - scmiddleware = "${driver}/lib/SCMiddleware"; in { environment = { etc = @@ -20,12 +16,11 @@ in { ''; } // lib.optionalAttrs (vendor == "athena") { - "Athena".source = "${driver}/etc/Athena"; + "Athena".source = "${athena.card-driver.lib}/etc/Athena"; } // lib.optionalAttrs (vendor == "idopte") { - "idoss.conf".source = "${driver}/etc/idoss.conf"; - "idoss.lic".source = "${driver}/etc/idoss.lic"; - "SCMiddleware".source = scmiddleware; + "idoss.conf".source = "${athena.card-driver.lib}/etc/idoss.conf"; + "idoss.lic".source = "${athena.card-driver.lib}/etc/idoss.lic"; }; systemPackages = [athena.card-driver]; @@ -52,42 +47,10 @@ in { services = { pcscd.enable = true; - udev.extraRules = - lib.optionalString (vendor == "athena") '' - # Athena Smartcard Solutions, Inc. ASEDrive V3CR - ATTRS{idVendor}=="0dc3", ATTRS{idProduct}=="1004", MODE="660", GROUP="${cfg.group}", TAG+="uaccess" - '' - + lib.optionalString (vendor == "idopte") '' - # Bit4id Srl miniLector-s - ACTION=="add", SUBSYSTEM=="usb", ENV{PRODUCT}=="25dd/1101*", RUN+="${config.systemd.package}/bin/systemctl start --no-block idopte-reader.target" - ACTION=="remove", SUBSYSTEM=="usb", ENV{PRODUCT}=="25dd/1101*", RUN+="${config.systemd.package}/bin/systemctl stop --no-block idopte-reader.target" - ''; - }; - - systemd = lib.mkIf (vendor == "idopte") { - #TODO: make this run as a non-root user - services.idopte-cache = { - description = "Idopte cache server"; - - after = ["smartcard.target"]; - bindsTo = ["idopte-reader.target"]; - wantedBy = ["idopte-reader.target"]; - - serviceConfig = { - Type = "forking"; - PIDFile = "/run/idoCacheSrv.pid"; - RuntimeDirectory = "idoss"; - - ExecStart = "${scmiddleware}/idocachesrv"; - }; - }; - - targets.idopte-reader = { - description = "Idopte USB reader inserted"; - - wants = ["smartcard.target"]; - before = ["smartcard.target"]; - }; + udev.extraRules = '' + # Athena Smartcard Solutions, Inc. ASEDrive V3CR + ATTRS{idVendor}=="0dc3", ATTRS{idProduct}=="1004", MODE="660", GROUP="${cfg.group}", TAG+="uaccess" + ''; }; users.groups.${cfg.group} = {}; diff --git a/pkgs/athena-bccr/firmador.nix b/pkgs/athena-bccr/firmador.nix index feec48e..82578e8 100644 --- a/pkgs/athena-bccr/firmador.nix +++ b/pkgs/athena-bccr/firmador.nix @@ -27,7 +27,7 @@ in ./0001-Remove-CheckUpdatePlugin-from-default-list.patch ]; - mvnHash = "sha256-QDjhwrKZK/cEQxRYUM+z1zMCNrTHyxRqAhUfNtubhhI="; + mvnHash = "sha256-0vwJ1f+0UXxrXRaJ1BHqfOXDU/pxrSPdYYEQ71m4jJQ="; nativeBuildInputs = [ makeWrapper diff --git a/pkgs/athena-bccr/unwrapped.nix b/pkgs/athena-bccr/unwrapped.nix index 3a70144..c7781e4 100644 --- a/pkgs/athena-bccr/unwrapped.nix +++ b/pkgs/athena-bccr/unwrapped.nix @@ -102,7 +102,6 @@ libnotify, openssl, pcsclite, - python3, stdenv, unzip, webkitgtk_4_1, @@ -125,7 +124,6 @@ nativeBuildInputs = [ autoPatchelfHook - python3 ]; outputs = ["out" "lib"]; @@ -134,34 +132,15 @@ runHook preInstall install -m755 -d $out/bin $lib/{etc,lib/SCMiddleware} - install -m755 usr/lib/SCMiddleware/SCManager $out/bin - install -m755 usr/lib/SCMiddleware/{*.so,idocachesrv} $lib/lib/SCMiddleware + install -m755 usr/lib/SCMiddleware/{idocachesrv,SCManager} $out/bin + install -m755 usr/lib/SCMiddleware/*.so $lib/lib/SCMiddleware cp -r etc/id* $lib/etc runHook postInstall ''; preFixup = '' - for elf in $lib/lib/SCMiddleware/* $out/bin/*; do - python3 /dev/fd/3 <$elf >$elf.patched 3<= len(b) - return s.replace(a, b + b'\0' * (len(a) - len(b))) - - contents = bin_replace(contents, b'/usr/lib/SCMiddleware', b'/etc/SCMiddleware') - contents = bin_replace(contents, b'/tmp/.idoss_socket', b'/run/idoss/socket') - - sys.stdout.buffer.write(contents) - EOF - - chmod --reference=$elf $elf.patched - mv $elf.patched $elf - - patchelf --set-rpath $lib/lib/SCMiddleware $elf - done + patchelf --set-rpath $lib/lib/SCMiddleware $lib/lib/SCMiddleware/* $out/bin/* ''; passthru.pkcs11-path = "lib/SCMiddleware/libidop11.so";