Persist nix store
This commit is contained in:
parent
732bbef79f
commit
70ee088919
|
@ -30,5 +30,15 @@ RUN curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/
|
||||||
# Now use devbox as global package manager
|
# Now use devbox as global package manager
|
||||||
RUN echo 'eval "$(devbox global shellenv --preserve-path-stack -r)" && hash -r' >> ~/.bashrc
|
RUN echo 'eval "$(devbox global shellenv --preserve-path-stack -r)" && hash -r' >> ~/.bashrc
|
||||||
|
|
||||||
|
# Backup of the nix-store
|
||||||
|
RUN cp -a /nix/store /nix-store-backup
|
||||||
|
|
||||||
|
# Add start script
|
||||||
|
COPY scripts/start.sh /usr/local/bin/start.sh
|
||||||
|
RUN chmod +x /usr/local/bin/start.sh
|
||||||
|
|
||||||
|
# Set start script as entrypoint
|
||||||
|
ENTRYPOINT ["/usr/local/bin/start.sh"]
|
||||||
|
|
||||||
WORKDIR /workspace
|
WORKDIR /workspace
|
||||||
CMD ["sh"]
|
CMD ["sh"]
|
|
@ -16,6 +16,12 @@ services:
|
||||||
- ../devbox.lock:/root/.local/share/devbox/global/default/devbox.lock
|
- ../devbox.lock:/root/.local/share/devbox/global/default/devbox.lock
|
||||||
# mount workspace
|
# mount workspace
|
||||||
- ../src:/workspace
|
- ../src:/workspace
|
||||||
|
# persist nix-store
|
||||||
|
- nix-store:/nix
|
||||||
# vscode needs a running container, so we make its shell interactive
|
# vscode needs a running container, so we make its shell interactive
|
||||||
stdin_open: true # docker run -i
|
stdin_open: true # docker run -i
|
||||||
tty: true # docker run -t
|
tty: true # docker run -t
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
nix-store:
|
||||||
|
external: true
|
12
.devcontainer/scripts/start.sh
Normal file
12
.devcontainer/scripts/start.sh
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Checks if /nix/store is empty
|
||||||
|
if [ -z "$(ls -A /nix/store)" ]; then
|
||||||
|
echo "Nix store volume is empty. Copying pre-filled store from image."
|
||||||
|
cp -a /nix-store-backup/. /nix/store/
|
||||||
|
else
|
||||||
|
echo "Nix store volume is not empty. Skipping copy."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start the normal container process
|
||||||
|
exec "$@"
|
Loading…
Reference in New Issue
Block a user