Skip to content

Commit 1b3e89c

Browse files
committed
adjustments to main.tf and dockerfile in github web editor
1 parent 966998a commit 1b3e89c

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-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

+35
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ resource "coder_agent" "dev" {
4040
code-server --auth none --port 13337 &
4141
sudo service docker start
4242
coder dotfiles -y 2>&1 | tee ~/.personalize.log
43+
44+
# Install Nix into our bash profile so `nix-shell`, `nix-build, and `nix` are available
45+
echo '. /home/coder/.nix-profile/etc/profile.d/nix.sh' >> /home/coder/.bashrc
4346
EOF
4447
}
4548

@@ -86,6 +89,33 @@ resource "docker_volume" "home_volume" {
8689
}
8790
}
8891

92+
resource "docker_volume" "nix_volume" {
93+
name = "coder-${data.coder_workspace.me.id}-home"
94+
# Protect the volume from being deleted due to changes in attributes.
95+
lifecycle {
96+
ignore_changes = all
97+
}
98+
# Add labels in Docker to keep track of orphan resources.
99+
labels {
100+
label = "coder.owner"
101+
value = data.coder_workspace.me.owner
102+
}
103+
labels {
104+
label = "coder.owner_id"
105+
value = data.coder_workspace.me.owner_id
106+
}
107+
labels {
108+
label = "coder.workspace_id"
109+
value = data.coder_workspace.me.id
110+
}
111+
# This field becomes outdated if the workspace is renamed but can
112+
# be useful for debugging or cleaning out dangling volumes.
113+
labels {
114+
label = "coder.workspace_name_at_creation"
115+
value = data.coder_workspace.me.name
116+
}
117+
}
118+
89119
resource "coder_metadata" "home_info" {
90120
resource_id = docker_volume.home_volume.id
91121
item {
@@ -137,6 +167,11 @@ resource "docker_container" "workspace" {
137167
volume_name = docker_volume.home_volume.name
138168
read_only = false
139169
}
170+
volumes {
171+
container_path = "/nix"
172+
volume_name = docker_volume.nix_volume.name
173+
read_only = false
174+
}
140175
# Add labels in Docker to keep track of orphan resources.
141176
labels {
142177
label = "coder.owner"

0 commit comments

Comments
 (0)