Skip to content

Commit 64f6ecd

Browse files
committed
hack: use devbox to install nix
I use devbox to install nix in a non-root docker devcontainer environment, which the other installers (official and detsys) don't support I dont actually use any of the devbox features
1 parent 6b766b0 commit 64f6ecd

File tree

3 files changed

+35
-29
lines changed

3 files changed

+35
-29
lines changed

.devcontainer/Dockerfile

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,13 @@
1-
FROM mcr.microsoft.com/devcontainers/base:ubuntu-24.04
2-
3-
# Install dependencies for Nix
4-
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
5-
&& apt-get -y install --no-install-recommends curl xz-utils sudo systemd \
6-
&& apt-get clean && rm -rf /var/lib/apt/lists/*
7-
8-
#VOLUME /nix
9-
10-
RUN curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install linux \
11-
--extra-conf "sandbox = false" \
12-
--no-start-daemon \
13-
--no-confirm
14-
15-
ENV PATH="/nix/var/nix/profiles/default/bin:${PATH}"
16-
ENV USER=vscode
17-
18-
# Basic Nix configuration (as root)
19-
# Ensure /etc/nix exists before trying to write to nix.conf
20-
RUN mkdir -p /etc/nix && \
21-
echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf && \
22-
echo "trusted-users = root ${USER} @wheel" >> /etc/nix/nix.conf
23-
1+
# renovate: datasource=github-tags depName=devbox packageName=jetify-com/devbox
2+
ARG DEVBOX_VERSION=0.16.0
3+
FROM jetpackio/devbox:${DEVBOX_VERSION}
4+
ENV DEVBOX_USER=vscode
245
ENV HM_FLAKE_URI=github:Ramblurr/nix-agent-dev
25-
RUN . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && \
26-
nix build --impure --no-write-lock-file "${HM_FLAKE_URI}#homeConfigurations.${USER}.activationPackage" --no-link
27-
28-
USER ${USER}
29-
WORKDIR /home/${USER}
30-
ENV PATH="/nix/var/nix/profiles/default/bin:${PATH}"
6+
WORKDIR /home/${DEVBOX_USER}
7+
8+
# I use devbox to install nix in a non-root docker devcontainer environment,
9+
# which the other installers (official and detsys) don't support
10+
# I dont actually use any of the devbox features
11+
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.json devbox.json
12+
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.lock devbox.lock
13+
RUN devbox install && nix-store --gc && nix build --extra-experimental-features 'nix-command flakes' --impure --no-write-lock-file "${HM_FLAKE_URI}#homeConfigurations.${DEVBOX_USER}.activationPackage" --no-link

devbox.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.16.0/.schema/devbox.schema.json",
3+
"packages": [],
4+
"shell": {
5+
"init_hook": [
6+
"echo 'Welcome to devbox!' > /dev/null"
7+
],
8+
"scripts": {
9+
"test": [
10+
"echo \"Error: no test specified\" && exit 1"
11+
]
12+
}
13+
}
14+
}

devbox.lock

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"lockfile_version": "1",
3+
"packages": {
4+
"github:NixOS/nixpkgs/nixpkgs-unstable": {
5+
"last_modified": "2025-09-03T14:58:13Z",
6+
"resolved": "github:NixOS/nixpkgs/c6a788f552b7b7af703b1a29802a7233c0067908?lastModified=1756911493&narHash=sha256-6n%2Fn1GZQ%2Fvi%2BLhFXMSyoseKdNfc2QQaSBXJdgamrbkE%3D"
7+
}
8+
}
9+
}

0 commit comments

Comments
 (0)