lol

Merge pull request #201518 from hacker1024/package/github-copilot-intellij-agent

authored by

Sandro and committed by
GitHub
a21c873f f038daef

+84
+82
pkgs/development/tools/github-copilot-intellij-agent/default.nix
··· 1 + { stdenv, lib, fetchurl, unzip }: 2 + 3 + stdenv.mkDerivation rec { 4 + pname = "github-copilot-intellij-agent"; 5 + version = "1.2.8.2631"; 6 + 7 + src = fetchurl { 8 + name = "${pname}-${version}-plugin.zip"; 9 + url = "https://plugins.jetbrains.com/plugin/download?updateId=341846"; 10 + hash = "sha256-0nnSMdx9Vb2WyNHreOJMP15K1+AII/kCEAOiFK5Mhik="; 11 + }; 12 + 13 + nativeBuildInputs = [ unzip ]; 14 + 15 + dontUnpack = true; 16 + 17 + installPhase = '' 18 + runHook preInstall 19 + 20 + mkdir -p $out/bin 21 + unzip -p $src github-copilot-intellij/copilot-agent/bin/copilot-agent-${ 22 + if stdenv.isDarwin then (if stdenv.isAarch64 then "macos-arm64" else "macos") else "linux" 23 + } | install -m755 /dev/stdin $out/bin/copilot-agent 24 + 25 + runHook postInstall 26 + ''; 27 + 28 + # https://discourse.nixos.org/t/unrelatable-error-when-working-with-patchelf/12043 29 + # https://github.com/NixOS/nixpkgs/blob/db0d8e10fc1dec84f1ccb111851a82645aa6a7d3/pkgs/development/web/now-cli/default.nix 30 + preFixup = let 31 + binaryLocation = "$out/bin/copilot-agent"; 32 + libPath = lib.makeLibraryPath [ stdenv.cc.cc ]; 33 + in '' 34 + orig_size=$(stat --printf=%s ${binaryLocation}) 35 + 36 + patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" ${binaryLocation} 37 + patchelf --set-rpath ${libPath} ${binaryLocation} 38 + chmod +x ${binaryLocation} 39 + 40 + new_size=$(stat --printf=%s ${binaryLocation}) 41 + 42 + var_skip=20 43 + var_select=22 44 + shift_by=$(expr $new_size - $orig_size) 45 + 46 + function fix_offset { 47 + location=$(grep -obUam1 "$1" ${binaryLocation} | cut -d: -f1) 48 + location=$(expr $location + $var_skip) 49 + value=$(dd if=${binaryLocation} iflag=count_bytes,skip_bytes skip=$location \ 50 + bs=1 count=$var_select status=none) 51 + value=$(expr $shift_by + $value) 52 + echo -n $value | dd of=${binaryLocation} bs=1 seek=$location conv=notrunc 53 + } 54 + 55 + fix_offset PAYLOAD_POSITION 56 + fix_offset PRELUDE_POSITION 57 + ''; 58 + 59 + dontStrip = true; 60 + 61 + meta = rec { 62 + description = "The GitHub copilot IntelliJ plugin's native component"; 63 + longDescription = '' 64 + The GitHub copilot IntelliJ plugin's native component. 65 + bin/copilot-agent must be symlinked into the plugin directory, replacing the existing binary. 66 + 67 + For example: 68 + 69 + ```shell 70 + ln -fs /run/current-system/sw/bin/copilot-agent ~/.local/share/JetBrains/IntelliJIdea2022.2/github-copilot-intellij/copilot-agent/bin/copilot-agent-linux 71 + ``` 72 + ''; 73 + homepage = "https://plugins.jetbrains.com/plugin/17718-github-copilot"; 74 + downloadPage = homepage; 75 + changelog = homepage; 76 + license = lib.licenses.unfree; 77 + maintainers = with lib.maintainers; [ hacker1024 ]; 78 + mainProgram = "copilot-agent"; 79 + platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ]; 80 + sourceProvenance = [ lib.sourceTypes.binaryNativeCode ]; 81 + }; 82 + }
+2
pkgs/top-level/all-packages.nix
··· 3548 3548 3549 3549 github-commenter = callPackage ../development/tools/github-commenter { }; 3550 3550 3551 + github-copilot-intellij-agent = callPackage ../development/tools/github-copilot-intellij-agent { }; 3552 + 3551 3553 github-desktop = callPackage ../applications/version-management/github-desktop { 3552 3554 openssl = openssl_1_1; 3553 3555 curl = curl.override { openssl = openssl_1_1; };