Unverified Commit 09af4be6 authored by Matt Sturgeon's avatar Matt Sturgeon Committed by GitHub
Browse files

jetbrains: drop bundled plugins (#470147)

parents fc3cf179 1daa63c6
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -31,6 +31,11 @@

- All Log4Shell vulnerability scanners were removed, as they were all unmaintained upstream and are no longer relevant given that the vulnerability has been fixed upstream for several years.

- Plugins for the JetBrains IDEs have been removed from Nixpkgs.

- `jetbrains.plugins.addPlugins` no longer supports plugin names or ID strings.
  You can still use `addPlugins` with plugin derivations, such as plugins packaged outside of Nixpkgs.

- `asio` (standalone version of `boost::asio`) has been updated from 1.24.0 to 1.36.0. Some breaking changes were introduced between these
  two versions, and the one affected most was the removal of `asio::io_service` in favor of `asio::io_context` in 1.33.0. `asio_1_32_0` is
  retained for packages that have not completed migration. `asio_1_10` has been removed as no packages depend on it anymore.
+0 −4
Original line number Diff line number Diff line
@@ -145,7 +145,3 @@ for name in toVersions.keys():
# Commit the result
logging.info("#### Committing changes... ####")
subprocess.run(['git', 'commit', f'-m{commitMessage}', '--', f'{versions_file_path}'], check=True)

logging.info("#### Updating plugins ####")
plugin_script = current_path.joinpath("../plugins/update_plugins.py").resolve()
subprocess.call(plugin_script)
+4 −78
Original line number Diff line number Diff line
@@ -8,77 +8,7 @@
  glib,
  darwin,
}:

let
  pluginsJson = builtins.fromJSON (builtins.readFile ./plugins.json);
  specialPluginsInfo = callPackage ./specialPlugins.nix { };
  fetchPluginSrc =
    url: hash:
    let
      isJar = lib.hasSuffix ".jar" url;
      fetcher = if isJar then fetchurl else fetchzip;
    in
    fetcher {
      executable = isJar;
      inherit url hash;
    };
  files = builtins.mapAttrs (key: value: fetchPluginSrc key value) pluginsJson.files;
  ids = builtins.attrNames pluginsJson.plugins;

  mkPlugin =
    id: file:
    if !specialPluginsInfo ? "${id}" then
      files."${file}"
    else
      stdenv.mkDerivation (
{
          name = "jetbrains-plugin-${id}";
          installPhase = ''
            runHook preInstall
            mkdir -p $out && cp -r . $out
            runHook postInstall
          '';
          src = files."${file}";
        }
        // specialPluginsInfo."${id}"
      );

  selectFile =
    id: ide: build:
    let
      # Allow all PyCharm/IDEA plugins for PyCharm/IDEA Community
      # - TODO: Remove this special case once PyCharm/IDEA Community is removed
      communityCheck =
        (id != "pycharm-community" || builtins.elem ide pluginsJson.plugins.pycharm.compatible)
        || (id != "idea-community" || builtins.elem ide pluginsJson.plugins.idea.compatible);
    in
    if !communityCheck && !builtins.elem ide pluginsJson.plugins."${id}".compatible then
      throw "Plugin with id ${id} does not support IDE ${ide}"
    else if !pluginsJson.plugins."${id}".builds ? "${build}" then
      throw "Jetbrains IDEs with build ${build} are not in nixpkgs. Try update_plugins.py with --with-build?"
    else if pluginsJson.plugins."${id}".builds."${build}" == null then
      throw "Plugin with id ${id} does not support build ${build}"
    else
      pluginsJson.plugins."${id}".builds."${build}";

  byId = builtins.listToAttrs (
    map (id: {
      name = id;
      value = ide: build: mkPlugin id (selectFile id ide build);
    }) ids
  );

  byName = builtins.listToAttrs (
    map (id: {
      name = pluginsJson.plugins."${id}".name;
      value = byId."${id}";
    }) ids
  );
