summary refs log tree commit diff
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2021-10-27 23:53:14 +0200
committerMaximilian Bosch <maximilian@mbosch.me>2021-11-01 10:06:00 +0100
commit63185299f4c8beecac7e204dc20394f38e68a477 (patch)
treeaa4356440c1408cfe4fea29a8541581b0f5b06fe
parent850251213a9df6a2f645de43e7e9b4cc6f376cf6 (diff)
downloadnixpkgs-63185299f4c8beecac7e204dc20394f38e68a477.tar
nixpkgs-63185299f4c8beecac7e204dc20394f38e68a477.tar.gz
nixpkgs-63185299f4c8beecac7e204dc20394f38e68a477.tar.bz2
nixpkgs-63185299f4c8beecac7e204dc20394f38e68a477.tar.lz
nixpkgs-63185299f4c8beecac7e204dc20394f38e68a477.tar.xz
nixpkgs-63185299f4c8beecac7e204dc20394f38e68a477.tar.zst
nixpkgs-63185299f4c8beecac7e204dc20394f38e68a477.zip
linux: make sure that `src`/`version` actually refer to the declaring file
With this change it's ensured that `builtins.unsafeGetAttrPos` actually
points to `<nixpkgs/pkgs/os-specific/linux/kernel/linux-x.y.nix>` when
retrieving the position of `src` or `version` of
`linuxPackages.kernel`.

This is relevant to make sure that ofborg pinging maintainers on kernel updates
actually works[1]. While the underlying issue should be fixed in ofborg
or Nix itself, this is IMHO a pragmatic change to ensure that all kernel
maintainers are automatically notified on updates.

[1] https://github.com/NixOS/nixpkgs/pull/143113#issuecomment-953319957
-rw-r--r--pkgs/os-specific/linux/kernel/generic.nix23
-rw-r--r--pkgs/os-specific/linux/kernel/manual-config.nix4
2 files changed, 21 insertions, 6 deletions
diff --git a/pkgs/os-specific/linux/kernel/generic.nix b/pkgs/os-specific/linux/kernel/generic.nix
index 7f2a97d868e..2d153d31800 100644
--- a/pkgs/os-specific/linux/kernel/generic.nix
+++ b/pkgs/os-specific/linux/kernel/generic.nix
@@ -60,7 +60,7 @@
 , kernelTests ? []
 , nixosTests
 , ...
-}:
+}@args:
 
 # Note: this package is used for bootstrapping fetchurl, and thus
 # cannot use fetchpatch! All mutable patches (generated by GitHub or
@@ -70,6 +70,18 @@
 assert stdenv.isLinux;
 
 let
+  # Dirty hack to make sure that `version` & `src` have
+  # `<nixpkgs/pkgs/os-specific/linux/kernel/linux-x.y.nix>` as position
+  # when using `builtins.unsafeGetAttrPos`.
+  #
+  # This is to make sure that ofborg actually detects changes in the kernel derivation
+  # and pings all maintainers.
+  #
+  # For further context, see https://github.com/NixOS/nixpkgs/pull/143113#issuecomment-953319957
+  basicArgs = builtins.removeAttrs
+    args
+    (lib.filter (x: ! (builtins.elem x [ "version" "src" ])) (lib.attrNames args));
+
   # Combine the `features' attribute sets of all the kernel patches.
   kernelFeatures = lib.foldr (x: y: (x.features or {}) // y) ({
     iwlwifi = true;
@@ -180,13 +192,14 @@ let
     };
   }; # end of configfile derivation
 
-  kernel = (callPackage ./manual-config.nix { inherit buildPackages;  }) {
-    inherit version modDirVersion src kernelPatches randstructSeed lib stdenv extraMakeFlags extraMeta configfile;
+  kernel = (callPackage ./manual-config.nix { inherit buildPackages;  }) (basicArgs // {
+    inherit modDirVersion kernelPatches randstructSeed lib stdenv extraMakeFlags extraMeta configfile;
+    pos = builtins.unsafeGetAttrPos "version" args;
 
     config = { CONFIG_MODULES = "y"; CONFIG_FW_LOADER = "m"; };
-  };
+  });
 
-  passthru = {
+  passthru = basicArgs // {
     features = kernelFeatures;
     inherit commonStructuredConfig structuredExtraConfig extraMakeFlags isZen isHardened isLibre modDirVersion;
     isXen = lib.warn "The isXen attribute is deprecated. All Nixpkgs kernels that support it now have Xen enabled." true;
diff --git a/pkgs/os-specific/linux/kernel/manual-config.nix b/pkgs/os-specific/linux/kernel/manual-config.nix
index d9a959c50bc..d741a1978d5 100644
--- a/pkgs/os-specific/linux/kernel/manual-config.nix
+++ b/pkgs/os-specific/linux/kernel/manual-config.nix
@@ -19,6 +19,8 @@ in {
   stdenv,
   # The kernel version
   version,
+  # Position of the Linux build expression
+  pos ? null,
   # Additional kernel make flags
   extraMakeFlags ? [],
   # The version of the kernel module directory
@@ -333,4 +335,4 @@ stdenv.mkDerivation ((drvAttrs config stdenv.hostPlatform.linux-kernel kernelPat
   ] ++ extraMakeFlags;
 
   karch = stdenv.hostPlatform.linuxArch;
-})
+} // (optionalAttrs (pos != null) { inherit pos; }))