jetbrains-plugins: fix copilot plugin (#424497)

This commit is contained in:
Morgan Jones
2025-08-09 19:33:04 +00:00
committed by GitHub
2 changed files with 27 additions and 3 deletions
@@ -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" = {
@@ -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 =