Skip to content

Commit a516413

Browse files
committed
hopefully the final review iteration, thanks for your help!
1 parent 0872948 commit a516413

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

dogfood/Dockerfile

-3
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,6 @@ RUN tar -xf "nix-${NIX_VERSION}-x86_64-linux.tar.xz" \
333333
&& bash "nix-${NIX_VERSION}-x86_64-linux/install" "--no-daemon" \
334334
&& rm -rf "nix-${NIX_VERSION}-x86_64-linux.tar.xz"
335335

336-
# Install Nix into our bash profile so `nix-shell`, `nix-build, and `nix` are available
337-
RUN echo '. /home/coder/.nix-profile/etc/profile.d/nix.sh' >> /home/coder/.bashrc
338-
339336
# Enable installation of unfree software - https://nixos.wiki/wiki/FAQ/How_can_I_install_a_proprietary_or_unfree_package
340337
RUN mkdir -p /home/coder/.config/nixpkgs && echo '{ allowUnfree = true; }' >> /home/coder/.config/nixpkgs/config.nix
341338

dogfood/main.tf

+37
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ resource "coder_agent" "dev" {
5656
if [ -n "$DOTFILES_URI" ]; then
5757
coder dotfiles "$DOTFILES_URI" -y 2>&1 | tee ~/.personalize.log
5858
fi
59+
60+
61+
# Install Nix into our bash profile so `nix-shell`, `nix-build, and `nix` are available
62+
echo '. /home/coder/.nix-profile/etc/profile.d/nix.sh' >> /home/coder/.bashrc
63+
bash /opt/nix/install --no-daemon
5964
EOF
6065
}
6166

@@ -102,6 +107,33 @@ resource "docker_volume" "home_volume" {
102107
}
103108
}
104109

110+
resource "docker_volume" "nix_volume" {
111+
name = "coder-${data.coder_workspace.me.id}-nix"
112+
# Protect the volume from being deleted due to changes in attributes.
113+
lifecycle {
114+
ignore_changes = all
115+
}
116+
# Add labels in Docker to keep track of orphan resources.
117+
labels {
118+
label = "coder.owner"
119+
value = data.coder_workspace.me.owner
120+
}
121+
labels {
122+
label = "coder.owner_id"
123+
value = data.coder_workspace.me.owner_id
124+
}
125+
labels {
126+
label = "coder.workspace_id"
127+
value = data.coder_workspace.me.id
128+
}
129+
# This field becomes outdated if the workspace is renamed but can
130+
# be useful for debugging or cleaning out dangling volumes.
131+
labels {
132+
label = "coder.workspace_name_at_creation"
133+
value = data.coder_workspace.me.name
134+
}
135+
}
136+
105137
resource "coder_metadata" "home_info" {
106138
resource_id = docker_volume.home_volume.id
107139
item {
@@ -153,6 +185,11 @@ resource "docker_container" "workspace" {
153185
volume_name = docker_volume.home_volume.name
154186
read_only = false
155187
}
188+
volumes {
189+
container_path = "/nix"
190+
volume_name = docker_volume.nix_volume.name
191+
read_only = false
192+
}
156193
# Add labels in Docker to keep track of orphan resources.
157194
labels {
158195
label = "coder.owner"

0 commit comments

Comments
 (0)