From aac5bbeb91733e4e920d512ff720ca50b1c2c725 Mon Sep 17 00:00:00 2001 From: Alejandro Soto Date: Tue, 10 Mar 2026 20:03:02 -0600 Subject: [PATCH 1/2] trivionomicon: athena-bccr: separate releases by vendor, add 'vendor' option --- modules/athena-bccr/hm.nix | 11 ++++---- modules/athena-bccr/options.nix | 48 ++++++++++++++++----------------- modules/athena-bccr/sys.nix | 14 +++++----- pkgs/athena-bccr/default.nix | 12 ++++++--- pkgs/athena-bccr/releases.nix | 42 ++++++++++++++++------------- pkgs/athena-bccr/unwrapped.nix | 3 ++- pkgs/default.nix | 3 ++- 7 files changed, 70 insertions(+), 63 deletions(-) diff --git a/modules/athena-bccr/hm.nix b/modules/athena-bccr/hm.nix index df41f12..683cb4d 100644 --- a/modules/athena-bccr/hm.nix +++ b/modules/athena-bccr/hm.nix @@ -5,12 +5,11 @@ doctrine, ... }: let - athena = - (pkgs.${doctrine.prefix}.athena-bccr.override { - inherit (cfg) mirror; - }).${ - cfg.release - }; + releases = pkgs.${doctrine.prefix}.athena-bccr.override { + inherit (cfg) mirror vendor; + }; + + athena = releases.${cfg.release}; in { home.packages = [ athena.firmador diff --git a/modules/athena-bccr/options.nix b/modules/athena-bccr/options.nix index 7b6cf93..dc4c986 100644 --- a/modules/athena-bccr/options.nix +++ b/modules/athena-bccr/options.nix @@ -1,42 +1,40 @@ {lib, ...}: -with lib.types; { +with lib.types; let + mirror = lib.mkOption { + type = nullOr str; + default = null; + description = "release zip mirror base URL, if null then the release zip must be manually added to the Nix store"; + }; + + release = lib.mkOption { + type = str; + default = "latest"; + description = "pinned athena-bccr release tag"; + }; + + vendor = lib.mkOption { + type = enum ["athena" "idopte"]; + default = "idopte"; + description = "driver dvendor"; + }; +in { hm = { + inherit mirror release vendor; + gaudiHash = lib.mkOption { type = nullOr str; default = null; description = "hash of the Gaudi client"; }; - - mirror = lib.mkOption { - type = nullOr str; - default = null; - description = "release zip mirror base URL, if null then the release zip must be manually added to the Nix store"; - }; - - release = lib.mkOption { - type = str; - default = "latest"; - description = "pinned athena-bccr release tag"; - }; }; sys = { + inherit mirror release vendor; + group = lib.mkOption { type = str; default = "users"; description = "user group with full access to the smartcard reader"; }; - - mirror = lib.mkOption { - type = nullOr str; - default = null; - description = "release zip mirror base URL, if null then the release zip must be manually added to the Nix store"; - }; - - release = lib.mkOption { - type = str; - default = "latest"; - description = "pinned athena-bccr release tag"; - }; }; } diff --git a/modules/athena-bccr/sys.nix b/modules/athena-bccr/sys.nix index bd7d758..0b4658c 100644 --- a/modules/athena-bccr/sys.nix +++ b/modules/athena-bccr/sys.nix @@ -6,17 +6,15 @@ doctrine, ... }: let - athena = - (pkgs.${doctrine.prefix}.athena-bccr.override { - inherit (cfg) mirror; - }).${ - cfg.release - }; - - inherit (athena) vendor; + releases = pkgs.${doctrine.prefix}.athena-bccr.override { + inherit (cfg) mirror vendor; + }; + athena = releases.${cfg.release}; driver = athena.card-driver.lib; scmiddleware = "${driver}/lib/SCMiddleware"; + + inherit (cfg) vendor; in { environment = { etc = diff --git a/pkgs/athena-bccr/default.nix b/pkgs/athena-bccr/default.nix index 038220b..c17911e 100644 --- a/pkgs/athena-bccr/default.nix +++ b/pkgs/athena-bccr/default.nix @@ -2,10 +2,14 @@ callPackage, lib, mirror ? null, + vendor ? "idopte", }: let - latest = "deb64-rev26.2"; + releases = lib.mapAttrs resolveRelease (import ./releases.nix).${vendor}; - releases = lib.mapAttrs (name: release: release // {name = name;}) (import ./releases.nix); + resolveRelease = name: release: + if builtins.isString release + then releases.${release} + else release // {name = name;}; overrideUnwrapped = default: new: let args = default // new; @@ -19,7 +23,7 @@ pkgsForRelease = release: let inherit (unwrapped) card-driver bccr-cacerts; - unwrapped = overrideUnwrapped {inherit mirror release;} {}; + unwrapped = overrideUnwrapped {inherit mirror release vendor;} {}; pkcs11-module = "${card-driver.lib}/${card-driver.pkcs11-path}"; in { inherit card-driver bccr-cacerts pkcs11-module; @@ -29,4 +33,4 @@ firmador = callPackage ./firmador.nix {inherit pkcs11-module;}; }; in - lib.mapAttrs (_: pkgsForRelease) (releases // {latest = releases.${latest};}) + lib.mapAttrs (_: pkgsForRelease) releases diff --git a/pkgs/athena-bccr/releases.nix b/pkgs/athena-bccr/releases.nix index cbc5bdb..203e57c 100644 --- a/pkgs/athena-bccr/releases.nix +++ b/pkgs/athena-bccr/releases.nix @@ -1,27 +1,33 @@ { - "deb64-rev26" = { - # nix hash convert --hash-algo sha256 --from base16 --to sri $(sha256sum sfd_ClientesLinux_DEB64_Rev26.zip | cut -d' ' -f1) - hash = "sha256-ZPWP9TqJQ5coJAPzUSiaXKVItBWlqFM4smCjOf+gqQM="; - filename = "sfd_ClientesLinux_DEB64_Rev26.zip"; - basename = "sfd_ClientesLinux_DEB64_Rev26"; - vendor = "athena"; + "athena" = { + latest = "deb64-rev26"; - srcPaths = { - gaudi = "Firma Digital/Agente GAUDI/agente-gaudi_20.0_amd64.deb"; - idprotect = "Firma Digital/PinTool/IDProtect PINTool 7.24.02/DEB/idprotectclient_7.24.02-0_amd64.deb"; + "deb64-rev26" = { + # nix hash convert --hash-algo sha256 --from base16 --to sri $(sha256sum sfd_ClientesLinux_DEB64_Rev26.zip | cut -d' ' -f1) + hash = "sha256-ZPWP9TqJQ5coJAPzUSiaXKVItBWlqFM4smCjOf+gqQM="; + filename = "sfd_ClientesLinux_DEB64_Rev26.zip"; + basename = "sfd_ClientesLinux_DEB64_Rev26"; + + srcPaths = { + gaudi = "Firma Digital/Agente GAUDI/agente-gaudi_20.0_amd64.deb"; + idprotect = "Firma Digital/PinTool/IDProtect PINTool 7.24.02/DEB/idprotectclient_7.24.02-0_amd64.deb"; + }; }; }; - "deb64-rev26.2" = { - # nix hash convert --hash-algo sha256 --from base16 --to sri $(sha256sum sfd_ClientesLinux_DEB64_Ubuntu24_rev26_02 | cut -d' ' -f1) - hash = "sha256-DNzP0YRnuUbfKLhi7JeQCirdGx4kM7ROqHDkTuVs0mA="; - filename = "sfd_ClientesLinux_DEB64_Ubuntu24_rev26_02.zip"; - basename = "sfd_ClientesLinux_DEB64_Ubuntu24_26_02"; - vendor = "idopte"; + "idopte" = { + latest = "deb64-rev26.2"; - srcPaths = { - gaudi = "Firma Digital/Agente GAUDI/agente-gaudi_27.0_amd64.deb"; - idopte = "Firma Digital/Idopte/Idopte_6.23.44.0_ubun24_amd64.deb"; + "deb64-rev26.2" = { + # nix hash convert --hash-algo sha256 --from base16 --to sri $(sha256sum sfd_ClientesLinux_DEB64_Ubuntu24_rev26_02 | cut -d' ' -f1) + hash = "sha256-DNzP0YRnuUbfKLhi7JeQCirdGx4kM7ROqHDkTuVs0mA="; + filename = "sfd_ClientesLinux_DEB64_Ubuntu24_rev26_02.zip"; + basename = "sfd_ClientesLinux_DEB64_Ubuntu24_26_02"; + + srcPaths = { + gaudi = "Firma Digital/Agente GAUDI/agente-gaudi_27.0_amd64.deb"; + idopte = "Firma Digital/Idopte/Idopte_6.23.44.0_ubun24_amd64.deb"; + }; }; }; } diff --git a/pkgs/athena-bccr/unwrapped.nix b/pkgs/athena-bccr/unwrapped.nix index bf99a84..dc9f142 100644 --- a/pkgs/athena-bccr/unwrapped.nix +++ b/pkgs/athena-bccr/unwrapped.nix @@ -5,9 +5,10 @@ requireFile, release, gaudiHash ? null, + vendor, ... }: let - inherit (release) srcPaths vendor; + inherit (release) srcPaths; url = if mirror != null diff --git a/pkgs/default.nix b/pkgs/default.nix index 1b11af9..6339da3 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -4,7 +4,8 @@ with prev.lib; let in { override = {}; - athena-bccr = callPackage ./athena-bccr {}; + athena-bccr = callPackage ./athena-bccr {vendor = "athena";}; + idopte-bccr = callPackage ./athena-bccr {vendor = "idopte";}; snapborg = final.python3Packages.callPackage ./snapborg {}; socialpredict = callPackage ./socialpredict {}; spliit = callPackage ./spliit {}; From 91e5edd82b1c51c5bdbdcfd32a3d055ff2954b24 Mon Sep 17 00:00:00 2001 From: Alejandro Soto Date: Mon, 23 Mar 2026 19:20:36 -0600 Subject: [PATCH 2/2] trivionomicon: ibkr-tws: initial commit --- pkgs/default.nix | 1 + pkgs/ibkr-tws/default.nix | 106 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 pkgs/ibkr-tws/default.nix diff --git a/pkgs/default.nix b/pkgs/default.nix index 6339da3..255a365 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -5,6 +5,7 @@ in { override = {}; athena-bccr = callPackage ./athena-bccr {vendor = "athena";}; + ibkr-tws = callPackage ./ibkr-tws {}; idopte-bccr = callPackage ./athena-bccr {vendor = "idopte";}; snapborg = final.python3Packages.callPackage ./snapborg {}; socialpredict = callPackage ./socialpredict {}; diff --git a/pkgs/ibkr-tws/default.nix b/pkgs/ibkr-tws/default.nix new file mode 100644 index 0000000..ea3e94b --- /dev/null +++ b/pkgs/ibkr-tws/default.nix @@ -0,0 +1,106 @@ +{ + lib, + makeWrapper, + openjdk, + requireFile, + stdenv, +}: let + version = "10.44.1g"; + + jdk = openjdk.override { + enableJavaFX = true; + }; + + removeJavaVersionCheck = file: '' + # Lie about the openjdk version to skip the version check + sed -i 's/\(read_db_entry || create_db_entry \$2\)/\1; ver_major=17; ver_minor=0; ver_micro=16/' ${file} + ''; +in + stdenv.mkDerivation { + pname = "ibkr-tws"; + inherit version; + + src = requireFile { + name = "tws-${version}-standalone-linux-x64.sh"; + url = "https://www.interactivebrokers.com/en/trading/download-tws.php?p=offline-latest"; + + # 1. Rename 'tws-latest-standalone-linux-x64.sh' to 'tws-${version}-standalone-linux-x64.sh' + # 2. nix hash convert --hash-algo sha256 --from base16 --to sri $(sha256sum tws-${version}-standalone-linux-x64.sh | cut -d' ' -f1) + hash = "sha256-UfyfTHOcPiwTof0ZMhV1haX7gyb08v7U2A12VjAny7c="; + }; + + nativeBuildInputs = [ + makeWrapper + ]; + + unpackPhase = '' + runHook preUnpack + + cp $src bundle.sh + chmod +x bundle.sh + + runHook postUnpack + ''; + + patchPhase = '' + runHook prePatch + + ${removeJavaVersionCheck "bundle.sh"} + + runHook postPatch + ''; + + preBuild = '' + export INSTALL4J_NO_DB=true + export INSTALL4J_JAVA_HOME=${jdk} + export INSTALL4J_DISABLE_BUNDLED_JRE=true + ''; + + buildPhase = '' + runHook preBuild + + # Where should Trader Workstation 10.44 be installed?: $out + # Run Trader Workstation 10.44? Yes [y], No [n, Enter]: n + echo -e "$out/lib/tws\nn" | ./bundle.sh + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + mkdir -p "$out/bin" "$out/share/applications" + + ${removeJavaVersionCheck "$out/lib/tws/tws"} + makeWrapper \ + "$out/lib/tws/tws" "$out/bin/tws" \ + --set INSTALL4J_NO_DB true \ + --set INSTALL4J_JAVA_HOME ${jdk} + + mv "$out/lib/tws/.install4j/tws.png" "$out/lib/tws" + + for path in $out/lib/tws/*.desktop; do + target="$(readlink -f "$path")" + mv "$target" "$out/share/applications/$(basename "$path")" + rm -f "$path" + done + + sed -i \ + 's@$out/lib/tws/tws\>@$out/bin/tws@; s@$out/lib/tws/.install4j/tws.png@$out/lib/tws/tws.png@' \ + $out/share/applications/*.desktop + + #TODO + sed -i \ + 's@/build/Jts@/tmp/Jts@g' \ + $out/lib/tws/.install4j/{i4jparams.conf,response.varfile} + + rm -f "$out/lib/tws/uninstall" $out/lib/tws/.install4j/*.log + + runHook postInstall + ''; + + meta = { + license = lib.licenses.unfree; + mainProgram = "tws"; + }; + }