Skip to content

Commit

Permalink
ib tws latest
Browse files Browse the repository at this point in the history
  • Loading branch information
Czichy committed Mar 1, 2025
1 parent e99d20d commit 5cbf967
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 58 deletions.
67 changes: 31 additions & 36 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,24 @@
debug = true;
};
inputs = {
# --- BASE DEPENDENCIES ---
# --- BASE DEPENDENCIES -----------------------------------------
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-parts.url = "github:hercules-ci/flake-parts";
home-manager = {
url = "github:nix-community/home-manager/master";
inputs.nixpkgs.follows = "nixpkgs";
};
impermanence.url = "github:nix-community/impermanence";
systems.url = "github:nix-systems/default";

# --- DEV DEPENDENCIES ---
microvm = {
url = "github:astro/microvm.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# --- DEV DEPENDENCIES ------------------------------------------
devenv.url = "github:cachix/devenv";
devenv-root = {
url = "file+file:///dev/null";
Expand All @@ -58,7 +70,7 @@
};
treefmt-nix.url = "github:numtide/treefmt-nix";

# --- SECRET DEPENDENCIES --
# --- SECRET DEPENDENCIES ---------------------------------------
agenix = {
url = "github:ryantm/agenix";
# url = "github:yaxitech/ragenix";
Expand All @@ -74,28 +86,13 @@
flake = false;
};

# --- (NOTE, YOUR) EXTRA DEPENDENCIES --
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager/master";
inputs.nixpkgs.follows = "nixpkgs";
};
impermanence.url = "github:nix-community/impermanence";

# --- UTILITIES -------------------------------------------------
nixGL = {
url = "github:nix-community/nixGL";
inputs.nixpkgs.follows = "nixpkgs";
};
hardware.url = "github:NixOS/nixos-hardware/master";

microvm = {
url = "github:astro/microvm.nix";
inputs.nixpkgs.follows = "nixpkgs";
};

nix-topology = {
url = "github:oddlama/nix-topology";
inputs.nixpkgs.follows = "nixpkgs";
Expand All @@ -113,8 +110,6 @@
inputs.nixpkgs.follows = "nixpkgs";
};

#nur.url = "github:nix-community/NUR";

arkenfox-user-js = {
url = "github:arkenfox/user.js";
flake = false;
Expand All @@ -129,8 +124,22 @@
flake = false;
};

# Sandbox wrappers for programs
nixpak = {
url = "github:nixpak/nixpak";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-parts.follows = "flake-parts";
};
};
# This exists, I guess
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
nix-alien.url = "github:thiagokokada/nix-alien";

# --- PACKAGES --------------------------------------------------
plasma-manager = {
url = "github:pjones/plasma-manager";
inputs.nixpkgs.follows = "nixpkgs";
Expand Down Expand Up @@ -158,25 +167,11 @@
};
};

# Sandbox wrappers for programs
nixpak = {
url = "github:nixpak/nixpak";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-parts.follows = "flake-parts";
};
};

nix-minecraft = {
url = "github:Misterio77/nix-minecraft";
inputs.nixpkgs.follows = "nixpkgs";
};

# This exists, I guess
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
ibkr-rust = {
url = "github:czichy/ibkr-rust";
};
Expand Down
1 change: 1 addition & 0 deletions hosts/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
nix-topology.nixosModules.default
nixos-nftables-firewall.nixosModules.default
microvm.nixosModules.host
# nur.modules.nixos.default
];
}
);
Expand Down
1 change: 1 addition & 0 deletions modules/home-manager/programs/ib-tws.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
lib,
system,
hostName,
pkgs,
...
}:
with builtins;
Expand Down
14 changes: 0 additions & 14 deletions modules/home-manager/services/keepassxc.nix
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
# --- parts/modules/home-manager/services/keepassxc.nix
#
# Author: czichy <[email protected]>
# URL: https://github.com/czichy/tensorfiles
# License: MIT
#
# 888 .d888 d8b 888
# 888 d88P" Y8P 888
# 888 888 888
# 888888 .d88b. 88888b. .d8888b .d88b. 888d888 888888 888 888 .d88b. .d8888b
# 888 d8P Y8b 888 "88b 88K d88""88b 888P" 888 888 888 d8P Y8b 88K
# 888 88888888 888 888 "Y8888b. 888 888 888 888 888 888 88888888 "Y8888b.
# Y88b. Y8b. 888 888 X88 Y88..88P 888 888 888 888 Y8b. X88
# "Y888 "Y8888 888 888 88888P' "Y88P" 888 888 888 888 "Y8888 88888P'
{localFlake}: {
config,
lib,
Expand Down
169 changes: 161 additions & 8 deletions parts/pkgs/ibtws_latest/default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{pkgs ? import <nixpkgs> {}}:
with pkgs; let
jdkWithJavaFX = pkgs.jdk11.override {
jdkWithJavaFX = pkgs.jdk21.override {
enableJavaFX = true;
openjfx = openjfx.override {withWebKit = true;};
openjfx21 = openjfx.override {withWebKit = true;};
};
ibDerivation = stdenv.mkDerivation rec {
version = "10.34.1c";
Expand Down Expand Up @@ -34,11 +34,11 @@ with pkgs; let
# The following disables the JRE compatability check inside the tws script
# so that we can use Oracle JRE pkgs of nixpkgs.
sed -i 's#test_jvm "$INSTALL4J_JAVA_HOME_OVERRIDE"#app_java_home="$INSTALL4J_JAVA_HOME_OVERRIDE"#' $out/libexec/tws-latest
sed -i 's#test_jvm "$INSTALL4J_JAVA_HOME_OVERRIDE"#app_java_home="$INSTALL4J_JAVA_HOME_OVERRIDE"#' $out/libexec/tws
# Make the tws launcher script read $HOME/.tws/tws.vmoptions
# instead of the unmutable version in $out.
sed -i -e 's#read_vmoptions "$prg_dir/$progname.vmoptions"#read_vmoptions "$HOME/.tws-latest/$progname.vmoptions"#' $out/libexec/tws-latest
sed -i -e 's#read_vmoptions "$prg_dir/$progname.vmoptions"#read_vmoptions "$HOME/.tws/$progname.vmoptions"#' $out/libexec/tws
# We set a bunch of flags found in the Arch PKGBUILD. The flags
# releated to AA fonts seem to make a positive difference.
Expand All @@ -47,9 +47,9 @@ with pkgs; let
# -Dsun.java2d.opengl=False not applied. Why would I disable that?
# -Dswing.aatext=true applied
mkdir $out/bin
sed -e s#__OUT__#$out# -e s#__JAVAHOME__#${jdkWithJavaFX.home}# -e s#__GTK__#${pkgs.gtk3}# -e s#__CCLIBS__#${pkgs.stdenv.cc.cc.lib}# ${./tws-wrap.sh} > $out/bin/ib-tws-latest
sed -e s#__OUT__#$out# -e s#__JAVAHOME__#${jdkWithJavaFX.home}# -e s#__GTK__#${pkgs.gtk3}# -e s#__CCLIBS__#${pkgs.stdenv.cc.cc.lib}# ${./tws-wrap.sh} > $out/bin/ib-tws-native
chmod a+rx $out/bin/ib-tws-latest
chmod a+rx $out/bin/ib-tws-native
# FIXME Fixup .desktop starter.
'';
Expand All @@ -68,7 +68,7 @@ with pkgs; let
# code.
in
buildFHSUserEnv {
name = "ib-tws-latest";
name = "ib-tws";
targetPkgs = pkgs1: [
ibDerivation

Expand Down Expand Up @@ -99,12 +99,164 @@ in
libxkbcommon
systemd # for libudev.so.1
];
runScript = "/usr/bin/ib-tws-latest";
runScript = "/usr/bin/ib-tws-native";
}
# {
# stdenv,
# lib,
# fetchurl,
# patchelf,
# makeDesktopItem,
# copyDesktopItems,
# libXxf86vm,
# libX11,
# libXext,
# libXtst,
# libXi,
# libXrender,
# glib,
# libxml2,
# ffmpeg,
# libGL,
# freetype,
# fontconfig,
# gtk3,
# pango,
# cairo,
# alsa-lib,
# atk,
# gdk-pixbuf,
# }: let
# rSubPaths = [
# "lib/amd64/jli"
# "lib/amd64/server"
# "lib/amd64"
# ];
# in
# stdenv.mkDerivation rec {
# pname = "ib-tws";
# version = "10.34.1c";
# etagHash = "28ba9461d0de56b53efc7a4106389df5";
# src = fetchurl {
# url = "https://download2.interactivebrokers.com/installers/tws/latest-standalone/tws-latest-standalone-linux-x64.sh";
# hash = "sha256-bpFKD1l8PwAV2g7MjApg3QC0TAO76VPHLiI5rGcfcSs=";
# };
# phases = ["unpackPhase" "installPhase" "fixupPhase"];
# nativeBuildInputs = [copyDesktopItems];
# desktopItems = [
# (makeDesktopItem {
# name = pname;
# desktopName = "IB Trader Workstation";
# exec = pname;
# icon = pname;
# categories = ["Office" "Finance"];
# startupWMClass = "jclient-LoginFrame";
# })
# (makeDesktopItem {
# name = "ib-gw";
# desktopName = "IB Gateway";
# exec = "ib-gw";
# icon = pname;
# categories = ["Office" "Finance"];
# startupWMClass = "ibgateway-GWClient";
# })
# ];
# unpackPhase = ''
# echo "Unpacking I4J sfx sh to $PWD..."
# INSTALL4J_TEMP="$PWD" sh "$src" __i4j_extract_and_exit
# # JRE
# jrePath="$out/share/${pname}/jre"
# echo "Unpacking JRE to $jrePath..."
# mkdir -p "$jrePath"
# tar -xf "$PWD/"*.dir/jre.tar.gz -C "$jrePath/"
# echo "Patching JRE executables..."
# patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
# "$jrePath/bin/java" "$jrePath/bin/unpack200"
# echo "Unpacking JRE pack files..."
# for f in "$jrePath/lib/"*.jar.pack "$jrePath/lib/ext/"*.jar.pack; do
# jar_file=`echo "$f" | awk '{ print substr($0,1,length($0)-5) }'`
# "$jrePath/bin/unpack200" -r "$f" "$jar_file"
# [ $? -ne 0 ] && echo "Error unpacking $f" && exit 1
# done
# echo "Unpacking TWS payload..."
# INSTALL4J_JAVA_HOME_OVERRIDE="$jrePath" sh "$src" -q -dir "$PWD/"
# '';
# installPhase = ''
# runHook preInstall
# # create main startup script
# mkdir -p "$out/bin"
# cat<<EOF > "$out/bin/${pname}"
# #!$SHELL
# # get script name
# PROG=\$(basename "\$0")
# # Load system-wide settings and per-user overrides
# IB_CONFIG_DIR="\$HOME/.\$PROG"
# JAVA_GC="-Xmx4G -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:ParallelGCThreads=20 -XX:ConcGCThreads=5 -XX:InitiatingHeapOccupancyPercent=70"
# JAVA_UI_FLAGS="-Dswing.aatext=TRUE -Dawt.useSystemAAFontSettings=on -Dsun.awt.nopixfmt=true -Dsun.java2d.noddraw=true -Dswing.boldMetal=false -Dsun.locale.formatasdefault=true"
# JAVA_LOCALE_FLAGS="-Dsun.locale.formatasdefault=true"
# JAVA_FLAGS="\$JAVA_GC \$JAVA_UI_FLAGS \$JAVA_LOCALE_FLAGS \$JAVA_EXTRA_FLAGS"
# [ -f "\$HOME/.config/\$PROG.conf" ] && . "\$HOME/.config/\$PROG.conf"
# CLASS="jclient.LoginFrame"
# [ "\$PROG" = "ib-gw" ] && CLASS="ibgateway.GWClient"
# cd "$out/share/${pname}/jars"
# "$out/share/${pname}/jre/bin/java" -cp \* \$JAVA_FLAGS \$CLASS \$IB_CONFIG_DIR
# EOF
# chmod u+x $out/bin/${pname}
# # create symlink for the gateway
# ln -s "${pname}" "$out/bin/ib-gw"
# # copy files
# mkdir -p $out/share/${pname}
# cp -R jars $out/share/${pname}
# install -Dm644 .install4j/tws.png $out/share/pixmaps/${pname}.png
# runHook postInstall
# '';
# dontPatchELF = true;
# dontStrip = true;
# postFixup = ''
# rpath+="''${rpath:+:}${lib.concatStringsSep ":" (map (a: "$jrePath/${a}") rSubPaths)}"
# # set all the dynamic linkers
# find $out -type f -perm -0100 \
# -exec patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
# --set-rpath "$rpath" {} \;
# find $out -name "*.so" -exec patchelf --set-rpath "$rpath" {} \;
# '';
# rpath = lib.strings.makeLibraryPath libraries;
# libraries = [
# stdenv.cc
# stdenv.cc.libc
# glib
# libxml2
# ffmpeg
# libGL
# libXxf86vm
# alsa-lib
# fontconfig
# freetype
# pango
# gtk3
# cairo
# gdk-pixbuf
# atk
# libX11
# libXext
# libXtst
# libXi
# libXrender
# ];
# # possibly missing libgdk-x11-2.0.so.0, from gtk2? never caused any trouble though
# passthru.updateScript = ./update.sh;
# meta = with lib; {
# description = "Trader Work Station of Interactive Brokers";
# homepage = "https://www.interactivebrokers.com";
# license = licenses.unfree;
# maintainers = lib.optionals (maintainers ? k3a) [maintainers.k3a];
# platforms = ["x86_64-linux"];
# };
# }
# {
# stdenv,
# lib,
# fetchurl,
# makeDesktopItem,
# copyDesktopItems,
# libXxf86vm,
Expand Down Expand Up @@ -177,6 +329,7 @@ in
# jrePath="$out/share/${pname}/jre"
# echo "Unpacking JRE to $jrePath..."
# mkdir -p "$jrePath"
# mkdir -p "$jrePath/bin"
# tar -xf "$PWD/"*.dir/jre.tar.gz -C "$jrePath/"
# echo "Patching JRE executables..."
# patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
Expand Down

0 comments on commit 5cbf967

Please sign in to comment.