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

top-level: apply platform config to cross system #38818

Closed
wants to merge 1 commit into from

Conversation

lopsided98
Copy link
Contributor

Motivation for this change

It is impossible to use the option nixpkgs.config.platform to set the platform when cross compiling, because it is not passed to crossSystem.

Things done

This PR elaborates crossSystem using config.platform when crossSystem is not null, and retains the current behavior when it is null. Someone who knows more about the internals of nixpkgs may have a more elegant way of doing this, but this solution solves the problem for me.

  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-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 nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@Ericson2314
Copy link
Member

Ericson2314 commented Apr 12, 2018

So I never thought crossSystem was the right idea for a top level argument, but I kept it for backwards compat. What if instead we make runSystem: attrs (née localSystem) and buildSystem: attrs or null (before, rather than after runSystem). Then this PR isn't needed:

let
  runSystem = lib.systems.elaborate
    (builtins.intersectAttrs { platform = null; } config // args.runSystem);

as is done today (with localSystem) is unconditional.

@shlevy @dtzWill @matthewbauer @bgamari @dezgeg @edolstra what do you all think?

@dezgeg
Copy link
Contributor

dezgeg commented Apr 12, 2018

That seems massively verbose and non-obvious to figure out.

I guess the real problem is that this new hostPlatform et al stuff were added separately to the existing platform stuff. They should really be merged together with the non-optimal layering violations removed from the existing platform.

BTW don't this localSystem and the like mostly just set hostPlatform in nixpkgs? Why is it called "system" in one place and "platform" in others?

@dezgeg
Copy link
Contributor

dezgeg commented Apr 12, 2018

@lopsided98 I'm curious, what's your use case for changing platform? If it's for changing the defconfig for when building the kernel, this should really be moved to the kernel expressions itself one day. I have a WIP branch for that at https://github.com/NixOS/nixpkgs/compare/master...dezgeg:defconfig-in-kernel-pkg?expand=1, hopefully one day I get to debug why it fails at runtime.

@lopsided98
Copy link
Contributor Author

@dezgeg Yes, I am changing defconfig, as well as enabling extra kernel options.

@Ericson2314
Copy link
Member

That seems massively verbose and non-obvious to figure out.

The PR or my proposal.

I guess the real problem is that this new hostPlatform et al stuff were added separately to the existing platform stuff.

The *System stuff is intentionally separate from the *Platform stuff; the former determines the latter and only the former is ever nullable. I could use the same names though, but I think its important to understand it separate. Also keep in mind while system, platform, and crossSystem are older, I reimplemented everything long ago anyways.

They should really be merged together with

Separately, platform and system, with exactly the same structure, are fields in all of localSystem, crossSystem. buildPlaform, hostPlatform, and targetPlatform.

the non-optimal layering violations removed from the existing platform.

Agreed.


@dezgeg I pinged you in IRC but we should really sync up in real time to go over all this stuff and document it. I am a single point of failure today because I rewrote all that stuff a year ago, and I do not want to be that.

@dtzWill
Copy link
Member

dtzWill commented Apr 19, 2018

EDIT: eep I accidentally commented on wrong issue, sorry about that! Nothing to see here....

@dezgeg
Copy link
Contributor

dezgeg commented Jun 4, 2018

@lopsided98 I recently added 87a68c4. Is that enough for your custom kernel uses to avoid the need for setting nixpkgs.config.platform?

@lopsided98
Copy link
Contributor Author

Yes, I have moved all my custom configuration to the kernel derivations. I still feel like the current behavior is not optimal, but I'll close this PR.

@lopsided98 lopsided98 closed this Aug 5, 2018
@lopsided98 lopsided98 deleted the cross-system-platform branch September 23, 2018 21:25
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

5 participants