Skip to content

linux: add extra passthru#412568

Merged
thiagokokada merged 3 commits intoNixOS:masterfrom
eljamm:kernels/extra-passthru
Jun 15, 2025
Merged

linux: add extra passthru#412568
thiagokokada merged 3 commits intoNixOS:masterfrom
eljamm:kernels/extra-passthru

Conversation

@eljamm
Copy link
Contributor

@eljamm eljamm commented May 31, 2025

Changes

Currently, kernel update scripts can't be triggered, given that passthru doesn't propagate to the final passthru.
This PR introduces extraPassthru (similar to extraMeta) for properly propagating the attribute.

Also, this PR switches the Zen and Libre kernels to use extraPassthru.updateScript, since they're the only ones that have update scripts, at the moment.

Test

Before

$ nix-shell maintainers/scripts/update.nix --argstr package linux_zen
error:
       … while evaluating 'strict' to select 'drvPath' on it
         at /builtin/derivation.nix:1:552:
       … while calling the 'derivationStrict' builtin
         at /builtin/derivation.nix:1:208:
       (stack trace truncated; use '--show-trace' to show the full trace)

       error: Package with an attribute name `linux_zen` does not have a `passthru.updateScript` attribute defined.

After

$ nix-shell maintainers/scripts/update.nix --argstr package linux_zen

Going to be running update for following packages:
 - linux-zen-6.14.7

