Skip to content

Commit 047ef3c

Browse files
committed
feat: add antigravity-nix devcontainer feature
0 parents  commit 047ef3c

4 files changed

Lines changed: 130 additions & 0 deletions

File tree

.github/workflows/release.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: "Release Dev Container Features"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
packages: write
12+
13+
jobs:
14+
deploy:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: "Publish Features"
21+
uses: devcontainers/action@v1
22+
with:
23+
publish-features: "true"
24+
base-path-to-features: "./src"
25+
generate-docs: "true"
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Devcontainer Features
2+
3+
Custom devcontainer features for Antigravity IDE development environments.
4+
5+
## Features
6+
7+
### `antigravity-nix`
8+
9+
A consolidated feature that provides:
10+
- **vscode user** (uid/gid 1000) with passwordless sudo
11+
- **Nix package manager** (single-user mode with flakes enabled)
12+
- **Essential tools**: wget, git, curl, sudo, ca-certificates
13+
14+
#### Usage
15+
16+
```json
17+
{
18+
"features": {
19+
"ghcr.io/duizendstra/devcontainer-features/antigravity-nix:1": {}
20+
}
21+
}
22+
```
23+
24+
## Publishing
25+
26+
Features are automatically published to `ghcr.io/duizendstra/devcontainer-features/` when pushed to main.
27+
28+
## Development
29+
30+
To test features locally, use the dev container CLI:
31+
32+
```bash
33+
devcontainer features test -f antigravity-nix
34+
```
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"id": "antigravity-nix",
3+
"version": "1.0.0",
4+
"name": "Antigravity Nix",
5+
"description": "Consolidated devcontainer feature: creates vscode user, installs Nix with flakes, and essential tools (wget, git, curl, sudo) for Antigravity IDE",
6+
"options": {},
7+
"containerEnv": {
8+
"NIX_CONF_DIR": "/etc/nix"
9+
}
10+
}

src/antigravity-nix/install.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "=== Antigravity Nix Feature ==="
5+
6+
# --- 1. Install essential packages ---
7+
echo "Installing essential packages..."
8+
apt-get update
9+
apt-get install -y --no-install-recommends \
10+
sudo \
11+
git \
12+
wget \
13+
curl \
14+
ca-certificates \
15+
xz-utils \
16+
gnupg
17+
rm -rf /var/lib/apt/lists/*
18+
19+
# --- 2. Create vscode user ---
20+
echo "Creating vscode user..."
21+
if ! id -u vscode > /dev/null 2>&1; then
22+
groupadd -g 1000 vscode
23+
useradd -u 1000 -g 1000 -m -s /bin/bash vscode
24+
fi
25+
echo "vscode ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/vscode
26+
chmod 0440 /etc/sudoers.d/vscode
27+
28+
# --- 3. Pre-create /nix with correct ownership ---
29+
echo "Setting up /nix directory..."
30+
mkdir -p /nix
31+
chown 1000:1000 /nix
32+
33+
# --- 4. Install Nix (single-user mode as vscode) ---
34+
echo "Installing Nix..."
35+
su - vscode -c 'curl -L https://nixos.org/nix/install | sh -s -- --no-daemon'
36+
37+
# --- 5. Configure Nix for flakes ---
38+
echo "Configuring Nix for flakes..."
39+
mkdir -p /etc/nix
40+
cat > /etc/nix/nix.conf << 'EOF'
41+
experimental-features = nix-command flakes
42+
build-users-group =
43+
EOF
44+
45+
# --- 6. Add Nix to profile for all shells ---
46+
echo "Adding Nix to shell profile..."
47+
cat >> /etc/profile.d/nix.sh << 'EOF'
48+
if [ -e '/home/vscode/.nix-profile/etc/profile.d/nix.sh' ]; then
49+
. '/home/vscode/.nix-profile/etc/profile.d/nix.sh'
50+
fi
51+
EOF
52+
53+
cat >> /etc/bash.bashrc << 'EOF'
54+
if [ -e '/home/vscode/.nix-profile/etc/profile.d/nix.sh' ]; then
55+
. '/home/vscode/.nix-profile/etc/profile.d/nix.sh'
56+
fi
57+
EOF
58+
59+
echo "=== Antigravity Nix Feature Complete ==="

0 commit comments

Comments
 (0)