Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 94 lines 2.8 kB view raw
1{ 2 delve, 3 autoPatchelfHook, 4 stdenv, 5 lib, 6 glibc, 7 gcc-unwrapped, 8}: 9# This is a list of plugins that need special treatment. For example, the go plugin (id is 9568) comes with delve, a 10# debugger, but that needs various linking fixes. The changes here replace it with the system one. 11{ 12 "631" = { 13 # Python 14 nativeBuildInputs = lib.optional stdenv.hostPlatform.isLinux autoPatchelfHook; 15 buildInputs = [ (lib.getLib stdenv.cc.cc) ]; 16 }; 17 "7322" = { 18 # Python community edition 19 nativeBuildInputs = lib.optional stdenv.hostPlatform.isLinux autoPatchelfHook; 20 buildInputs = [ (lib.getLib stdenv.cc.cc) ]; 21 }; 22 "8182" = { 23 # Rust (deprecated) 24 nativeBuildInputs = lib.optional stdenv.hostPlatform.isLinux autoPatchelfHook; 25 buildInputs = [ (lib.getLib stdenv.cc.cc) ]; 26 buildPhase = '' 27 runHook preBuild 28 chmod +x -R bin 29 runHook postBuild 30 ''; 31 }; 32 "9568" = { 33 # Go 34 buildInputs = [ delve ]; 35 buildPhase = 36 let 37 arch = 38 (if stdenv.hostPlatform.isLinux then "linux" else "mac") 39 + (if stdenv.hostPlatform.isAarch64 then "arm" else ""); 40 in 41 '' 42 runHook preBuild 43 ln -sf ${delve}/bin/dlv lib/dlv/${arch}/dlv 44 runHook postBuild 45 ''; 46 }; 47 "17718" = { 48 # Github Copilot 49 # Modified version of https://github.com/ktor/nixos/commit/35f4071faab696b2a4d86643726c9dd3e4293964 50 buildPhase = '' 51 agent='copilot-agent/native/${lib.toLower stdenv.hostPlatform.uname.system}${ 52 { 53 x86_64 = "-x64"; 54 aarch64 = "-arm64"; 55 } 56 .${stdenv.hostPlatform.uname.processor} or "" 57 }/copilot-language-server' 58 orig_size=$(stat --printf=%s $agent) 59 patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $agent 60 patchelf --set-rpath ${ 61 lib.makeLibraryPath [ 62 glibc 63 gcc-unwrapped 64 ] 65 } $agent 66 chmod +x $agent 67 new_size=$(stat --printf=%s $agent) 68 var_skip=20 69 var_select=22 70 shift_by=$(($new_size-$orig_size)) 71 function fix_offset { 72 # $1 = name of variable to adjust 73 location=$(grep -obUam1 "$1" $agent | cut -d: -f1) 74 location=$(expr $location + $var_skip) 75 value=$(dd if=$agent iflag=count_bytes,skip_bytes skip=$location \ 76 bs=1 count=$var_select status=none) 77 value=$(expr $shift_by + $value) 78 echo -n $value | dd of=$agent bs=1 seek=$location conv=notrunc 79 } 80 fix_offset PAYLOAD_POSITION 81 fix_offset PRELUDE_POSITION 82 ''; 83 }; 84 "22407" = { 85 # Rust 86 nativeBuildInputs = lib.optional stdenv.hostPlatform.isLinux autoPatchelfHook; 87 buildInputs = [ (lib.getLib stdenv.cc.cc) ]; 88 buildPhase = '' 89 runHook preBuild 90 chmod +x -R bin 91 runHook postBuild 92 ''; 93 }; 94}