Unverified Commit 2a2348ed authored by Aleksana's avatar Aleksana Committed by GitHub
Browse files

Merge pull request #327306 from Mic92/ib-controller

{ib-tws,ib-controller}: remove
parents 889e2710 e58cfebe
Loading
Loading
Loading
Loading
+0 −165
Original line number Diff line number Diff line
{ lib, stdenv, fetchFromGitHub, unzip, jdk, ib-tws, xpra }:

stdenv.mkDerivation rec {
  version = "2.14.0";
  pname = "ib-controller";

  src = fetchFromGitHub {
    owner = "ib-controller";
    repo = "ib-controller";
    rev = version;
    sha256 = "sha256-R175CKb3uErjBNe73HEFMI+bNmmuH2nWGraCSh5bXwc=";
  };

  nativeBuildInputs = [ unzip ];
  buildInputs = [ jdk ib-tws ];

  installPhase = ''
    mkdir -p $out $out/bin $out/etc/ib/controller $out/share/IBController
    cp resources/*.jar $out/share/IBController/.
    cp resources/*.ini $out/etc/ib/controller/.
    classpath=""
    for jar in ${ib-tws}/share/IBJts/*.jar; do
      classpath="$classpath:$jar"
    done
    for jar in $out/share/IBController/*.jar; do
      classpath="$classpath:$jar"
    done
    # strings to use below; separated to avoid nix specific substitutions
    javaOptions={JAVA_OPTIONS:--Xmx1024M}
    ibProfileDir={IB_PROFILE_DIR:-~/IB/}
    cat<<EOF > $out/bin/ib-tws-c
    #!$SHELL
    if [[ \$1 == /* ]] || [[ \$1 == ./* ]]; then
      IB_USER_PROFILE=\`realpath \$1\`
      IB_USER_PROFILE_TITLE=\`basename \$1\`
    else
      if [[ x\$1 != "x" ]] && [[ \$1 != -* ]]; then
        IB_USER_PROFILE=\`realpath \$$ibProfileDir\$1\`
        IB_USER_PROFILE_TITLE=\$1
      else
        echo "ERROR: \"\$1\" is not a valid name of a profile."
        exit 1
      fi
    fi
    shift
    if [ ! -e \$IB_USER_PROFILE ]; then mkdir -p \$IB_USER_PROFILE; fi
    if [ ! -d \$IB_USER_PROFILE ]; then echo "ERROR: \$IB_USER_PROFILE must be a directory!" && echo 1; fi
    if [ ! -e \$IB_USER_PROFILE/jts.ini ]; then cp ${ib-tws}/etc/ib/tws/jts.ini \$IB_USER_PROFILE/. && chmod +w \$IB_USER_PROFILE/jts.ini; fi
    if [ ! -e \$IB_USER_PROFILE/IBController.ini ]; then cp $out/etc/ib/controller/IBController.ini \$IB_USER_PROFILE/. && chmod +w \$IB_USER_PROFILE/IBController.ini; fi
    if [[ \$1 == "-q" ]]; then
      if [ -f \$IB_USER_PROFILE/xpra/run ]; then
        ${xpra}/bin/xpra stop \`cat \$IB_USER_PROFILE/xpra/run\` --socket-dir=\$IB_USER_PROFILE/xpra/ &> /dev/null
      fi
      exit 0
    fi
    if [[ \$1 == "-d" ]] && [ ! -f \$IB_USER_PROFILE/xpra/run ]; then
      ( sleep infinity ) &
      WAIT_DUMMY_PID=\$!
      ( trap "" INT;
        DISPLAYNUM=100
        while [ -f /tmp/.X\$DISPLAYNUM-lock ]; do DISPLAYNUM=\$((\$DISPLAYNUM + 1)); done
        mkdir -p \$IB_USER_PROFILE/xpra
        cd \$IB_USER_PROFILE
        nohup ${xpra}/bin/xpra start :\$DISPLAYNUM \
          --socket-dir=\$IB_USER_PROFILE/xpra/ \
          --start-child="echo -n :\$DISPLAYNUM > \$IB_USER_PROFILE/xpra/run \
                         && kill \$WAIT_DUMMY_PID &> /dev/null \
                         && ${jdk}/bin/java -cp $classpath \$$javaOptions ibcontroller.IBController \$IB_USER_PROFILE/IBController.ini" \
          --exit-with-children \
          --no-pulseaudio \
          --no-mdns \
          --no-notification \
          --no-daemon \
          &> \$IB_USER_PROFILE/xpra/server.log
        rm -f \$IB_USER_PROFILE/xpra/run
        rm -f /tmp/.X\$DISPLAYNUM-lock
      ) &
      wait \$WAIT_DUMMY_PID
      exit 0
    fi
    if [ -f \$IB_USER_PROFILE/xpra/run ]; then
      ${xpra}/bin/xpra attach \`cat \$IB_USER_PROFILE/xpra/run\` --socket-dir=\$IB_USER_PROFILE/xpra/ \
      --windows \
      --no-speaker \
      --no-microphone \
      --no-tray \
      --title="\$IB_USER_PROFILE_TITLE: @title@" \
      &> \$IB_USER_PROFILE/xpra/client.log
    fi
    EOF
    chmod u+x $out/bin/ib-tws-c
    cat<<EOF > $out/bin/ib-gw-c
    #!$SHELL
    if [[ \$1 == /* ]] || [[ \$1 == ./* ]]; then
      IB_USER_PROFILE=\`realpath \$1\`
      IB_USER_PROFILE_TITLE=\`basename \$1\`
    else
      if [[ x\$1 != "x" ]] && [[ \$1 != -* ]]; then
        IB_USER_PROFILE=\`realpath \$$ibProfileDir\$1\`
        IB_USER_PROFILE_TITLE=\$1
      else
        echo "ERROR: \"\$1\" is not a valid name of a profile."
        exit 1
      fi
    fi
    shift
    if [ ! -e \$IB_USER_PROFILE ]; then mkdir -p \$IB_USER_PROFILE; fi
    if [ ! -d \$IB_USER_PROFILE ]; then echo "ERROR: \$IB_USER_PROFILE must be a directory!" && echo 1; fi
    if [ ! -e \$IB_USER_PROFILE/jts.ini ]; then cp ${ib-tws}/etc/ib/tws/jts.ini \$IB_USER_PROFILE/. && chmod +w \$IB_USER_PROFILE/jts.ini; fi
    if [ ! -e \$IB_USER_PROFILE/IBController.ini ]; then cp $out/etc/ib/controller/IBController.ini \$IB_USER_PROFILE/. && chmod +w \$IB_USER_PROFILE/IBController.ini; fi
    if [[ \$1 == "-q" ]]; then
      if [ -f \$IB_USER_PROFILE/xpra/run ]; then
        ${xpra}/bin/xpra stop \`cat \$IB_USER_PROFILE/xpra/run\` --socket-dir=\$IB_USER_PROFILE/xpra/ &> /dev/null
      fi
      exit 0
    fi
    if [[ \$1 == "-d" ]] && [ ! -f \$IB_USER_PROFILE/xpra/run ]; then
      ( sleep infinity ) &
      WAIT_DUMMY_PID=\$!
      ( trap "" INT;
        DISPLAYNUM=100
        while [ -f /tmp/.X\$DISPLAYNUM-lock ]; do DISPLAYNUM=\$((\$DISPLAYNUM + 1)); done
        mkdir -p \$IB_USER_PROFILE/xpra
        cd \$IB_USER_PROFILE
        nohup ${xpra}/bin/xpra start :\$DISPLAYNUM \
          --socket-dir=\$IB_USER_PROFILE/xpra/ \
          --start-child="echo -n :\$DISPLAYNUM > \$IB_USER_PROFILE/xpra/run \
                         && kill \$WAIT_DUMMY_PID &> /dev/null \
                         && ${jdk}/bin/java -cp $classpath \$$javaOptions ibcontroller.IBGatewayController \$IB_USER_PROFILE/IBController.ini" \
          --exit-with-children \
          --no-pulseaudio \
          --no-mdns \
          --no-notification \
          --no-daemon \
          &> \$IB_USER_PROFILE/xpra/server.log
        rm -f \$IB_USER_PROFILE/xpra/run
        rm -f /tmp/.X\$DISPLAYNUM-lock
      ) &
      wait \$WAIT_DUMMY_PID
      exit 0
    fi
    if [ -f \$IB_USER_PROFILE/xpra/run ]; then
      ${xpra}/bin/xpra attach \`cat \$IB_USER_PROFILE/xpra/run\` --socket-dir=\$IB_USER_PROFILE/xpra/ \
      --windows \
      --no-speaker \
      --no-microphone \
      --no-tray \
      --title="\$IB_USER_PROFILE_TITLE: @title@" \
      &> \$IB_USER_PROFILE/xpra/client.log
    fi
    EOF
    chmod u+x $out/bin/ib-gw-c
  '';


  meta = with lib; {
    description = "Automation Controller for the Trader Work Station of Interactive Brokers";
    broken = true;  # Ref: https://github.com/NixOS/nixpkgs/issues/40784
    homepage = "https://github.com/ib-controller/ib-controller";
    sourceProvenance = with sourceTypes; [ binaryBytecode ];
    license = licenses.gpl3;
    maintainers = [ ];
    platforms = platforms.linux;
  };
}
+0 −96
Original line number Diff line number Diff line
{ lib, stdenv, requireFile, jdk }:

stdenv.mkDerivation rec {
  version = "9542";
  pname = "ib-tws";

  src = requireFile rec {
    name = "ibtws_${version}.jar";
    message = ''
      This nix expression requires that ${name} is already part of the store.
      Download the TWS from
      https://download2.interactivebrokers.com/download/unixmacosx_latest.jar,
      rename the file to ${name}, and add it to the nix store with
      "nix-prefetch-url file://\$PWD/${name}".
    '';
    sha256 = "1a2jiwwnr5g3xfba1a89c257bdbnq4zglri8hz021vk7f6s4rlrf";
  };

  buildInputs = [ jdk ];

  buildPhase = ''
    jar -xf IBJts/jts.jar
    cp trader/common/images/ibapp_icon.gif ibtws_icon.gif
    '';

  unpackPhase = ''
    jar xf ${src}
    '';

  installPhase = ''
    mkdir -p $out $out/bin $out/etc/ib/tws $out/share/IBJts $out/share/icons
    cp IBJts/*.jar $out/share/IBJts/.
    cp IBJts/*.ini $out/etc/ib/tws/.
    cp ibtws_icon.gif $out/share/icons/.
    classpath=""
    for jar in $out/share/IBJts/*.jar; do
      classpath="$classpath:$jar"
    done
    # strings to use below; separated to avoid nix specific substitutions
    javaOptions={JAVA_OPTIONS:-'-Xmx1024M -Dawt.useSystemAAFontSettings=lcd -Dsun.java2d.xrender=True -Dsun.java2d.opengl=False'}
    # OTHER JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java
    ibProfileDir={IB_PROFILE_DIR:-~/IB/}
    cat<<EOF > $out/bin/ib-tws
    #!$SHELL
    if [[ \$1 == /* ]] || [[ \$1 == ./* ]]; then
      IB_USER_PROFILE=\`realpath \$1\`
      IB_USER_PROFILE_TITLE=\`basename \$1\`
    else
      if [[ x\$1 != "x" ]] && [[ \$1 != -* ]]; then
        IB_USER_PROFILE=\`realpath \$$ibProfileDir\$1\`
        IB_USER_PROFILE_TITLE=\$1
      else
        echo "ERROR: \"\$1\" is not a valid name of a profile."
        exit 1
      fi
    fi
    shift
    if [ ! -e \$IB_USER_PROFILE ]; then mkdir -p \$IB_USER_PROFILE; fi
    if [ ! -d \$IB_USER_PROFILE ]; then echo "ERROR: \$IB_USER_PROFILE must be a directory!" && echo 1; fi
    if [ ! -e \$IB_USER_PROFILE/jts.ini ]; then cp $out/etc/ib/tws/jts.ini \$IB_USER_PROFILE/. && chmod +w \$IB_USER_PROFILE/jts.ini; fi
    ${jdk}/bin/java -cp $classpath \$$javaOptions jclient.LoginFrame \$IB_USER_PROFILE
    EOF
    chmod u+x $out/bin/ib-tws
    cat<<EOF > $out/bin/ib-gw
    #!$SHELL
    if [[ \$1 == /* ]] || [[ \$1 == ./* ]]; then
      IB_USER_PROFILE=\`realpath \$1\`
      IB_USER_PROFILE_TITLE=\`basename \$1\`
    else
      if [[ x\$1 != "x" ]] && [[ \$1 != -* ]]; then
        IB_USER_PROFILE=\`realpath \$$ibProfileDir\$1\`
        IB_USER_PROFILE_TITLE=\$1
      else
        echo "ERROR: \"\$1\" is not a valid name of a profile."
        exit 1
      fi
    fi
    shift
    if [ ! -e \$IB_USER_PROFILE ]; then mkdir -p \$IB_USER_PROFILE; fi
    if [ ! -d \$IB_USER_PROFILE ]; then echo "ERROR: \$IB_USER_PROFILE must be a directory!" && echo 1; fi
    if [ ! -e \$IB_USER_PROFILE/jts.ini ]; then cp $out/etc/ib/tws/jts.ini \$IB_USER_PROFILE/. && chmod +w \$IB_USER_PROFILE/jts.ini; fi
    ${jdk}/bin/java -cp $classpath -Dsun.java2d.noddraw=true \$$javaOptions ibgateway.GWClient \$IB_USER_PROFILE
    EOF
    chmod u+x $out/bin/ib-gw
    '';

  meta = with lib; {
    description = "Trader Work Station of Interactive Brokers";
    broken = true;  # Ref: https://github.com/NixOS/nixpkgs/issues/40784
    homepage = "https://www.interactivebrokers.com";
    sourceProvenance = with sourceTypes; [ binaryBytecode ];
    license = licenses.unfree;
    maintainers = [ ];
    platforms = platforms.linux;
  };
}
+2 −0
Original line number Diff line number Diff line
@@ -609,6 +609,8 @@ mapAliases ({
  ### I ###

  i3-gaps = i3; # Added 2023-01-03
  ib-tws = throw "ib-tws has been removed from nixpkgs as it was broken"; # Added 2024-07-15
  ib-controller = throw "ib-controller has been removed from nixpkgs as it was broken"; # Added 2024-07-15
  icedtea8_web = throw "'icedtea8_web' has been renamed to/replaced by 'adoptopenjdk-icedtea-web'"; # Converted to throw 2023-09-10
  icedtea_web = throw "'icedtea_web' has been renamed to/replaced by 'adoptopenjdk-icedtea-web'"; # Converted to throw 2023-09-10
  ignite = throw "'ignite' has been removed as the upstream project was archived, please use 'flintlock' instead"; # Added 2024-01-07
+0 −4
Original line number Diff line number Diff line
@@ -39675,10 +39675,6 @@ with pkgs;
  tewi-font = callPackage ../data/fonts/tewi { };
  ib-tws = callPackage ../applications/office/ib/tws { jdk=oraclejdk8; };
  ib-controller = callPackage ../applications/office/ib/controller { jdk=oraclejdk8; };
  vcluster = callPackage ../applications/networking/cluster/vcluster { };
  sshportal = callPackage ../servers/sshportal { };