Press Enter key to continue...

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • Nixpkgs 25.11 Release Notes (or backporting 24.11 and 25.05 Nixpkgs Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
  • NixOS 25.11 Release Notes (or backporting 24.11 and 25.05 NixOS Release notes)
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

eljamm added 3 commits May 31, 2025 06:39
Currently, kernel update scripts can't be triggered, given that
`passthru` doesn't propagate to the [final
passthru](https://github.com/NixOS/nixpkgs/blob/59138c7667b7970d205d6a05a8bfa2d78caa3643/pkgs/os-specific/linux/kernel/generic.nix#L300).
This change introduces `extraPassthru` for properly propagating it.
@github-actions github-actions bot added the 6.topic: kernel The Linux kernel label May 31, 2025
@eljamm eljamm requested a review from ShamrockLee May 31, 2025 04:42
@github-actions github-actions bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels May 31, 2025
@eljamm
Copy link
Contributor Author

eljamm commented May 31, 2025

Manually pinging Zen and Libre kernel maintainers, given CI won't do it because of the zero rebuilds:
@thiagokokada @JerrySM64 @AxerTheAxe @alyssais

@alyssais alyssais requested a review from K900 May 31, 2025 13:49
@ShamrockLee
Copy link
Contributor

ShamrockLee commented May 31, 2025

Do you know what the existing passthru variable is for? (I'll take a look tomorrow with an IDE. The phone screen is too small for a thorough review.)

BTW, I think passthru is a better name than extraPassthru.

@eljamm
Copy link
Contributor Author

eljamm commented May 31, 2025

Do you know what the existing passthru variable is for?

I'm not very familiar with the inner workings of how kernels are composed, but I took this as a chance to take a deeper dive and here is what I understand so far:

  • First, generic.nix creates an overridableKernel
  • Second, we override the result, but for attributes and not arguments. Specifically, we compose a final passthru.
    • This combines the previously-created passthru with a bunch of other attributes
    • I suppose the redundancy here for some of the attributes is to ensure that kernel-specific values are applied. For example, if you remove isZen here, then you will have the wrong result when you evaluate:
      nix-repl> linux_zen.passthru.isZen
      false
      
      Whereas when it's set, you get:
      nix-repl> linux_zen.passthru.isZen
      true
      
  • Finally, all of this is composed into a buildLinux function, which is then used to create kernel detivations.

To conclude, a kernel derivation's passthru is always internally composed, so setting something like passthru.updateScript is not propagated to the final passthru, which this PR essentially fixes.

BTW, I think passthru is a better name than extraPassthru.

I just tried to keep things consistent with extraMeta (which I don't know why it was called that way, either). I don't mind either name, but I'd like to hear what the other maintainers prefer as well and possibly agree on one of them.

@alyssais
Copy link
Member

alyssais commented Jun 1, 2025

BTW, I think passthru is a better name than extraPassthru.

I just tried to keep things consistent with extraMeta (which I don't know why it was called that way, either). I don't mind either name, but I'd like to hear what the other maintainers prefer as well and possibly agree on one of them.

Yeah, I agree. I wouldn't have called it extraMeta either, but there's not much point changing it now, and it's good to be consistent with extraPassthru.

@ShamrockLee
Copy link
Contributor

I'll take a look tomorrow with an IDE.

Sorry for missing this PR. I'm having too much on my plate.

I'll try to review this weekend.

@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one person. label Jun 9, 2025
@eljamm
Copy link
Contributor Author

eljamm commented Jun 15, 2025

Friendly ping to @ShamrockLee

passthru =
previousAttrs.passthru or { }
// extraPassthru
// basicArgs
Copy link
Contributor

Choose a reason for hiding this comment

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

Not related to this PR but kind strange that we are merging basicArgs to passthru.

Copy link
Contributor

Choose a reason for hiding this comment

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

For example:

nix-repl> legacyPackages.x86_64-linux.linuxPackages_zen.kernel.passthru
{
  baseVersion = "6.14.7";
  commonMakeFlags = [ ... ];
  commonStructuredConfig = { ... };
  config = { ... };
  configEnv = «derivation /nix/store/ncilq58kr4pl2r10pqgnwnm0sgbwkggm-linux-zen-6.14.7.drv»;
  configfile = «derivation /nix/store/c1nfai5wq9x84wljlisqb2pri1r615s3-linux-config-6.14.7.drv»;
  extraMakeFlags = [ ... ];
  features = { ... };
  isHardened = false;
  isLibre = false;
  isXen = true;
  isZen = true;
  kernelAtLeast = «lambda versionAtLeast @ /nix/store/8ky1s7q96lz5n6gpyb6gdsiqhxin6dfr-source/lib/strings.nix:1944:24»;
  kernelOlder = «lambda versionOlder @ /nix/store/8ky1s7q96lz5n6gpyb6gdsiqhxin6dfr-source/lib/strings.nix:1910:22»;
  kernelPatches = [ ... ];
  modDirVersion = "6.14.7-zen1";
  moduleBuildDependencies = [ ... ];
  pname = "linux-zen";
  src = «derivation /nix/store/2by3j92cr187df98ijql39jj813az299-source.drv»;
  stdenv = «derivation /nix/store/ljjhsmahjyc0l49q4v21mkzrhn2p24ra-stdenv-linux.drv»;
  structuredExtraConfig = { ... };
  tests = { ... };
  updateScript = [ ... ];
  version = "6.14.7";
  withRust = true;
}

I don't think things like src or stdenv is supposed to be in passthru.

Copy link
Contributor Author

@eljamm eljamm Jun 15, 2025

Choose a reason for hiding this comment

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

I think this is why it was added: 6318529. Don't know if it's still relevant or not for our current infra.

Copy link
Contributor

@thiagokokada thiagokokada left a comment

Choose a reason for hiding this comment

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

LGTM:

nix-repl> :p legacyPackages.x86_64-linux.linuxPackages_zen.kernel.passthru.updateScript
[
  /nix/store/8ky1s7q96lz5n6gpyb6gdsiqhxin6dfr-source/pkgs/os-specific/linux/kernel/update-zen.py
  "zen"
]

@thiagokokada thiagokokada merged commit ff2bab8 into NixOS:master Jun 15, 2025
19 of 20 checks passed
@github-actions github-actions bot added 12.approvals: 2 This PR was reviewed and approved by two persons. and removed 12.approvals: 1 This PR was reviewed and approved by one person. labels Jun 15, 2025
@eljamm eljamm deleted the kernels/extra-passthru branch June 15, 2025 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: kernel The Linux kernel 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. 12.approvals: 2 This PR was reviewed and approved by two persons.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants