diff options
author | DS <commits@sidhion.com> | 2023-10-23 19:37:04 -0700 |
---|---|---|
committer | DS <commits@sidhion.com> | 2023-11-23 08:50:16 -0800 |
commit | 1d7ee9ff0901b780f0d9398735307933ac518d77 (patch) | |
tree | 510b3ac91e7d7d6ca9698424bd085fe8f5543b08 /nixos/doc/manual/configuration | |
parent | a68bc4feaf4bbf4b626226ff8f0f8110588d4ebc (diff) | |
download | nixlib-1d7ee9ff0901b780f0d9398735307933ac518d77.tar nixlib-1d7ee9ff0901b780f0d9398735307933ac518d77.tar.gz nixlib-1d7ee9ff0901b780f0d9398735307933ac518d77.tar.bz2 nixlib-1d7ee9ff0901b780f0d9398735307933ac518d77.tar.lz nixlib-1d7ee9ff0901b780f0d9398735307933ac518d77.tar.xz nixlib-1d7ee9ff0901b780f0d9398735307933ac518d77.tar.zst nixlib-1d7ee9ff0901b780f0d9398735307933ac518d77.zip |
doc: consolidate info on manual linux kernel configs
The Nixpkgs documentation on the linux kernel builders focused on using and extending kernels that were already packaged, but never mentioned that it's possible to also build a kernel almost "from scratch". The NixOS documentation went a bit deeper on manual linux kernel configs, but that information wasn't particularly NixOS-specific. This commit consolidates the information related to building the kernel on Nixpkgs's documentation, while keeping any additional NixOS-specific information on NixOS's documentation. An additional README.md was created for contributor-facing documentation.
Diffstat (limited to 'nixos/doc/manual/configuration')
-rw-r--r-- | nixos/doc/manual/configuration/linux-kernel.chapter.md | 66 |
1 files changed, 3 insertions, 63 deletions
diff --git a/nixos/doc/manual/configuration/linux-kernel.chapter.md b/nixos/doc/manual/configuration/linux-kernel.chapter.md index f5bce99dd1bb..9d1b2bc2f9b8 100644 --- a/nixos/doc/manual/configuration/linux-kernel.chapter.md +++ b/nixos/doc/manual/configuration/linux-kernel.chapter.md @@ -84,26 +84,7 @@ available parameters, run `sysctl -a`. ## Building a custom kernel {#sec-linux-config-customizing} -You can customize the default kernel configuration by overriding the arguments for your kernel package: - -```nix -pkgs.linux_latest.override { - ignoreConfigErrors = true; - autoModules = false; - kernelPreferBuiltin = true; - extraStructuredConfig = with lib.kernel; { - DEBUG_KERNEL = yes; - FRAME_POINTER = yes; - KGDB = yes; - KGDB_SERIAL_CONSOLE = yes; - DEBUG_INFO = yes; - }; -} -``` - -See `pkgs/os-specific/linux/kernel/generic.nix` for details on how these arguments -affect the generated configuration. You can also build a custom version of Linux by calling -`pkgs.buildLinux` directly, which requires the `src` and `version` arguments to be specified. +Please refer to the Nixpkgs manual for the various ways of [building a custom kernel](https://nixos.org/nixpkgs/manual#sec-linux-kernel). To use your custom kernel package in your NixOS configuration, set @@ -111,50 +92,9 @@ To use your custom kernel package in your NixOS configuration, set boot.kernelPackages = pkgs.linuxPackagesFor yourCustomKernel; ``` -Note that this method will use the common configuration defined in `pkgs/os-specific/linux/kernel/common-config.nix`, -which is suitable for a NixOS system. - -If you already have a generated configuration file, you can build a kernel that uses it with `pkgs.linuxManualConfig`: - -```nix -let - baseKernel = pkgs.linux_latest; -in pkgs.linuxManualConfig { - inherit (baseKernel) src modDirVersion; - version = "${baseKernel.version}-custom"; - configfile = ./my_kernel_config; - allowImportFromDerivation = true; -} -``` - -::: {.note} -The build will fail if `modDirVersion` does not match the source's `kernel.release` file, -so `modDirVersion` should remain tied to `src`. -::: - -To edit the `.config` file for Linux X.Y, proceed as follows: - -```ShellSession -$ nix-shell '<nixpkgs>' -A linuxKernel.kernels.linux_X_Y.configEnv -$ unpackPhase -$ cd linux-* -$ make nconfig -``` - ## Developing kernel modules {#sec-linux-config-developing-modules} -When developing kernel modules it's often convenient to run -edit-compile-run loop as quickly as possible. See below snippet as an -example of developing `mellanox` drivers. - -```ShellSession -$ nix-build '<nixpkgs>' -A linuxPackages.kernel.dev -$ nix-shell '<nixpkgs>' -A linuxPackages.kernel -$ unpackPhase -$ cd linux-* -$ make -C $dev/lib/modules/*/build M=$(pwd)/drivers/net/ethernet/mellanox modules -# insmod ./drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko -``` +This section was moved to the [Nixpkgs manual](https://nixos.org/nixpkgs/manual#sec-linux-kernel-developing-modules). ## ZFS {#sec-linux-zfs} @@ -163,7 +103,7 @@ available Linux kernel. It is recommended to use the latest available LTS that's with ZFS. Usually this is the default kernel provided by nixpkgs (i.e. `pkgs.linuxPackages`). Alternatively, it's possible to pin the system to the latest available kernel -version *that is supported by ZFS* like this: +version _that is supported by ZFS_ like this: ```nix { |