linux: Partially revert "linux: drop hacky passing around of positions"

This partially reverts commit 845e340ed9.

This re-introduces the `pos` juggling previous done.

The rationale used in the commit was:

> This is long obsolete since the versions are maintained in a JSON
> file now.

That is only accurate for `mainline`. Other in-tree kernels are
maintained in different ways. This led to a loss of information.

Before (cf3f5c4def):

```
nix-repl> linux_latest.meta.position
".../pkgs/os-specific/linux/kernel/mainline.nix:34"
nix-repl> linux_rpi0.meta.position
".../pkgs/os-specific/linux/kernel/linux-rpi.nix:20"

```

After (2fb006b87f):

```
nix-repl> linux_latest.meta.position
".../pkgs/os-specific/linux/kernel/build.nix:558"
nix-repl> linux_rpi0.meta.position
".../pkgs/os-specific/linux/kernel/build.nix:558"
```

This is also observable for out-of-tree kernels:

```
nix-repl> pkgs.linux_jovian.meta.position
".../Jovian-NixOS/pkgs/linux-jovian/default.nix:11"

nix-repl> :r # after updating the Nixpkgs input

nix-repl> pkgs.linux_jovian.meta.position
"/nix/store/xjjq52iwslhz6lbc621a31v0nfdhr5ks-source/pkgs/os-specific/linux/kernel/build.nix:558"
```

This also conveniently works around the root cause of an
`stdenv.mkDerivation`-based `pos` infrec regression when using the
kernel package version in a NixOS configuration to conditionally
apply kernel patches.
This commit is contained in:
Samuel Dionne-Riel
2025-11-01 17:57:50 -04:00
parent 2fb006b87f
commit cd6eb54878
2 changed files with 5 additions and 0 deletions

View File

@@ -51,6 +51,8 @@ lib.makeOverridable (
version,
# The kernel pname (should be set for variants)
pname ? "linux",
# Position of the Linux build expression
pos ? null,
# Additional kernel make flags
extraMakeFlags ? [ ],
# The name of the kernel module directory
@@ -551,6 +553,8 @@ lib.makeOverridable (
karch = stdenv.hostPlatform.linuxArch;
pos = lib.optionalDrvAttr (pos != null) pos;
meta = {
# https://github.com/NixOS/nixpkgs/pull/345534#issuecomment-2391238381
broken = withRust && lib.versionOlder version "6.12";

View File

@@ -293,6 +293,7 @@ let
configfile
modDirVersion
;
pos = builtins.unsafeGetAttrPos "version" args;
config = {
CONFIG_MODULES = "y";