github-copilot-app: init at 1.1.11

This commit is contained in:
Rachala Raj
2026-08-20 00:51:42 +05:30
parent 9c1bfa3394
commit b362b947e5
2 changed files with 170 additions and 0 deletions

View File

@@ -0,0 +1,134 @@
{
lib,
stdenv,
fetchurl,
dpkg,
undmg,
autoPatchelfHook,
wrapGAppsHook3,
alsa-lib,
gtk3,
pango,
harfbuzz,
gdk-pixbuf,
cairo,
glib,
dbus,
webkitgtk_4_1,
atk,
libsoup_3,
openssl_3,
libayatana-appindicator,
}:
let
pname = "github-copilot-app";
version = "1.1.11";
sources = {
x86_64-linux = fetchurl {
url = "https://github.com/github/app/releases/download/v${version}/GitHub-Copilot-linux-x64.deb";
hash = "sha256-BmHuJg4fIsPp52LZ9F+9esvSNsAd9bjF4GEtfzgG7Dg=";
};
aarch64-linux = fetchurl {
url = "https://github.com/github/app/releases/download/v${version}/GitHub-Copilot-linux-arm64.deb";
hash = "sha256-AHUvg7aur4/eCo1Ewne7QWpEFsoZG7FcHPcxtbcOnyY=";
};
aarch64-darwin = fetchurl {
url = "https://github.com/github/app/releases/download/v${version}/GitHub-Copilot-darwin-arm64.dmg";
hash = "sha256-gXJp65Kf/D4m+G3BSUDJwPkdM1dx8C+vTveCUtWkUX8=";
};
};
src =
sources.${stdenv.hostPlatform.system}
or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
in
stdenv.mkDerivation {
inherit pname version src;
nativeBuildInputs =
lib.optionals stdenv.hostPlatform.isLinux [
dpkg
autoPatchelfHook
wrapGAppsHook3
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
undmg
];
buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
alsa-lib
gtk3
pango
harfbuzz
gdk-pixbuf
cairo
glib
dbus
webkitgtk_4_1
atk
libsoup_3
openssl_3
libayatana-appindicator
stdenv.cc.cc.lib
];
runtimeDependencies = lib.optionals stdenv.hostPlatform.isLinux [
libayatana-appindicator
];
dontStrip = true;
strictDeps = true;
__structuredAttrs = true;
unpackCmd = if stdenv.hostPlatform.isDarwin then "undmg $curSrc" else "dpkg-deb -x $curSrc .";
sourceRoot = ".";
installPhase = ''
runHook preInstall
''
+ (
if stdenv.hostPlatform.isDarwin then
''
mkdir -p $out/Applications
cp -r *.app $out/Applications/
mkdir -p $out/bin
ln -s "$out/Applications/"*.app/Contents/MacOS/* $out/bin/github-copilot-app
''
else
''
mkdir -p $out/bin $out/share $out/lib
cp -r usr/share/* $out/share/
cp -r usr/lib/* $out/lib/
# Rename the main executable from github to github-copilot-app to avoid conflicts
mv usr/bin/github $out/bin/github-copilot-app
cp usr/bin/git-credential-copilot $out/bin/
# Update desktop file to use the new executable name
substituteInPlace $out/share/applications/*.desktop \
--replace-fail "Exec=github" "Exec=github-copilot-app"
''
)
+ ''
runHook postInstall
'';
passthru = {
inherit sources;
updateScript = ./update.sh;
};
meta = {
description = "Agent-native desktop experience for GitHub repositories";
homepage = "https://github.com/github/app";
license = lib.licenses.unfree;
maintainers = with lib.maintainers; [ rachalaraj ];
mainProgram = "github-copilot-app";
platforms = lib.attrNames sources;
sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
};
}

View File

@@ -0,0 +1,36 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq perl nix
set -euo pipefail
ROOT="$(dirname "$(readlink -f "$0")")"
PACKAGE_NIX="$ROOT/package.nix"
latest_tag=$(curl -s ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} "https://api.github.com/repos/github/app/releases/latest" | jq -r .tag_name)
latest_version=${latest_tag#v}
current_version=$(grep -oP 'version = "\K[^"]+' "$PACKAGE_NIX")
if [[ "$current_version" == "$latest_version" ]]; then
echo "Already up-to-date: $latest_version"
exit 0
fi
sed -i "s/version = \"$current_version\"/version = \"$latest_version\"/" "$PACKAGE_NIX"
for arch in x86_64-linux aarch64-linux aarch64-darwin; do
case $arch in
x86_64-linux)
url="https://github.com/github/app/releases/download/v${latest_version}/GitHub-Copilot-linux-x64.deb"
;;
aarch64-linux)
url="https://github.com/github/app/releases/download/v${latest_version}/GitHub-Copilot-linux-arm64.deb"
;;
aarch64-darwin)
url="https://github.com/github/app/releases/download/v${latest_version}/GitHub-Copilot-darwin-arm64.dmg"
;;
esac
raw_hash=$(nix-prefetch-url "$url")
new_hash=$(nix-hash --to-sri --type sha256 "$raw_hash")
perl -0777 -pi -e "s|($arch = fetchurl \\{\\s*url = \"[^\"]+\";\\s*hash = \")[^\"]+(\";)|\${1}${new_hash}\${2}|g" "$PACKAGE_NIX"
done