Linux kernel: Difference between revisions

Sandro (talk | contribs)
Remove stub troubleshooting section
 
(5 intermediate revisions by 4 users not shown)
Line 24: Line 24:
</syntaxHighlight>
</syntaxHighlight>
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
nix-repl> :l <nixpkgs>
nix-repl> pkgs = import <nixpkgs> {}
Added 12607 variables.
Added 12607 variables.


Line 130: Line 130:
     name = "crashdump-config";
     name = "crashdump-config";
     patch = null;
     patch = null;
     structuredExtraConfig = {
     structuredExtraConfig = with lib.kernel; {
       CRASH_DUMP = lib.kernel.yes;
       CRASH_DUMP = yes;
       DEBUG_INFO = lib.kernel.yes;
       DEBUG_INFO = yes;
       PROC_VMCORE = lib.kernel.yes;
       PROC_VMCORE = yes;
       LOCKUP_DETECTOR = lib.kernel.yes;
       LOCKUP_DETECTOR = yes;
       HARDLOCKUP_DETECTOR = lib.kernel.yes;
       HARDLOCKUP_DETECTOR = yes;
     };
     };
   } ];
   } ];
Line 142: Line 142:
</syntaxhighlight>
</syntaxhighlight>


Alternatively, you can pass a string as <code>extraConfig</code>, with option names and answers formatted like so:
Another way is to create an overlay to configure {{ic|structuredExtraConfig}}. This allows for more flexibility, since you can basically override any available kernel option<ref>[https://github.com/NixOS/nixpkgs/blob/e6db435973160591fe7348876a5567c729495175/pkgs/os-specific/linux/kernel/generic.nix#L11-L56<tt>pkgs/os-specific/linux/kernel/generic.nix#L11-L56</tt>]</ref>.
 
<pre>
CRASH_DUMP y
DEBUG_INFO y
PROC_VMCORE y
LOCKUP_DETECTOR y
HARDLOCKUP_DETECTOR y
</pre>
 
Another way is to create an overlay to configure either {{ic|extraConfig}} or {{ic|structuredExtraConfig}}. This allows for more flexibility, since you can basically override any available kernel option<ref>[https://github.com/NixOS/nixpkgs/blob/e6db435973160591fe7348876a5567c729495175/pkgs/os-specific/linux/kernel/generic.nix#L11-L56<tt>pkgs/os-specific/linux/kernel/generic.nix#L11-L56</tt>]</ref>. Using {{ic|structuredExtraConfig}} is recommended as it checks if the configured option are correct.


{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
Line 251: Line 241:


Please provide a comparison with other distributions' kernel:
Please provide a comparison with other distributions' kernel:
- arch: https://github.com/archlinux/svntogit-packages/blob/packages/linux/trunk/config
 
- debian: https://salsa.debian.org/kernel-team/linux/blob/master/debian/config/config and the ARCH specific ones
* Arch: https://gitlab.archlinux.org/archlinux/packaging/packages/linux/-/blob/main/config
* Debian: https://salsa.debian.org/kernel-team/linux/blob/master/debian/config/config and the ARCH specific ones


== Booting a kernel from a custom source ==
== Booting a kernel from a custom source ==
Line 276: Line 267:
           kernelPatches = [];
           kernelPatches = [];


           extraConfig = ''
           structuredExtraConfig = with lib.kernel; {
             INTEL_SGX y
             INTEL_SGX = yes;
           '';
           };


           extraMeta.branch = "5.4";
           extraMeta.branch = "5.4";
Line 484: Line 475:
=== Overriding kernel packages ===
=== Overriding kernel packages ===


In order to override <code>linuxPackages</code>, use the <code>extend</code> attribute. Example:
In order to override <code>linuxPackages</code>, an alias of <code>linuxKernel.packages</code>, use the <code>extend</code> attribute. Example:


<syntaxHighlight lang=nix>
<syntaxHighlight lang=nix>
Line 508: Line 499:
     })
     })
   ];
   ];
</syntaxHighlight>
You can also use <code>kernelPackagesExtensions</code> in a similar fashion to override <code>linuxKernel.packages</code>:
<syntaxHighlight lang=nix>
nixpkgs.overlays = [ 
  (_: prev: {
    kernelPackagesExtensions = prev.kernelPackagesExtensions ++ [
      (_: linuxPrev: {
        digimend = linuxPrev.digimend.overrideAttrs (prevAttrs: {
          postPatch = prevAttrs.postPatch or "" + ''
            substituteInPlace "hid-uclogic-core.c" \
              --replace-fail "del_timer_sync" "timer_shutdown_sync"
          '';
        });
      })
    ];
  })
];
</syntaxHighlight>
</syntaxHighlight>


Line 604: Line 614:
}
}
</syntaxhighlight>
</syntaxhighlight>
== Troubleshooting ==
=== Build fails ===
==== Too high ram usage ====
turn off <code>DEBUG_INFO_BTF</code>


== See also ==
== See also ==