-
-
Save ZeroDeth/d8591c1054789a21630d1c6a29ad06a0 to your computer and use it in GitHub Desktop.
Github Copilot on NixOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ "$EUID" -ne 0 ] | |
then echo "This script must be run as root" | |
exit | |
fi | |
if [ "$#" -ne 1 ]; then | |
echo "Usage: ./$0 <path-to-ide" | |
exit 1 | |
fi | |
BASE="$1" | |
COPILOT_BIN="$BASE/github-copilot-intellij/copilot-agent/bin" | |
if [ ! -d "$COPILOT_BIN" ]; then | |
echo "Copilot plugin data not found, check the specified path" | |
exit 2 | |
fi | |
STORE_PATH="/nix/store" | |
LIB_PATH="/lib64" | |
echo "Searching for necessary libs..." | |
LIB_LD=$(find "$STORE_PATH" -name "*ld-linux-x86-64.so.2" \ | |
| grep "\-glibc\-" \ | |
| head -n 1) | |
if [ -z "$LIB_LD" ]; then | |
echo "Cannot find 'ld-linux-x86-64.so.2' in nix/store" | |
exit 3 | |
else | |
echo "Found ld-linux at $LIB_LD" | |
fi | |
LIB_STDCPP=$(find "$STORE_PATH" -name "libstdc++.so.6" \ | |
| grep "\-gcc\-" \ | |
| head -n 1) | |
if [ -z "$LIB_STDCPP" ]; then | |
echo "Cannot find 'libstdc++.so.6' in nix/store" | |
exit 4 | |
else | |
echo "Found libstdc++ at $LIB_STDCPP" | |
fi | |
if [ ! -d "$LIB_PATH" ]; then | |
echo "Creating '$LIB_PATH' folder to store libraries" | |
mkdir -p "$LIB_PATH" | |
fi | |
echo "Linking '$LIB_LD' in $LIB_PATH" | |
ln -nsf "$LIB_LD" "$LIB_PATH/ld-linux-x86-64.so.2" | |
echo "Linking '$LIB_STDCPP' in $LIB_PATH" | |
ln -nsf "$LIB_STDCPP" "$LIB_PATH/libstdc++.so.6" | |
cd "$COPILOT_BIN" | |
echo "Moving copilot agent to setup the wrapper" | |
mv "copilot-agent-linux" "copilot-agent-linux-bin" | |
echo "Creating the wrapper" | |
echo "#!/bin/sh | |
export LD_LIBRARY_PATH=\"$LIB_PATH\" | |
exec ./copilot-agent-linux-bin" > copilot-agent-linux | |
chmod +x copilot-agent-linux | |
echo "Everything done !" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment