Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sharing /nix with docker #30

Open
wmertens opened this issue Jun 4, 2019 · 2 comments
Open

Sharing /nix with docker #30

wmertens opened this issue Jun 4, 2019 · 2 comments

Comments

@wmertens
Copy link

wmertens commented Jun 4, 2019

Using the delegate flag, file sharing with Docker is quite fast.

It would be great to have a minimal image that just needs nix to be installed on macos, and then it pulls it the linux dependencies, runs the image with -v /nix:/nix:delegate and then everything is cached.

@LnL7
Copy link
Owner

LnL7 commented Jun 5, 2019

This would require overlayfs otherwise this is possible with any image if nix installed on the docker host. I use the following alias with DOCKER_HOST pointing to my desktop.

nix-docker() {
    docker run --rm -it -v /nix:/nix:ro \
        -e PATH=/nix/var/nix/profiles/system/sw/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
        -e NIX_PATH=nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs \
        -e NIX_SSL_CERT_FILE=/nix/var/nix/profiles/system/etc/ssl/certs/ca-bundle.crt \
        "$@"
}
$ nix-docker alpine
/ # nix run nixpkgs.hello -c hello
[1 copied (0.2 MiB), 0.0 MiB DL]
Hello, world!

If you want to do the same thing without nix on the docker host (eg. Docker.app) it needs a writable store since builds can't go through the nix-daemon and you'd need to configure a profile with a linux binaries on your mac because everything in the image is shadowed by the mount.

@wmertens
Copy link
Author

wmertens commented Jun 7, 2019

right - so basically I need to know what I need to pull in to have the nix-base linux image in my /nix.

🤔could I maybe just run the Nix installer inside an image that only has bash?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants