From cd6eb54878d50d772682f2457f5263b138c55b0b Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Sat, 1 Nov 2025 17:57:50 -0400 Subject: [PATCH] linux: Partially revert "linux: drop hacky passing around of positions" This partially reverts commit 845e340ed98ef6d8a5c5d7069663f2cd034e508a. 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 (cf3f5c4def3c): ``` 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 (2fb006b87f04c): ``` 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. --- pkgs/os-specific/linux/kernel/build.nix | 4 ++++ pkgs/os-specific/linux/kernel/generic.nix | 1 + 2 files changed, 5 insertions(+) diff --git a/pkgs/os-specific/linux/kernel/build.nix b/pkgs/os-specific/linux/kernel/build.nix index da50861fb459..4ec0c63cb761 100644 --- a/pkgs/os-specific/linux/kernel/build.nix +++ b/pkgs/os-specific/linux/kernel/build.nix @@ -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"; diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix index 8eecd334df70..456e9052d5c2 100644 --- a/pkgs/os-specific/linux/kernel/generic.nix +++ b/pkgs/os-specific/linux/kernel/generic.nix @@ -293,6 +293,7 @@ let configfile modDirVersion ; + pos = builtins.unsafeGetAttrPos "version" args; config = { CONFIG_MODULES = "y";