in
{
  # Only use if you know what youre doing
  raw = { inherit files byId byName; };

  tests = callPackage ./tests.nix { };

  addPlugins =
@@ -86,14 +16,10 @@ in
    let
      processPlugin =
        plugin:
        if lib.isDerivation plugin then
          plugin
        else if byId ? "${plugin}" then
          byId."${plugin}" ide.pname ide.buildNumber
        else if byName ? "${plugin}" then
          byName."${plugin}" ide.pname ide.buildNumber
        else
          throw "Could not resolve plugin ${plugin}";
        # We can remove this check and just asume plugins to be derivations starting with 26.11.
        lib.throwIfNot (lib.isDerivation plugin)
          "addPlugins no longer supports resolving plugins by name or id strings. Please supply a derivation instead"
          plugin;

      plugins = map processPlugin unprocessedPlugins;
    in
+0 −2098

File deleted.

Preview size limit exceeded, changes collapsed.

+0 −119
Original line number Diff line number Diff line
{
  delve,
  autoPatchelfHook,
  stdenv,
  lib,
  glibc,
  gcc-unwrapped,
}:
# This is a list of plugins that need special treatment. For example, the go plugin (id is 9568) comes with delve, a
# debugger, but that needs various linking fixes. The changes here replace it with the system one.
{
  "631" = {
    # Python
    nativeBuildInputs = lib.optional stdenv.hostPlatform.isLinux autoPatchelfHook;
    buildInputs = [ (lib.getLib stdenv.cc.cc) ];
  };
  "7322" = {
    # Python community edition
    nativeBuildInputs = lib.optional stdenv.hostPlatform.isLinux autoPatchelfHook;
    buildInputs = [ (lib.getLib stdenv.cc.cc) ];
  };
  "8182" = {
    # Rust (deprecated)
    nativeBuildInputs = lib.optional stdenv.hostPlatform.isLinux autoPatchelfHook;
    buildInputs = [ (lib.getLib stdenv.cc.cc) ];
    buildPhase = ''
      runHook preBuild
      chmod +x -R bin
      runHook postBuild
    '';
  };
  "9568" = {
    # Go
    buildInputs = [ delve ];
    buildPhase =
      let
        arch =
          (if stdenv.hostPlatform.isLinux then "linux" else "mac")
          + (if stdenv.hostPlatform.isAarch64 then "arm" else "");
      in
      ''
        runHook preBuild
        ln -sf ${delve}/bin/dlv lib/dlv/${arch}/dlv
        runHook postBuild
      '';
  };
  "17718" = {
    # Github Copilot
    # Modified version of https://github.com/ktor/nixos/commit/35f4071faab696b2a4d86643726c9dd3e4293964
    buildPhase = ''
      agent='copilot-agent/native/${lib.toLower stdenv.hostPlatform.uname.system}${
        {
          x86_64 = "-x64";
          aarch64 = "-arm64";
        }
        .${stdenv.hostPlatform.uname.processor} or ""
      }/copilot-language-server'
      orig_size=$(stat --printf=%s $agent)

      find_payload_offset() {
        grep -aobUam1 -f <(printf '\x1f\x8b\x08\x00') "$agent" | cut -d: -f1
      }

      # Helper: find the offset of the prelude by searching for function string start
      find_prelude_offset() {
        local prelude_string='(function(process, require, console, EXECPATH_FD, PAYLOAD_POSITION, PAYLOAD_SIZE) {'
        grep -obUa -- "$prelude_string" "$agent" | cut -d: -f1
      }

      before_payload_position="$(find_payload_offset)"
      before_prelude_position="$(find_prelude_offset)"

      patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $agent
      patchelf --set-rpath ${
        lib.makeLibraryPath [
          glibc
          gcc-unwrapped
        ]
      } $agent
      chmod +x $agent
      new_size=$(stat --printf=%s $agent)
      var_skip=20
      var_select=22
      shift_by=$(($new_size-$orig_size))
      function fix_offset {
        # $1 = name of variable to adjust
        location=$(grep -obUam1 "$1" $agent | cut -d: -f1)
        location=$(expr $location + $var_skip)
        value=$(dd if=$agent iflag=count_bytes,skip_bytes skip=$location \
        bs=1 count=$var_select status=none)
        value=$(expr $shift_by + $value)
        echo -n $value | dd of=$agent bs=1 seek=$location conv=notrunc
      }

      after_payload_position="$(find_payload_offset)"
      after_prelude_position="$(find_prelude_offset)"

      if [ "${stdenv.hostPlatform.system}" == "aarch64-linux" ]
      then
        fix_offset PAYLOAD_POSITION
        fix_offset PRELUDE_POSITION
      else
        # There are hardcoded positions in the binary, then it replaces the placeholders by himself
        sed -i -e "s/$before_payload_position/$after_payload_position/g" "$agent"
        sed -i -e "s/$before_prelude_position/$after_prelude_position/g" "$agent"
      fi
    '';
  };
  "22407" = {
    # Rust
    nativeBuildInputs = lib.optional stdenv.hostPlatform.isLinux autoPatchelfHook;
    buildInputs = [ (lib.getLib stdenv.cc.cc) ];
    buildPhase = ''
      runHook preBuild
      chmod +x -R bin
      runHook postBuild
    '';
  };
}
Loading