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

docker: Add Nix Store volume support #524

Merged
merged 1 commit into from
Mar 17, 2022
Merged

docker: Add Nix Store volume support #524

merged 1 commit into from
Mar 17, 2022

Conversation

otavio
Copy link
Contributor

@otavio otavio commented Mar 3, 2021

When running inside NixOS or using Nix packaging we need to add the Nix
Store to the running container so it can load the needed binaries.

Signed-off-by: Otavio Salvador [email protected]

@otavio otavio requested review from Dylan-DPC-zz and a team as code owners March 3, 2021 23:08
@otavio
Copy link
Contributor Author

otavio commented Mar 3, 2021

The error on the pipeline does not seem related. Any idea what might have caused it?

@otavio
Copy link
Contributor Author

otavio commented Mar 3, 2021

The error on the pipeline does not seem related. Any idea what might have caused it?

This is indeed not related. See:

E: Unable to locate package linux-image-4.19.0-11-arm64:arm64
E: Couldn't find any package by glob 'linux-image-4.19.0-11-arm64'
E: Couldn't find any package by regex 'linux-image-4.19.0-11-arm64'

@otavio
Copy link
Contributor Author

otavio commented Apr 17, 2021

Any news on this?

@reitermarkus
Copy link
Member

What is the use case for this? It seems like this should already be possible using env.volumes.

@otavio
Copy link
Contributor Author

otavio commented Mar 15, 2022

It fails to run automatically; so we would need to pass it to every time we call cross when using NixOS.

@reitermarkus
Copy link
Member

It fails to run automatically

What exactly fails to run? I'm not really familiar with NixOS, can you explain in more detail which packages need to be available/mounted in the container and why?

@otavio
Copy link
Contributor Author

otavio commented Mar 15, 2022

I am unsure if you know what NixOS is. So please take a look at How Nix works document. It explains how the Nix store works and more.

In summary, without the patch, cross fails to run because it cannot find the binaries it runs inside the container. It took me a while to understand the root cause of the error but now it works just fine. This is the same patch I apply in the official Nix package.

@reitermarkus
Copy link
Member

reitermarkus commented Mar 16, 2022

It explains how the Nix store works and more.

Okay, I understand now what the Nix store is/does.

it cannot find the binaries it runs inside the container

I'm still not sure what specifically the problem is though. Let me know if the following assumption is correct.

Let's say we are talking about the cargo binary:

  • We mount the rustup toolchain into the container.
  • The toolchain's ./bin/cargo is not a binary but a symlink into the Nix store.
  • Calling cargo fails since the Nix store is not mounted.

@otavio
Copy link
Contributor Author

otavio commented Mar 16, 2022

Exactly, your understanding is correct. Doing the mount inside the container allows it to run successfully.

@reitermarkus
Copy link
Member

Just one more question. Does Nix use some kind of customized version of rustup or how does symlinking the toolchain bineries into Nix store happen? I'd assume rustup just installs a complete pre-built toolchain from a tarball. Or is this a custom toolchain installed by Nix and not rustup?

@otavio
Copy link
Contributor Author

otavio commented Mar 16, 2022

Yes, it does. See rustup.

reitermarkus
reitermarkus previously approved these changes Mar 16, 2022
@reitermarkus
Copy link
Member

bors r+

bors bot added a commit that referenced this pull request Mar 16, 2022
524: docker: Add Nix Store volume support r=reitermarkus a=otavio

When running inside NixOS or using Nix packaging we need to add the Nix
Store to the running container so it can load the needed binaries.

Signed-off-by: Otavio Salvador <[email protected]>

Co-authored-by: Otavio Salvador <[email protected]>
@bors
Copy link
Contributor

bors bot commented Mar 16, 2022

Build failed:

@otavio
Copy link
Contributor Author

otavio commented Mar 17, 2022

Should I do anything on my side on this one?

@Emilgardis
Copy link
Member

Emilgardis commented Mar 17, 2022

fix the fmt error and it should be good to go :)

https://github.com/cross-rs/cross/runs/5578287402?check_suite_focus=true#step:4:10

bors d+

edit:: Actually, delegation doesn't work well when new commits dismisses reviews :/

@bors
Copy link
Contributor

bors bot commented Mar 17, 2022

✌️ otavio can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

When running inside NixOS or using Nix packaging we need to add the Nix
Store to the running container so it can load the needed binaries.

Signed-off-by: Otavio Salvador <[email protected]>
@otavio
Copy link
Contributor Author

otavio commented Mar 17, 2022

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 17, 2022

👎 Rejected by too few approved reviews

@Emilgardis
Copy link
Member

Emilgardis commented Mar 17, 2022

yeah, thought so. Should maybe fix that in upstream bors (or disable dismissal)

Copy link
Member

@Emilgardis Emilgardis left a comment

Choose a reason for hiding this comment

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

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 17, 2022

Build succeeded:

@bors bors bot merged commit 38fd62b into cross-rs:main Mar 17, 2022
@Emilgardis
Copy link
Member

I think there was an issue for this, this should pr should close that

@Emilgardis Emilgardis added this to the v0.2.2 milestone Jun 15, 2022
@Alexhuszagh Alexhuszagh added bug A-nixos-host Area: NixOS hosts labels Nov 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-nixos-host Area: NixOS hosts bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants