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

Use cross build packages in extlinux builder when hostPlafrom differs from buildPlatform #62318

Closed
wants to merge 1 commit into from

Conversation

kampka
Copy link
Contributor

@kampka kampka commented May 31, 2019

Motivation for this change

When cross building a system configuration using NixOps and nixpkgs.crossSystem, the builder for extlinux is run on the target host and not the build system.
The current abstraction places the buildPkgs into the builders path, making the builder fail with unsupported execution formats for things like coreutils.

This change attemts to correct this.
As I am not very experienced with the Nix cross-build setup as a hole, I am not very confident about this change as I don't know the full implications of it.
I apologize in advance for the extra strain this puts on the reviews, I hope we can come to a propper solution in the end.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@kampka
Copy link
Contributor Author

kampka commented May 31, 2019

@matthewbauer Since this is a cross build issue, I feel you might be qualified to review it.
Apologies if I'm mistaken.

@@ -8,7 +8,8 @@ let

timeoutStr = if blCfg.timeout == null then "-1" else toString blCfg.timeout;

builder = import ./extlinux-conf-builder.nix { pkgs = pkgs.buildPackages; };
builderPkgs = if (pkgs.stdenv.hostPlatform != pkgs.stdenv.buildPlatform) then pkgs else pkgs.buildPackages;
builder = import ./extlinux-conf-builder.nix { pkgs = builderPkgs; };
Copy link
Member

Choose a reason for hiding this comment

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

I wolud just do pkgs = pkgs.buildPackages. On hostPlatform == buildPlatform, it will be the same as pkgs. This would remove the above condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The important case I want to address is hostPlatform != buildPlatform.
If I just pass pkgs = pkgs.buildPackages, it won't work.

Just to clarify, you suggest to remove the condition and use

builder = import ./extlinux-conf-builder.nix { pkgs = pkgs.buildPackages; };

If so, that fails for me.

Copy link
Member

Choose a reason for hiding this comment

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

Oh ok! I see, I was thinking these would be run on the building machine. But it looks like the install bootloader is run on the target machine. That makes sense now that I think about it. I think a few more of these are messed up. These were done by me in this commit:

35af6e3

Could you see if reverting that fixes the issue? I would prefer to reduce the number of if statements we use here.

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 need to revert that commit for all of them besides the sd-* ones. Those /are/ run on the build machine, but installBootLoader is not

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed the revert to a second branch to keep it clean
#62333

Tests work out well so far, but the sd-image does not build for me (uboot won't compile), so that part is untested. Will close this PR when #62333 is accepted.

@kampka kampka mentioned this pull request May 31, 2019
10 tasks
@kampka
Copy link
Contributor Author

kampka commented Jun 5, 2019

Closing this in favor of #62333

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

Successfully merging this pull request may close these issues.

None yet

2 participants