Skip to content

Commit 937d660

Browse files
authored
Merge pull request #7 from paulrbr-fl/nix-store-as-a-volym
volume: change base images to be able to mount /nix/store as volume
2 parents c17ecb7 + 63ece95 commit 937d660

File tree

4 files changed

+37
-5
lines changed

4 files changed

+37
-5
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ matrix:
1414
- env: BASE_OS=debian
1515

1616
script:
17-
- docker build --pull -t fretlink/nix ${BASE_OS}/
17+
- docker build --pull -t fretlink/nix -f ${BASE_OS}/Dockerfile .
1818
- docker run -it --rm fretlink/nix 'nix-channel --list'
1919
- docker run -it --rm fretlink/nix 'nix-env -iA nixpkgs.hello && test "$(hello)" = "Hello, world!"'

alpine/Dockerfile

+11-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,17 @@ RUN nix-channel --add https://nixos.org/channels/nixpkgs-19.09-darwin nixpkgs \
3636
# Propagate UTF8
3737
# https://github.com/NixOS/nix/issues/599#issuecomment-153885553
3838
# The same is hapenning with stack2nix
39-
RUN nix-env -iA nixpkgs.glibcLocales \
40-
&& echo "export LOCALE_ARCHIVE=$(nix-env --installed --no-name --out-path --query glibc-locales)/lib/locale/locale-archive" >> ${HOME}/.profile
39+
RUN nix-env -iA nixpkgs.glibcLocales
40+
41+
# < Nix context as a volume
42+
# We want to be able to define /nix/store as a volume
43+
# We thus need to "save" the current nix context to be able
44+
# to restore it at startup time
45+
RUN cp -R /nix /home/nixuser/initial-nix
46+
VOLUME ["/nix"]
47+
# Create bash profile
48+
COPY --chown=nixuser:nixuser files/.profile ${HOME}/.profile
49+
# />
4150

4251
# Make sure to use "login" shell when running container
4352
ENTRYPOINT ["/usr/bin/env", "bash", "-l", "-c"]

debian/Dockerfile

+11-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,17 @@ RUN nix-channel --add https://nixos.org/channels/nixpkgs-19.09-darwin nixpkgs \
3636
# Propagate UTF8
3737
# https://github.com/NixOS/nix/issues/599#issuecomment-153885553
3838
# The same is hapenning with stack2nix
39-
RUN nix-env -iA nixpkgs.glibcLocales \
40-
&& echo "export LOCALE_ARCHIVE=$(nix-env --installed --no-name --out-path --query glibc-locales)/lib/locale/locale-archive" >> ${HOME}/.profile
39+
RUN nix-env -iA nixpkgs.glibcLocales
40+
41+
# < Nix context as a volume
42+
# We want to be able to define /nix/store as a volume
43+
# We thus need to "save" the current nix context to be able
44+
# to restore it at startup time
45+
RUN cp -R /nix /home/nixuser/initial-nix
46+
VOLUME ["/nix"]
47+
# Create bash profile
48+
COPY --chown=nixuser:nixuser files/.profile ${HOME}/.profile
49+
# />
4150

4251
# Make sure to use "login" shell when running container
4352
ENTRYPOINT ["/usr/bin/env", "bash", "-l", "-c"]

files/.profile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
# Copy initial saved nix context if the /nix is empty
4+
[ ! "$(ls -A /nix)" ] && cp -R ~/initial-nix/* /nix/
5+
6+
# Source nix environment
7+
nix_profile="/home/nixuser/.nix-profile/etc/profile.d/nix.sh"
8+
# shellcheck source=/home/nixuser/.nix-profile/etc/profile.d/nix.sh
9+
[ -e "${nix_profile}" ] && . "${nix_profile}"
10+
11+
# Propagate UTF8
12+
# https://github.com/NixOS/nix/issues/599#issuecomment-153885553
13+
LOCALE_ARCHIVE="$(nix-env --installed --no-name --out-path --query glibc-locales)/lib/locale/locale-archive"
14+
export LOCALE_ARCHIVE

0 commit comments

Comments
 (0)