Trouble compiling linux-next-20230908


I am trying to compile linux-next-20230908, the exact version is not that important. But it contains a fix for r8169 that should solve the issue where the network card sometimes completely stops working.

In my configuration.nix I have it set up like on the wiki:

  boot.kernelPackages = let

    nixpkgsMaster = import "/home/michel/sources/nixpkgs/default.nix" {
      config = config.nixpkgs.config;
  in let
    linux_next_pkg = { fetchurl, buildLinux, ... }@args:

      buildLinux (args // rec {
        version = "6.5.0-next-20230908";
        modDirVersion = version;

        src = fetchurl {
          url =
          hash = "sha256-ht7qxewNo0Oxg6cT191yEG5EKxQROAz4nC2MyCvEcG4=";
        kernelPatches = [ ];

        extraMeta.branch = "linux-next";
      } // (args.argsOverride or { }));
    linux_next = nixpkgsMaster.pkgs.callPackage linux_next_pkg { };
  in pkgs.recurseIntoAttrs (pkgs.linuxPackagesFor linux_next);

My local copy of nixpkgs is at commit 1216b3 with the following change, as they removed some options in Linux:

diff --git a/pkgs/os-specific/linux/kernel/common-config.nix b/pkgs/os-specific/linux/kernel/common-config.nix
index c8ae911c1287..f861f2c6a379 100644
--- a/pkgs/os-specific/linux/kernel/common-config.nix
+++ b/pkgs/os-specific/linux/kernel/common-config.nix
@@ -603,8 +603,8 @@ let

     microcode = {
       MICROCODE       = yes;
-      MICROCODE_INTEL = yes;
-      MICROCODE_AMD   = yes;
+      MICROCODE_INTEL = whenOlder "6.5.0-next-20230831" yes;
+      MICROCODE_AMD   = whenOlder "6.5.0-next-20230831" yes;
       # Write Back Throttling
@@ -913,7 +913,7 @@ let
       SECCOMP             = yes; # used by systemd >= 231
       SECCOMP_FILTER      = yes; # ditto
       POSIX_MQUEUE        = yes;
-      FRONTSWAP           = yes;
+      FRONTSWAP           = whenOlder "6.5.0-next-20230831" yes;
       FUSION              = yes; # Fusion MPT device support
       IDE                 = whenOlder "5.14" no; # deprecated IDE support, removed in 5.14
       IDLE_PAGE_TRACKING  = yes;

When building the configuration, it fails like this:

  XZ      /nix/store/fwsjd82yjzyx629idivzjvmyrd61vjpi-linux-6.5.0-next-20230908/lib/modules/6.5.0-next-20230908/kernel/net/qrtr/qrtr-mhi.ko.xz
  XZ      /nix/store/fwsjd82yjzyx629idivzjvmyrd61vjpi-linux-6.5.0-next-20230908/lib/modules/6.5.0-next-20230908/kernel/virt/lib/irqbypass.ko.xz
  DEPMOD  /nix/store/fwsjd82yjzyx629idivzjvmyrd61vjpi-linux-6.5.0-next-20230908/lib/modules/6.5.0-next-20230908
Warning: 'make modules_install' requires depmod. Please install it.
This is probably in the kmod package.
unlink: cannot unlink '/nix/store/fwsjd82yjzyx629idivzjvmyrd61vjpi-linux-6.5.0-next-20230908/lib/modules/6.5.0-next-20230908/source': No such file or directory
/nix/store/1qxkj91n172qnypdrqdybh4p203nax7g-stdenv-linux/setup: line 144: pop_var_context: head of shell_variables not a function context
error: builder for '/nix/store/ymwk8xwmya74a690nl6r1dzl14cv5742-linux-6.5.0-next-20230908.drv' failed with exit code 1
error: 1 dependencies of derivation '/nix/store/ry6bb21mqxvvf2n8n099p12n19yq345q-nixos-system-windtunnel-23.05.3085.2ab91c8d65c0.drv'

I have tried commenting out this line, but that does not make a difference. It is probably also there for a good reason.

I don’t really know where to go from here, am I missing something obvious?

I am running NixOS 23.05.

Check what /nix/store/fwsjd82yjzyx629idivzjvmyrd61vjpi-linux-6.5.0-next-20230908/lib/modules/ contains

Im guessing your modDirVersion is wrong

If the modDirVersion is wrong then why doesn’t the command on line 273 fail too

The nix store has the following:

[michel@windtunnel:~]$ ls /nix/store/fwsjd82yjzyx629idivzjvmyrd61vjpi-linux-6.5.0-next-20230908/lib/modules/

[michel@windtunnel:~]$ ls /nix/store/fwsjd82yjzyx629idivzjvmyrd61vjpi-linux-6.5.0-next-20230908/lib/modules/6.5.0-next-20230908/
kernel  modules.builtin  modules.builtin.modinfo  modules.order

When I change version and modDirVersion to 6.5.0 it says

Error: modDirVersion 6.5.0 specified in the Nix expression is wrong, it should be: 6.5.0-next-20230908

I’m not sure what the side effects of this are, but I just deleted unlink $out/lib/modules/${modDirVersion}/source from pkgs/os-specific/linux/kernel/manual-config.nix along with the above and it built successfully. :hushed: Booted in and nothing seemed broken. Was there a change in the kernel recently that stopped it producing that file?

I think I have found part of the problem.

The warning comes from scripts/, the way it finds depmod has changed recently. But when it cannot find depmod it exits with 0 so the build does not fail right away.

next-20230825 has the old behaviour, so I was able to compile that version.

Fixed in 813e00.