Skip to content

Instantly share code, notes, and snippets.

@JonhSHEPARD
Last active August 20, 2023 00:45
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save JonhSHEPARD/ba32537a529f61f06ca571b7e62b09b2 to your computer and use it in GitHub Desktop.
Save JonhSHEPARD/ba32537a529f61f06ca571b7e62b09b2 to your computer and use it in GitHub Desktop.
Github Copilot on NixOS
#!/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_BIN/copilot-agent-linux-bin" > copilot-agent-linux
chmod +x copilot-agent-linux
echo "Everything done !"
exit 0
@Guekka
Copy link

Guekka commented Oct 3, 2022

What's this script supposed to do?
I'm trying to get Copilot working with CLion under NixOS, but I get the message "Failed to initiate the GitHub login process. Please try again"
It looks like this script did not fix it, so is it unrelated?
Thanks

@JonhSHEPARD
Copy link
Author

What's this script supposed to do? I'm trying to get Copilot working with CLion under NixOS, but I get the message "Failed to initiate the GitHub login process. Please try again" It looks like this script did not fix it, so is it unrelated? Thanks

Indeed this was made to link the missing libs needed for Copilot on Jetbrains IDE's, but I haven't looked at it for a while so it may not work properly now and needing some tweaks, or not working at all sorry

@Guekka
Copy link

Guekka commented Oct 4, 2022

No problem, thanks for replying

@amacfie
Copy link

amacfie commented Aug 20, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment