Commit cd6eb548 authored by Samuel Dionne-Riel's avatar Samuel Dionne-Riel
Browse files

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

This partially reverts commit 845e340e.

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 (cf3f5c4d):

```
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 (2fb006b8):

```
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.
parent 2fb006b8
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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";
+1 −0
Original line number Diff line number Diff line
@@ -293,6 +293,7 @@ let
          configfile
          modDirVersion
          ;
        pos = builtins.unsafeGetAttrPos "version" args;

        config = {
          CONFIG_MODULES = "y";