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

kernelTarget attr is ignored in buildKernel (linux) #234084

Closed
MOZGIII opened this issue May 25, 2023 · 5 comments
Closed

kernelTarget attr is ignored in buildKernel (linux) #234084

MOZGIII opened this issue May 25, 2023 · 5 comments

Comments

@MOZGIII
Copy link

MOZGIII commented May 25, 2023

Describe the bug

kernelTarget attribute exists in the buildKernel derivation code, but it is never used. This is confusing to me as newcomer, and is probably a leftover from an unclean past refactoring.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Use buildKernel with an override of the kernelTarget via overrideAttrs
  2. The standard target it generated.

Expected behavior

Ethier:

  • overriding kernelTarget (i.e. from the bzImage to vmlinuz) changes the actual build output to vmlinuz, or
  • kernelTarget does not exist

Additional context

Ultimately, I need a way to build a kernel via nix but not for a nixos, so I can't understand how to override the stdenv.hostPlatform.linux-kernel.target properly without it affecting the rest of the system (i.e. I want to build the nixos kernel to use with my system, and this other kernel for use in my other system that I want a different target on). A similar issue is present at linuxKernel.manualConfig (which I actually use now, since I also need a custom config).

Notify maintainers

@alyssais, @ncfavier (not sure if you are the right people to ping, sorry if I'm mistaken)

Metadata

This shouldn't really matter, but:

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.0-rc4-snp-host-db73108c4fd6, Ubuntu, 20.04.6 LTS (Focal Fossa), nobuild`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.15.1`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`

I'm also in a flake currently, but this needs to be portable for other environments...

@alyssais
Copy link
Member

alyssais commented May 25, 2023 via email

alyssais added a commit to alyssais/nixpkgs that referenced this issue May 25, 2023
As far as I can tell this is unused since f95d214.

Fixes: f95d214 ("Implement generic kernel build via manual-config")
Fixes: NixOS#234084
@MOZGIII
Copy link
Author

MOZGIII commented May 25, 2023

There's no such attribute in the kernel derivation. The only mention of kernelTarget in Nixpkgs is an attribute of the kernel config file. It deosn't seem to do anything and can probably be removed.

Right, that's what I meant, it is just declared inline within the definition of buildKernel fn.

If you can confirm it doesn't do anything, I'd send a PR to remove it, as it surely is confusing.

If you want to build a kernel with a custom target, that's a property of the platform being built for, so you should set linux-kernel.target in localSystem or crossSystem appropriately when you import Nixpkgs.

Got it! This is a bit more complicated than I expected as it seems I have rewire how the nixpkgs are used in my setup. My understanding is that I'll have to import a second instance of nixpkgs with a cross-build (even though it's not really a cross-build in a usual sense) and set the target settings on that. This seems like it would work, as long as nixpkgs itself is really pure, and doesn't pollute the global environment.

Thank you for the tip!

@alyssais
Copy link
Member

alyssais commented May 25, 2023 via email

@MOZGIII
Copy link
Author

MOZGIII commented May 25, 2023

Well, I'm currently focusing on just one, but eventually, I want to build two "standalone" kernels - one for the host os and one for the guest os - "standalone" in the sense that they won't be used as part of a nixos installation, but a custom one.
These are sort of like two environments I need to maintain.
In addition to that, I also have a nix shell defined with the same flake (devShells), that is intended to be usable on the system I develop on - and this is the third nixpkgs environment I need to maintain.

So, ultimately I think what would make sense would be to have the "default" nixpkgs import what I use in the devShells, and two new imports, one for each "standalone" kernel.

@bolives-hax
Copy link
Contributor

this

  1. Use buildKernel with an override of the kernelTarget via overrideAttrs
    There's no such attribute in the kernel derivation. The only mention of kernelTarget in Nixpkgs is an attribute of the kernel config file. It deosn't seem to do anything and can probably be removed. If you want to build a kernel with a custom target, that's a property of the platform being built for, so you should set linux-kernel.target in localSystem or crossSystem appropriately when you import Nixpkgs.

I wish I knew this earlier. Been fucking around with the buildKernel drvs wondering where it sources that stuff from. I didn't
know these variables existed and if I wouldn't have found out I probably would have give up porting nixos to s390X (e.g Z10 mainframes as I happen to have one of these for a while)

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

3 participants