Skip to content

Commit 2ce88b0

Browse files
authored
feat: add devcontainer configuration with Nix support (#112)
Change-Id: I9f23638b2c61e90f4c44c7840dcb0ca32cfcdcd3 Signed-off-by: Thomas Kosiewski <[email protected]>
1 parent 9c74ead commit 2ce88b0

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM mcr.microsoft.com/devcontainers/base:ubuntu
2+
3+
# Install Nix
4+
RUN apt-get update && apt-get install -y \
5+
curl \
6+
xz-utils \
7+
sudo \
8+
&& rm -rf /var/lib/apt/lists/*
9+
10+
# Create vscode user if it doesn't exist
11+
RUN if ! id -u vscode > /dev/null 2>&1; then \
12+
useradd -m -s /bin/bash vscode && \
13+
echo "vscode ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers; \
14+
fi
15+
16+
# Switch to vscode user for Nix installation
17+
USER vscode
18+
WORKDIR /home/vscode
19+
20+
# Install Nix in single-user mode
21+
RUN curl -L https://nixos.org/nix/install | sh -s -- --no-daemon
22+
23+
# Add Nix to PATH and configure for the shell
24+
RUN echo '. /home/vscode/.nix-profile/etc/profile.d/nix.sh' >> /home/vscode/.bashrc && \
25+
mkdir -p /home/vscode/.config/nix && \
26+
echo 'experimental-features = nix-command flakes' >> /home/vscode/.config/nix/nix.conf
27+
28+
# Set up workspace directory
29+
RUN sudo mkdir -p /workspace && sudo chown vscode:vscode /workspace
30+
WORKDIR /workspace
31+
32+
# Keep container running
33+
CMD ["sleep", "infinity"]

.devcontainer/devcontainer.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "claudecode.nvim Development",
3+
"build": {
4+
"dockerfile": "Dockerfile"
5+
},
6+
"features": {
7+
"ghcr.io/devcontainers/features/git:1": {}
8+
},
9+
"customizations": {
10+
"vscode": {
11+
"settings": {
12+
"terminal.integrated.defaultProfile.linux": "bash"
13+
},
14+
"extensions": ["jnoortheen.nix-ide"]
15+
}
16+
},
17+
"postCreateCommand": "bash .devcontainer/post-create.sh",
18+
"remoteUser": "vscode",
19+
"mounts": [
20+
"source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached"
21+
],
22+
"workspaceFolder": "/workspace"
23+
}

.devcontainer/post-create.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
# Source Nix environment
4+
. /home/vscode/.nix-profile/etc/profile.d/nix.sh
5+
6+
# Verify Nix is available
7+
if ! command -v nix &>/dev/null; then
8+
echo "Error: Nix is not installed properly"
9+
exit 1
10+
fi
11+
12+
echo "✅ Nix is installed and available"
13+
echo ""
14+
echo "📦 claudecode.nvim Development Container Ready!"
15+
echo ""
16+
echo "To enter the development shell with all dependencies, run:"
17+
echo " nix develop"
18+
echo ""
19+
echo "This will provide:"
20+
echo " - Neovim"
21+
echo " - Lua and LuaJIT"
22+
echo " - busted (test framework)"
23+
echo " - luacheck (linter)"
24+
echo " - stylua (formatter)"
25+
echo " - All other development tools"
26+
echo ""
27+
echo "You can also run development commands directly:"
28+
echo " - make # Run full validation (format, lint, test)"
29+
echo " - make test # Run tests"
30+
echo " - make check # Run linter"
31+
echo " - make format # Format code"

0 commit comments

Comments
 (0)