Skip to content

Commit

Permalink
Merge pull request #7 from paulrbr-fl/nix-store-as-a-volym
Browse files Browse the repository at this point in the history
volume: change base images to be able to mount /nix/store as volume
  • Loading branch information
paulrbr-fl authored Feb 5, 2020
2 parents c17ecb7 + 63ece95 commit 937d660
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ matrix:
- env: BASE_OS=debian

script:
- docker build --pull -t fretlink/nix ${BASE_OS}/
- docker build --pull -t fretlink/nix -f ${BASE_OS}/Dockerfile .
- docker run -it --rm fretlink/nix 'nix-channel --list'
- docker run -it --rm fretlink/nix 'nix-env -iA nixpkgs.hello && test "$(hello)" = "Hello, world!"'
13 changes: 11 additions & 2 deletions alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,17 @@ RUN nix-channel --add https://nixos.org/channels/nixpkgs-19.09-darwin nixpkgs \
# Propagate UTF8
# https://github.com/NixOS/nix/issues/599#issuecomment-153885553
# The same is hapenning with stack2nix
RUN nix-env -iA nixpkgs.glibcLocales \
&& echo "export LOCALE_ARCHIVE=$(nix-env --installed --no-name --out-path --query glibc-locales)/lib/locale/locale-archive" >> ${HOME}/.profile
RUN nix-env -iA nixpkgs.glibcLocales

# < Nix context as a volume
# We want to be able to define /nix/store as a volume
# We thus need to "save" the current nix context to be able
# to restore it at startup time
RUN cp -R /nix /home/nixuser/initial-nix
VOLUME ["/nix"]
# Create bash profile
COPY --chown=nixuser:nixuser files/.profile ${HOME}/.profile
# />

# Make sure to use "login" shell when running container
ENTRYPOINT ["/usr/bin/env", "bash", "-l", "-c"]
13 changes: 11 additions & 2 deletions debian/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,17 @@ RUN nix-channel --add https://nixos.org/channels/nixpkgs-19.09-darwin nixpkgs \
# Propagate UTF8
# https://github.com/NixOS/nix/issues/599#issuecomment-153885553
# The same is hapenning with stack2nix
RUN nix-env -iA nixpkgs.glibcLocales \
&& echo "export LOCALE_ARCHIVE=$(nix-env --installed --no-name --out-path --query glibc-locales)/lib/locale/locale-archive" >> ${HOME}/.profile
RUN nix-env -iA nixpkgs.glibcLocales

# < Nix context as a volume
# We want to be able to define /nix/store as a volume
# We thus need to "save" the current nix context to be able
# to restore it at startup time
RUN cp -R /nix /home/nixuser/initial-nix
VOLUME ["/nix"]
# Create bash profile
COPY --chown=nixuser:nixuser files/.profile ${HOME}/.profile
# />

# Make sure to use "login" shell when running container
ENTRYPOINT ["/usr/bin/env", "bash", "-l", "-c"]
14 changes: 14 additions & 0 deletions files/.profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

# Copy initial saved nix context if the /nix is empty
[ ! "$(ls -A /nix)" ] && cp -R ~/initial-nix/* /nix/

# Source nix environment
nix_profile="/home/nixuser/.nix-profile/etc/profile.d/nix.sh"
# shellcheck source=/home/nixuser/.nix-profile/etc/profile.d/nix.sh
[ -e "${nix_profile}" ] && . "${nix_profile}"

# Propagate UTF8
# https://github.com/NixOS/nix/issues/599#issuecomment-153885553
LOCALE_ARCHIVE="$(nix-env --installed --no-name --out-path --query glibc-locales)/lib/locale/locale-archive"
export LOCALE_ARCHIVE

0 comments on commit 937d660

Please sign in to comment.