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

Packages should have to opt-into target sensitivity #263640

Open
Ericson2314 opened this issue Oct 26, 2023 · 1 comment
Open

Packages should have to opt-into target sensitivity #263640

Ericson2314 opened this issue Oct 26, 2023 · 1 comment

Comments

@Ericson2314
Copy link
Member

Unless you set some sort of special field consenting to craziness, you shouldn't get to see targetPlatform, and you shouldn't get to see any other package which sees targetPlatform.

It's very important this is opt-in rather than opt-out.

@ghost
Copy link

ghost commented Nov 13, 2023

I plan to approach this in three steps:

Step 1: don't use targetPlatform in non-compiler packages

Step 2: require opt-in for target sensitivity

Make it strictly opt-in for a package to be aware of the fact that there is such a thing as a targetPlatform. Most of nixpkgs does not need to opt-in to this. There will be no more host/target confusion, because there simply won't be any targetXXX attributes around to use by accident.

Without targetPlatform there are only two relevant packagesets, pkgs and buildPackages, instead of all the pkgs{Build,Host,Target}{Build,Host,Target} permutations. Likewise for deps{Build,Host,Target}{Build,Host,Target}. Everything will be vastly simpler for all the non-compiler packages.

Step 3: "inter-stage" packageset for target-sensitive packages

The third, more speculative step, is to have all of these opted-in packages belong to packagesets which "fall in-between" the normal package sets, exactly the way each stdenv of the bootstrapping stages "falls in-between" two packagesets:

  • before it is stdenv.__bootPackages, which is the packageset that stdenv is built from
  • after it is stdenv.__hatPackages, which is the packageset built by stdenv

The idea is to generalize the stdenv, pkgs, stdenv, pkgs, ... "braid" so into compilers, pkgs, compilers, pkgs ...; only the compilers packagesets know or care about targetPlatforms. Then the non-compiler packages get drastically simpler: all they need to know about is:

  • pkgs
  • pkgs.__compilers (currently called pkgsBuildHost)
  • pkgs.__compilers.__pkgs (currently called pkgsBuildBuild)

When moving towards earlier stages there's always only one choice: if you're at a pkgs stage then there is only one stage before you: pkgs.__compilers. Before that there is only one stage, and it's a pkgs stage: pkgs.__compilers.__pkgs.

When moving towards later stages from a pkgs stage you have to make a choice: pkgs.compilersFor takes an argument (just like emulatorFor), which is the platform you want to compile things for:

pkgs.compilersFor "aarch64-unknown-linux-musl"

When moving forward from a compilers stage there is no additional choice to make. You already picked the targetPlatform for the compilers; that will be the hostPlatform for the pkgs stage that follows it:

(pkgs.compilersFor "aarch64-unknown-linux-musl").pkgs

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

No branches or pull requests

2 participants