Skip to content

Commit 46c6a38

Browse files
committed
adjustments to main.tf and dockerfile in github web editor
1 parent 9402c6f commit 46c6a38

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

dogfood/Dockerfile

Lines changed: 0 additions & 3 deletions
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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ resource "coder_agent" "dev" {
3434
code-server --auth none --port 13337 &
3535
sudo service docker start
3636
coder dotfiles -y 2>&1 | tee ~/.personalize.log
37+
38+
# Install Nix into our bash profile so `nix-shell`, `nix-build, and `nix` are available
39+
echo '. /home/coder/.nix-profile/etc/profile.d/nix.sh' >> /home/coder/.bashrc
3740
EOF
3841
}
3942

@@ -80,6 +83,33 @@ resource "docker_volume" "home_volume" {
8083
}
8184
}
8285

86+
resource "docker_volume" "nix_volume" {
87+
name = "coder-${data.coder_workspace.me.id}-home"
88+
# Protect the volume from being deleted due to changes in attributes.
89+
lifecycle {
90+
ignore_changes = all
91+
}
92+
# Add labels in Docker to keep track of orphan resources.
93+
labels {
94+
label = "coder.owner"
95+
value = data.coder_workspace.me.owner
96+
}
97+
labels {
98+
label = "coder.owner_id"
99+
value = data.coder_workspace.me.owner_id
100+
}
101+
labels {
102+
label = "coder.workspace_id"
103+
value = data.coder_workspace.me.id
104+
}
105+
# This field becomes outdated if the workspace is renamed but can
106+
# be useful for debugging or cleaning out dangling volumes.
107+
labels {
108+
label = "coder.workspace_name_at_creation"
109+
value = data.coder_workspace.me.name
110+
}
111+
}
112+
83113
resource "coder_metadata" "home_info" {
84114
resource_id = docker_volume.home_volume.id
85115
item {
@@ -128,6 +158,11 @@ resource "docker_container" "workspace" {
128158
volume_name = docker_volume.home_volume.name
129159
read_only = false
130160
}
161+
volumes {
162+
container_path = "/nix"
163+
volume_name = docker_volume.nix_volume.name
164+
read_only = false
165+
}
131166
# Add labels in Docker to keep track of orphan resources.
132167
labels {
133168
label = "coder.owner"

0 commit comments

Comments
 (0)