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
Add instructions to build in Docker for Mac #584
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bxrt ❤️
I added few things which I hope will make the instructions even easier.
|
||
In your favourite macOS terminal: | ||
|
||
$ docker run -p 8000:8000 -it --name nixos-homepage nixos/nix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ docker run -p 8000:8000 -it --name nixos-homepage nixos/nix | |
$ git clone https://github.com/NixOS/nixos-homepage.git | |
$ cd nixos-homepage | |
$ docker run -v $PWD:/work -w /work -p 8000:8000 -it --name nixos-homepage nixos/nix nix-shell |
It would be better if git is used from the operating system. I think we can expect this to be installed on macos. I realize that then we have to fix default.nix
and shell.nix
a bit (which I already did).
This would avoid running nix-shell in nix-shell, since fd
and entr
are already present in development environment of nixos-homepage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@garbas, thanks. My change puts everything in the container. I agree that it is nicer to have the sources on the macos-side and mount those as a volume in the container as you suggest. I tried this and the nix-shell
command is successful. So that's great. However, make
then fails in the container:
[...]
nix-build -A packages.x86_64-linux.siteStyles --out-link styles
error: creating symlink from '/work/styles.tmp-16815-189614047' to '/nix/store/d9f5ppqpx1p6cswpg3wlzy5dwy7sdwi5-nixos-homepage-styles': Operation not permitted
make: *** [Makefile:199: styles] Error 1
I don't know how to fix this. Please advice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I do have ideas on how to fix this, but that involves changing how the build is done and that goes beyond the scope of documenting it in Docker on Mac.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this maybe because the link already existed because you already tried building it outside docker?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it is because symlinks between container and volumes mounted on a host are unsupported by Docker.
|
||
Add the `--bind 0.0.0.0` argument to bind the web server with the container's external interface too: | ||
|
||
[nix-shell]$ python -m http.server --bind 0.0.0.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could also use some other way to serve from the host environment (not from within docker) to serve a folder. Maybe simply running nix-shell -p python3 --run "python -m http.server"
outside the container is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@garbas, this is a great idea if we get the make
issue fixed, as long as there is content dynamically generated in the backend. I experimented with your suggestion and I believe the interfaces ip address must be specified within the nix-shell, so: nix-shell -p python3 --run "python -m http.server --bind 127.0.0.1"
(and the -p 8000:8000
argument must be removed from the docker invocation).
|
||
Then open http://127.0.0.1:8000/index.html in your browser on macOS. | ||
|
||
A single terminal screen is inconvenient for serious development, so you may want to set up openssh on the container to access the sources with the IDE on your Mac. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would skip this section and try to provide instructions to only run one instance of container with running nix-shell -p
outside the container.
Co-authored-by: Rok Garbas <rok@garbas.si>
Co-authored-by: Rok Garbas <rok@garbas.si>
Co-authored-by: Rok Garbas <rok@garbas.si>
Hi, what requested changes are missing here? I think this would make contributing a lot easier for new mac users. |
@lockejan (or anybody else using macOS) could you test the instructions in this PR and submit new PR? |
Resolves #515