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

Add instructions to build in Docker for Mac #584

Closed
wants to merge 5 commits into from
Closed

Conversation

bxrt
Copy link

@bxrt bxrt commented Sep 27, 2020

Resolves #515

Copy link
Member

@garbas garbas left a 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.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved

In your favourite macOS terminal:

$ docker run -p 8000:8000 -it --name nixos-homepage nixos/nix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$ 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

Copy link
Author

@bxrt bxrt Sep 27, 2020

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.

Copy link
Author

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.

Copy link
Member

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?

Copy link
Author

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.

README.md Outdated Show resolved Hide resolved

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
Copy link
Member

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.

Copy link
Author

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.
Copy link
Member

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.

bxrt and others added 3 commits September 27, 2020 13:47
Co-authored-by: Rok Garbas <rok@garbas.si>
Co-authored-by: Rok Garbas <rok@garbas.si>
Co-authored-by: Rok Garbas <rok@garbas.si>
@lockejan
Copy link

lockejan commented Dec 6, 2021

Hi, what requested changes are missing here? I think this would make contributing a lot easier for new mac users.
I'd be happy to help resolving this.

@garbas
Copy link
Member

garbas commented Jan 14, 2022

@lockejan (or anybody else using macOS) could you test the instructions in this PR and submit new PR?

@garbas garbas closed this Jan 14, 2022
@lockejan lockejan mentioned this pull request Mar 19, 2022
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

Successfully merging this pull request may close these issues.

error building homepage on macos
3 participants