Skip to content

Commit 718a44a

Browse files
feat(antigravity-hub): init at 2.0.1
1 parent e00d35b commit 718a44a

3 files changed

Lines changed: 396 additions & 0 deletions

File tree

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
{
2+
lib,
3+
stdenv,
4+
fetchurl,
5+
autoPatchelfHook,
6+
makeWrapper,
7+
alsa-lib,
8+
at-spi2-atk,
9+
at-spi2-core,
10+
atk,
11+
cairo,
12+
cups,
13+
dbus,
14+
expat,
15+
fontconfig,
16+
freetype,
17+
gdk-pixbuf,
18+
glib,
19+
gsettings-desktop-schemas,
20+
gtk3,
21+
libdrm,
22+
libgbm,
23+
libGL,
24+
libglvnd,
25+
libnotify,
26+
libpulseaudio,
27+
libsecret,
28+
libuuid,
29+
libxml2,
30+
libxkbcommon,
31+
mesa,
32+
nspr,
33+
nss,
34+
pango,
35+
systemd,
36+
vulkan-loader,
37+
wayland,
38+
libX11,
39+
libXcomposite,
40+
libXcursor,
41+
libXdamage,
42+
libXext,
43+
libXfixes,
44+
libXi,
45+
libXrandr,
46+
libXrender,
47+
libXt,
48+
libXtst,
49+
libxcb,
50+
libxshmfence,
51+
xdg-utils,
52+
passwordStore ? "basic",
53+
}:
54+
55+
let
56+
inherit (stdenv) hostPlatform;
57+
58+
desktopLibs = [
59+
alsa-lib
60+
at-spi2-atk
61+
at-spi2-core
62+
atk
63+
cairo
64+
cups
65+
dbus
66+
expat
67+
fontconfig
68+
freetype
69+
gdk-pixbuf
70+
glib
71+
gsettings-desktop-schemas
72+
gtk3
73+
libdrm
74+
libgbm
75+
libGL
76+
libglvnd
77+
libnotify
78+
libpulseaudio
79+
libsecret
80+
libuuid
81+
libxml2
82+
libxkbcommon
83+
mesa
84+
nspr
85+
nss
86+
pango
87+
stdenv.cc.cc
88+
systemd
89+
vulkan-loader
90+
wayland
91+
libX11
92+
libXcomposite
93+
libXcursor
94+
libXdamage
95+
libXext
96+
libXfixes
97+
libXi
98+
libXrandr
99+
libXrender
100+
libXt
101+
libXtst
102+
libxcb
103+
libxshmfence
104+
];
105+
106+
desktopSrcs = {
107+
x86_64-linux = {
108+
url = "https://storage.googleapis.com/antigravity-public/antigravity-hub/2.0.1-6566078776737792/linux-x64/Antigravity.tar.gz";
109+
hash = "sha256-Byfh9WlhttI0eUHyeNppzGwX3jvv6YhSSEjNFnOA6as=";
110+
sourceRoot = "Antigravity-x64";
111+
};
112+
aarch64-linux = {
113+
url = "https://storage.googleapis.com/antigravity-public/antigravity-hub/2.0.1-6566078776737792/linux-arm/Antigravity.tar.gz";
114+
hash = "sha256-WvVsyd2pVPNpphBFt9ovNIvLCzUH0nK0wOmqfNYXXZs=";
115+
sourceRoot = "Antigravity-arm64";
116+
};
117+
};
118+
119+
source = desktopSrcs.${hostPlatform.system}
120+
or (throw "antigravity-hub: unsupported system ${hostPlatform.system}");
121+
in
122+
stdenv.mkDerivation {
123+
pname = "antigravity-hub";
124+
version = "2.0.1";
125+
126+
src = fetchurl {
127+
inherit (source) url hash;
128+
};
129+
130+
sourceRoot = source.sourceRoot;
131+
132+
nativeBuildInputs = [
133+
autoPatchelfHook
134+
makeWrapper
135+
];
136+
137+
buildInputs = desktopLibs;
138+
139+
installPhase = ''
140+
runHook preInstall
141+
mkdir -p $out/share/antigravity
142+
cp -r . $out/share/antigravity/
143+
144+
mkdir -p $out/bin
145+
makeWrapper $out/share/antigravity/antigravity $out/bin/antigravity \
146+
--add-flags "--no-sandbox" \
147+
${lib.optionalString (passwordStore != "") "--add-flags \"--password-store=${passwordStore}\""} \
148+
--prefix PATH : ${lib.makeBinPath [ xdg-utils ]} \
149+
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath desktopLibs} \
150+
--prefix XDG_DATA_DIRS : "${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}" \
151+
--prefix XDG_DATA_DIRS : "${gtk3}/share/gsettings-schemas/${gtk3.name}"
152+
153+
mkdir -p $out/share/applications
154+
cat > $out/share/applications/antigravity-hub.desktop << EOF
155+
[Desktop Entry]
156+
Name=Antigravity
157+
Comment=Antigravity 2 - Agent-first development platform
158+
Exec=$out/bin/antigravity %U
159+
Terminal=false
160+
Type=Application
161+
Categories=Development;
162+
StartupWMClass=Antigravity
163+
EOF
164+
runHook postInstall
165+
'';
166+
167+
passthru.updateScript = ./update.sh;
168+
169+
meta = with lib; {
170+
description = "Antigravity 2";
171+
homepage = "https://antigravity.google";
172+
license = licenses.unfree;
173+
platforms = [ "x86_64-linux" "aarch64-linux" ];
174+
mainProgram = "antigravity";
175+
maintainers = with maintainers; [ ];
176+
};
177+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env nix-shell
2+
#!nix-shell -i bash -p curl jq nix
3+
4+
set -euo pipefail
5+
6+
# Fetch latest release
7+
LATEST_RELEASE=$(curl -s "https://antigravity-auto-updater-974169037036.us-central1.run.app/releases" | jq -r '.[0]')
8+
NEW_VERSION=$(echo "$LATEST_RELEASE" | jq -r '.version')
9+
NEW_EXEC_ID=$(echo "$LATEST_RELEASE" | jq -r '.execution_id')
10+
11+
# Find current version
12+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
13+
PACKAGE_NIX="$DIR/package.nix"
14+
CURRENT_VERSION=$(grep -oP 'version = "\K[^"]+' "$PACKAGE_NIX" | head -n1)
15+
16+
if [[ "$CURRENT_VERSION" == "$NEW_VERSION" ]]; then
17+
echo "Antigravity Hub is already up to date ($CURRENT_VERSION)"
18+
exit 0
19+
fi
20+
21+
echo "Updating Antigravity Hub from $CURRENT_VERSION to $NEW_VERSION (exec id $NEW_EXEC_ID)..."
22+
23+
URL_X64="https://storage.googleapis.com/antigravity-public/antigravity-hub/${NEW_VERSION}-${NEW_EXEC_ID}/linux-x64/Antigravity.tar.gz"
24+
URL_ARM="https://storage.googleapis.com/antigravity-public/antigravity-hub/${NEW_VERSION}-${NEW_EXEC_ID}/linux-arm/Antigravity.tar.gz"
25+
26+
echo "Fetching hash for x86_64-linux..."
27+
HASH_X64=$(nix-prefetch-url "$URL_X64")
28+
HASH_X64_SRI=$(nix hash to-sri --type sha256 "$HASH_X64")
29+
30+
echo "Fetching hash for aarch64-linux..."
31+
HASH_ARM=$(nix-prefetch-url "$URL_ARM")
32+
HASH_ARM_SRI=$(nix hash to-sri --type sha256 "$HASH_ARM")
33+
34+
# Extract current hashes
35+
CURRENT_HASH_X64=$(grep -B1 'sourceRoot = "Antigravity-x64"' "$PACKAGE_NIX" | grep 'hash =' | grep -oP 'hash = "\K[^"]+')
36+
CURRENT_HASH_ARM=$(grep -B1 'sourceRoot = "Antigravity-arm64"' "$PACKAGE_NIX" | grep 'hash =' | grep -oP 'hash = "\K[^"]+')
37+
38+
# Replace version
39+
sed -i "s/version = \"$CURRENT_VERSION\"/version = \"$NEW_VERSION\"/" "$PACKAGE_NIX"
40+
41+
# Replace urls
42+
sed -i -E "s|https://storage\.googleapis\.com/antigravity-public/antigravity-hub/[^/]+/linux-x64/Antigravity\.tar\.gz|$URL_X64|" "$PACKAGE_NIX"
43+
sed -i -E "s|https://storage\.googleapis\.com/antigravity-public/antigravity-hub/[^/]+/linux-arm/Antigravity\.tar\.gz|$URL_ARM|" "$PACKAGE_NIX"
44+
45+
# Replace hashes
46+
if [[ -n "$CURRENT_HASH_X64" ]]; then
47+
sed -i "s|$CURRENT_HASH_X64|$HASH_X64_SRI|" "$PACKAGE_NIX"
48+
fi
49+
50+
if [[ -n "$CURRENT_HASH_ARM" ]]; then
51+
sed -i "s|$CURRENT_HASH_ARM|$HASH_ARM_SRI|" "$PACKAGE_NIX"
52+
fi
53+
54+
echo "Successfully updated to $NEW_VERSION."
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
{
2+
stdenv,
3+
lib,
4+
fetchFromGitHub,
5+
fetchFromGitLab,
6+
meson,
7+
ninja,
8+
pkg-config,
9+
desktop-file-utils,
10+
appstream,
11+
vte-gtk4,
12+
gtksourceview5,
13+
gjs,
14+
libadwaita,
15+
vala,
16+
blueprint-compiler,
17+
wrapGAppsHook4,
18+
libportal-gtk4,
19+
libshumate,
20+
webkitgtk_6_0,
21+
rustc,
22+
cargo,
23+
nodejs,
24+
typescript,
25+
python3,
26+
glib,
27+
gtk4,
28+
}:
29+
30+
let
31+
troll = fetchFromGitHub {
32+
owner = "sonnyp";
33+
repo = "troll";
34+
rev = "8b0275948eedec9ed0378f9bdda1aa4aac3062ba";
35+
hash = "sha256-gpQcRofE9ZG0DNCwjz06a7citmxEox+k2wxb3mDJLaE=";
36+
};
37+
demos = fetchFromGitHub {
38+
owner = "workbenchdev";
39+
repo = "demos";
40+
rev = "5efa50c4692da433fdd9ce696b329ebcea03fb1b";
41+
hash = "sha256-Sk4g9yDr5bpHnu73nwECmnZfnsTxZfGeC4Ax8+0wu/c=";
42+
};
43+
gi-types = fetchFromGitLab {
44+
domain = "gitlab.gnome.org";
45+
owner = "BrainBlasted";
46+
repo = "gi-typescript-definitions";
47+
rev = "396fe147142e28a921f0745eff1a562c7a551843";
48+
hash = "sha256-HhL9Nwmf7Z4P//6aCBXonZImSAM+U7xv7+ELKPO8OS4=";
49+
};
50+
in
51+
52+
stdenv.mkDerivation rec {
53+
pname = "workbench";
54+
version = "49.0";
55+
56+
src = fetchFromGitHub {
57+
owner = "workbenchdev";
58+
repo = "Workbench";
59+
rev = "v${version}";
60+
hash = "sha256-MvSC1yDiluFOgawtzgsY7a/wcjHuot+ne5UhtNl4/ps=";
61+
};
62+
63+
postUnpack = ''
64+
for dir in troll demos gi-types; do
65+
rm -rf $sourceRoot/$dir
66+
done
67+
cp -r ${troll} $sourceRoot/troll
68+
cp -r ${demos} $sourceRoot/demos
69+
cp -r ${gi-types} $sourceRoot/gi-types
70+
chmod -R u+w $sourceRoot/troll $sourceRoot/demos $sourceRoot/gi-types
71+
'';
72+
73+
postPatch = ''
74+
# Remove Flatpak-only check
75+
substituteInPlace src/bin.js \
76+
--replace-fail 'if (!Xdp.Portal.running_under_flatpak())' 'if (false)'
77+
78+
# Make getFlatpakInfo return a fake KeyFile with plausible values when not in Flatpak
79+
cat > src/flatpak.js << 'FLATPAK_EOF'
80+
import GLib from "gi://GLib";
81+
82+
let flatpak_info;
83+
export function getFlatpakInfo() {
84+
if (flatpak_info) return flatpak_info;
85+
flatpak_info = new GLib.KeyFile();
86+
try {
87+
flatpak_info.load_from_file("/.flatpak-info", GLib.KeyFileFlags.NONE);
88+
} catch (err) {
89+
// Not running in Flatpak — provide sensible defaults
90+
flatpak_info.set_string("Application", "name", "re.sonny.Workbench");
91+
flatpak_info.set_string("Application", "runtime", "org.gnome.Platform/x86_64/49");
92+
flatpak_info.set_string("Instance", "flatpak-version", "1.15.6");
93+
}
94+
return flatpak_info;
95+
}
96+
97+
export function getFlatpakId() {
98+
return getFlatpakInfo().get_string("Application", "name");
99+
}
100+
101+
export function isDeviceInputOverrideAvailable(_flatpak_version) {
102+
return true;
103+
}
104+
FLATPAK_EOF
105+
106+
# Patch library.js install script to skip Flatpak runtime version check
107+
sed -i '/const key_file/,/\.split/c\const runtime_version = "49";' build-aux/library.js
108+
109+
# Fix shebangs that use /usr/bin/env
110+
substituteInPlace troll/gjspack/bin/gjspack \
111+
--replace-fail "#!/usr/bin/env -S gjs -m" "#!${gjs}/bin/gjs -m"
112+
substituteInPlace build-aux/library.js \
113+
--replace-fail "#!/usr/bin/env -S gjs -m" "#!${gjs}/bin/gjs -m"
114+
'';
115+
116+
preFixup = ''
117+
sed -e '2iimports.package._findEffectiveEntryPointName = () => "re.sonny.Workbench"' \
118+
-i $out/bin/re.sonny.Workbench
119+
gappsWrapperArgs+=(
120+
--prefix PATH : $out/bin
121+
--prefix PATH : ${lib.makeBinPath [
122+
blueprint-compiler
123+
vala
124+
]}
125+
)
126+
'';
127+
128+
dontPatchShebangs = true;
129+
130+
nativeBuildInputs = [
131+
blueprint-compiler
132+
cargo
133+
desktop-file-utils
134+
appstream
135+
gjs
136+
glib
137+
gtk4
138+
meson
139+
ninja
140+
pkg-config
141+
rustc
142+
vala
143+
wrapGAppsHook4
144+
];
145+
146+
buildInputs = [
147+
gjs
148+
gtksourceview5
149+
libadwaita
150+
libportal-gtk4
151+
libshumate
152+
vte-gtk4
153+
webkitgtk_6_0
154+
];
155+
156+
doCheck = false;
157+
158+
meta = with lib; {
159+
description = "Learn and prototype with GNOME technologies";
160+
homepage = "https://github.com/workbenchdev/Workbench";
161+
license = licenses.gpl3Only;
162+
maintainers = with maintainers; [ onny ];
163+
platforms = platforms.linux;
164+
};
165+
}

0 commit comments

Comments
 (0)