diff --git a/pkgs/applications/editors/jetbrains/plugins/specialPlugins.nix b/pkgs/applications/editors/jetbrains/plugins/specialPlugins.nix index ccfd90b68b8c..dfbd81a540a0 100644 --- a/pkgs/applications/editors/jetbrains/plugins/specialPlugins.nix +++ b/pkgs/applications/editors/jetbrains/plugins/specialPlugins.nix @@ -56,6 +56,20 @@ .${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 [ @@ -77,8 +91,19 @@ value=$(expr $shift_by + $value) echo -n $value | dd of=$agent bs=1 seek=$location conv=notrunc } - fix_offset PAYLOAD_POSITION - fix_offset PRELUDE_POSITION + + 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" = { diff --git a/pkgs/applications/editors/jetbrains/plugins/tests.nix b/pkgs/applications/editors/jetbrains/plugins/tests.nix index bb182e599cac..8ebfc4194fc2 100644 --- a/pkgs/applications/editors/jetbrains/plugins/tests.nix +++ b/pkgs/applications/editors/jetbrains/plugins/tests.nix @@ -11,7 +11,6 @@ let # Known broken plugins, PLEASE remove entries here whenever possible. broken-plugins = [ - "github-copilot" # GitHub Copilot: https://github.com/NixOS/nixpkgs/issues/400317 ]; ides =