mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
Merge pull request #207095 from ncfavier/linux-custom-kernel
This commit is contained in:
commit
3fc528ff7f
22 changed files with 198 additions and 169 deletions
|
@ -212,6 +212,21 @@ runTests {
|
||||||
expected = [ "1" "2" "3" ];
|
expected = [ "1" "2" "3" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
testPadVersionLess = {
|
||||||
|
expr = versions.pad 3 "1.2";
|
||||||
|
expected = "1.2.0";
|
||||||
|
};
|
||||||
|
|
||||||
|
testPadVersionLessExtra = {
|
||||||
|
expr = versions.pad 3 "1.3-rc1";
|
||||||
|
expected = "1.3.0-rc1";
|
||||||
|
};
|
||||||
|
|
||||||
|
testPadVersionMore = {
|
||||||
|
expr = versions.pad 3 "1.2.3.4";
|
||||||
|
expected = "1.2.3";
|
||||||
|
};
|
||||||
|
|
||||||
testIsStorePath = {
|
testIsStorePath = {
|
||||||
expr =
|
expr =
|
||||||
let goodPath =
|
let goodPath =
|
||||||
|
|
|
@ -46,4 +46,19 @@ rec {
|
||||||
builtins.concatStringsSep "."
|
builtins.concatStringsSep "."
|
||||||
(lib.take 2 (splitVersion v));
|
(lib.take 2 (splitVersion v));
|
||||||
|
|
||||||
|
/* Pad a version string with zeros to match the given number of components.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
pad 3 "1.2"
|
||||||
|
=> "1.2.0"
|
||||||
|
pad 3 "1.3-rc1"
|
||||||
|
=> "1.3.0-rc1"
|
||||||
|
pad 3 "1.2.3.4"
|
||||||
|
=> "1.2.3"
|
||||||
|
*/
|
||||||
|
pad = n: version: let
|
||||||
|
numericVersion = lib.head (lib.splitString "-" version);
|
||||||
|
versionSuffix = lib.removePrefix numericVersion version;
|
||||||
|
in lib.concatStringsSep "." (lib.take n (lib.splitVersion numericVersion ++ lib.genList (_: "0") n)) + versionSuffix;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,61 +82,68 @@ boot.kernel.sysctl."net.ipv4.tcp_keepalive_time" = 120;
|
||||||
sets the kernel's TCP keepalive time to 120 seconds. To see the
|
sets the kernel's TCP keepalive time to 120 seconds. To see the
|
||||||
available parameters, run `sysctl -a`.
|
available parameters, run `sysctl -a`.
|
||||||
|
|
||||||
## Customize your kernel {#sec-linux-config-customizing}
|
## Building a custom kernel {#sec-linux-config-customizing}
|
||||||
|
|
||||||
The first step before compiling the kernel is to generate an appropriate
|
You can customize the default kernel configuration by overriding the arguments for your kernel package:
|
||||||
`.config` configuration. Either you pass your own config via the
|
|
||||||
`configfile` setting of `linuxKernel.manualConfig`:
|
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
custom-kernel = let base_kernel = linuxKernel.kernels.linux_4_9;
|
pkgs.linux_latest.override {
|
||||||
in super.linuxKernel.manualConfig {
|
|
||||||
inherit (super) stdenv hostPlatform;
|
|
||||||
inherit (base_kernel) src;
|
|
||||||
version = "${base_kernel.version}-custom";
|
|
||||||
|
|
||||||
configfile = /home/me/my_kernel_config;
|
|
||||||
allowImportFromDerivation = true;
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
You can edit the config with this snippet (by default `make
|
|
||||||
menuconfig` won\'t work out of the box on nixos):
|
|
||||||
|
|
||||||
```ShellSession
|
|
||||||
nix-shell -E 'with import <nixpkgs> {}; kernelToOverride.overrideAttrs (o: {nativeBuildInputs=o.nativeBuildInputs ++ [ pkg-config ncurses ];})'
|
|
||||||
```
|
|
||||||
|
|
||||||
or you can let nixpkgs generate the configuration. Nixpkgs generates it
|
|
||||||
via answering the interactive kernel utility `make config`. The answers
|
|
||||||
depend on parameters passed to
|
|
||||||
`pkgs/os-specific/linux/kernel/generic.nix` (which you can influence by
|
|
||||||
overriding `extraConfig, autoModules,
|
|
||||||
modDirVersion, preferBuiltin, extraConfig`).
|
|
||||||
|
|
||||||
```nix
|
|
||||||
mptcp93.override ({
|
|
||||||
name="mptcp-local";
|
|
||||||
|
|
||||||
ignoreConfigErrors = true;
|
ignoreConfigErrors = true;
|
||||||
autoModules = false;
|
autoModules = false;
|
||||||
kernelPreferBuiltin = true;
|
kernelPreferBuiltin = true;
|
||||||
|
extraStructuredConfig = with lib.kernel; {
|
||||||
|
DEBUG_KERNEL = yes;
|
||||||
|
FRAME_POINTER = yes;
|
||||||
|
KGDB = yes;
|
||||||
|
KGDB_SERIAL_CONSOLE = yes;
|
||||||
|
DEBUG_INFO = yes;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
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.
|
||||||
|
|
||||||
extraConfig = ''
|
To use your custom kernel package in your NixOS configuration, set
|
||||||
DEBUG_KERNEL y
|
|
||||||
FRAME_POINTER y
|
```nix
|
||||||
KGDB y
|
boot.kernelPackages = pkgs.linuxPackagesFor yourCustomKernel;
|
||||||
KGDB_SERIAL_CONSOLE y
|
```
|
||||||
DEBUG_INFO y
|
|
||||||
'';
|
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}
|
## Developing kernel modules {#sec-linux-config-developing-modules}
|
||||||
|
|
||||||
When developing kernel modules it\'s often convenient to run
|
When developing kernel modules it's often convenient to run
|
||||||
edit-compile-run loop as quickly as possible. See below snippet as an
|
edit-compile-run loop as quickly as possible. See below snippet as an
|
||||||
example of developing `mellanox` drivers.
|
example of developing `mellanox` drivers.
|
||||||
|
|
||||||
|
|
|
@ -96,65 +96,82 @@ boot.kernel.sysctl."net.ipv4.tcp_keepalive_time" = 120;
|
||||||
available parameters, run <literal>sysctl -a</literal>.
|
available parameters, run <literal>sysctl -a</literal>.
|
||||||
</para>
|
</para>
|
||||||
<section xml:id="sec-linux-config-customizing">
|
<section xml:id="sec-linux-config-customizing">
|
||||||
<title>Customize your kernel</title>
|
<title>Building a custom kernel</title>
|
||||||
<para>
|
<para>
|
||||||
The first step before compiling the kernel is to generate an
|
You can customize the default kernel configuration by overriding
|
||||||
appropriate <literal>.config</literal> configuration. Either you
|
the arguments for your kernel package:
|
||||||
pass your own config via the <literal>configfile</literal> setting
|
|
||||||
of <literal>linuxKernel.manualConfig</literal>:
|
|
||||||
</para>
|
</para>
|
||||||
<programlisting language="bash">
|
<programlisting language="bash">
|
||||||
custom-kernel = let base_kernel = linuxKernel.kernels.linux_4_9;
|
pkgs.linux_latest.override {
|
||||||
in super.linuxKernel.manualConfig {
|
|
||||||
inherit (super) stdenv hostPlatform;
|
|
||||||
inherit (base_kernel) src;
|
|
||||||
version = "${base_kernel.version}-custom";
|
|
||||||
|
|
||||||
configfile = /home/me/my_kernel_config;
|
|
||||||
allowImportFromDerivation = true;
|
|
||||||
};
|
|
||||||
</programlisting>
|
|
||||||
<para>
|
|
||||||
You can edit the config with this snippet (by default
|
|
||||||
<literal>make menuconfig</literal> won't work out of the box on
|
|
||||||
nixos):
|
|
||||||
</para>
|
|
||||||
<programlisting>
|
|
||||||
nix-shell -E 'with import <nixpkgs> {}; kernelToOverride.overrideAttrs (o: {nativeBuildInputs=o.nativeBuildInputs ++ [ pkg-config ncurses ];})'
|
|
||||||
</programlisting>
|
|
||||||
<para>
|
|
||||||
or you can let nixpkgs generate the configuration. Nixpkgs
|
|
||||||
generates it via answering the interactive kernel utility
|
|
||||||
<literal>make config</literal>. The answers depend on parameters
|
|
||||||
passed to
|
|
||||||
<literal>pkgs/os-specific/linux/kernel/generic.nix</literal>
|
|
||||||
(which you can influence by overriding
|
|
||||||
<literal>extraConfig, autoModules, modDirVersion, preferBuiltin, extraConfig</literal>).
|
|
||||||
</para>
|
|
||||||
<programlisting language="bash">
|
|
||||||
mptcp93.override ({
|
|
||||||
name="mptcp-local";
|
|
||||||
|
|
||||||
ignoreConfigErrors = true;
|
ignoreConfigErrors = true;
|
||||||
autoModules = false;
|
autoModules = false;
|
||||||
kernelPreferBuiltin = true;
|
kernelPreferBuiltin = true;
|
||||||
|
extraStructuredConfig = with lib.kernel; {
|
||||||
enableParallelBuilding = true;
|
DEBUG_KERNEL = yes;
|
||||||
|
FRAME_POINTER = yes;
|
||||||
extraConfig = ''
|
KGDB = yes;
|
||||||
DEBUG_KERNEL y
|
KGDB_SERIAL_CONSOLE = yes;
|
||||||
FRAME_POINTER y
|
DEBUG_INFO = yes;
|
||||||
KGDB y
|
};
|
||||||
KGDB_SERIAL_CONSOLE y
|
}
|
||||||
DEBUG_INFO y
|
</programlisting>
|
||||||
'';
|
<para>
|
||||||
});
|
See <literal>pkgs/os-specific/linux/kernel/generic.nix</literal>
|
||||||
|
for details on how these arguments affect the generated
|
||||||
|
configuration. You can also build a custom version of Linux by
|
||||||
|
calling <literal>pkgs.buildLinux</literal> directly, which
|
||||||
|
requires the <literal>src</literal> and <literal>version</literal>
|
||||||
|
arguments to be specified.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
To use your custom kernel package in your NixOS configuration, set
|
||||||
|
</para>
|
||||||
|
<programlisting language="bash">
|
||||||
|
boot.kernelPackages = pkgs.linuxPackagesFor yourCustomKernel;
|
||||||
|
</programlisting>
|
||||||
|
<para>
|
||||||
|
Note that this method will use the common configuration defined in
|
||||||
|
<literal>pkgs/os-specific/linux/kernel/common-config.nix</literal>,
|
||||||
|
which is suitable for a NixOS system.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
If you already have a generated configuration file, you can build
|
||||||
|
a kernel that uses it with
|
||||||
|
<literal>pkgs.linuxManualConfig</literal>:
|
||||||
|
</para>
|
||||||
|
<programlisting language="bash">
|
||||||
|
let
|
||||||
|
baseKernel = pkgs.linux_latest;
|
||||||
|
in pkgs.linuxManualConfig {
|
||||||
|
inherit (baseKernel) src modDirVersion;
|
||||||
|
version = "${baseKernel.version}-custom";
|
||||||
|
configfile = ./my_kernel_config;
|
||||||
|
allowImportFromDerivation = true;
|
||||||
|
}
|
||||||
|
</programlisting>
|
||||||
|
<note>
|
||||||
|
<para>
|
||||||
|
The build will fail if <literal>modDirVersion</literal> does not
|
||||||
|
match the source’s <literal>kernel.release</literal> file, so
|
||||||
|
<literal>modDirVersion</literal> should remain tied to
|
||||||
|
<literal>src</literal>.
|
||||||
|
</para>
|
||||||
|
</note>
|
||||||
|
<para>
|
||||||
|
To edit the <literal>.config</literal> file for Linux X.Y, proceed
|
||||||
|
as follows:
|
||||||
|
</para>
|
||||||
|
<programlisting>
|
||||||
|
$ nix-shell '<nixpkgs>' -A linuxKernel.kernels.linux_X_Y.configEnv
|
||||||
|
$ unpackPhase
|
||||||
|
$ cd linux-*
|
||||||
|
$ make nconfig
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</section>
|
</section>
|
||||||
<section xml:id="sec-linux-config-developing-modules">
|
<section xml:id="sec-linux-config-developing-modules">
|
||||||
<title>Developing kernel modules</title>
|
<title>Developing kernel modules</title>
|
||||||
<para>
|
<para>
|
||||||
When developing kernel modules it's often convenient to run
|
When developing kernel modules it’s often convenient to run
|
||||||
edit-compile-run loop as quickly as possible. See below snippet as
|
edit-compile-run loop as quickly as possible. See below snippet as
|
||||||
an example of developing <literal>mellanox</literal> drivers.
|
an example of developing <literal>mellanox</literal> drivers.
|
||||||
</para>
|
</para>
|
||||||
|
|
|
@ -3,9 +3,10 @@ let
|
||||||
inherit (lib) mkIf mkOption types;
|
inherit (lib) mkIf mkOption types;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# This needs options.warnings, which we don't have (yet?).
|
# This needs options.warnings and options.assertions, which we don't have (yet?).
|
||||||
# imports = [
|
# imports = [
|
||||||
# (lib.mkRenamedOptionModule [ "machine" ] [ "nodes" "machine" ])
|
# (lib.mkRenamedOptionModule [ "machine" ] [ "nodes" "machine" ])
|
||||||
|
# (lib.mkRemovedOptionModule [ "minimal" ] "The minimal kernel module was removed as it was broken and not used any more in nixpkgs.")
|
||||||
# ];
|
# ];
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
|
|
|
@ -23,7 +23,7 @@ let
|
||||||
nixpkgs.config.allowAliases = false;
|
nixpkgs.config.allowAliases = false;
|
||||||
})
|
})
|
||||||
testModuleArgs.config.extraBaseModules
|
testModuleArgs.config.extraBaseModules
|
||||||
] ++ optional config.minimal ../../modules/testing/minimal-kernel.nix;
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,14 +78,6 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
minimal = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = mdDoc ''
|
|
||||||
Enable to configure all [{option}`nodes`](#test-opt-nodes) to run with a minimal kernel.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
nodesCompat = mkOption {
|
nodesCompat = mkOption {
|
||||||
internal = true;
|
internal = true;
|
||||||
description = mdDoc ''
|
description = mdDoc ''
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
{ config, pkgs, lib, ... }:
|
|
||||||
|
|
||||||
let
|
|
||||||
configfile = builtins.storePath (builtins.toFile "config" (lib.concatStringsSep "\n"
|
|
||||||
(map (builtins.getAttr "configLine") config.system.requiredKernelConfig))
|
|
||||||
);
|
|
||||||
|
|
||||||
origKernel = pkgs.buildLinux {
|
|
||||||
inherit (pkgs.linux) src version stdenv;
|
|
||||||
inherit configfile;
|
|
||||||
allowImportFromDerivation = true;
|
|
||||||
kernelPatches = [ pkgs.kernelPatches.cifs_timeout_2_6_38 ];
|
|
||||||
};
|
|
||||||
|
|
||||||
kernel = origKernel // (derivation (origKernel.drvAttrs // {
|
|
||||||
configurePhase = ''
|
|
||||||
runHook preConfigure
|
|
||||||
mkdir ../build
|
|
||||||
make $makeFlags "''${makeFlagsArray[@]}" mrproper
|
|
||||||
make $makeFlags "''${makeFlagsArray[@]}" KCONFIG_ALLCONFIG=${configfile} allnoconfig
|
|
||||||
runHook postConfigure
|
|
||||||
'';
|
|
||||||
}));
|
|
||||||
|
|
||||||
kernelPackages = pkgs.linuxPackagesFor kernel;
|
|
||||||
in {
|
|
||||||
boot.kernelPackages = kernelPackages;
|
|
||||||
}
|
|
|
@ -29,7 +29,8 @@
|
||||||
structuredExtraConfig ? {}
|
structuredExtraConfig ? {}
|
||||||
|
|
||||||
, # The version number used for the module directory
|
, # The version number used for the module directory
|
||||||
modDirVersion ? version
|
# If unspecified, this is determined automatically from the version.
|
||||||
|
modDirVersion ? null
|
||||||
|
|
||||||
, # An attribute set whose attributes express the availability of
|
, # An attribute set whose attributes express the availability of
|
||||||
# certain features in this kernel. E.g. `{iwlwifi = true;}'
|
# certain features in this kernel. E.g. `{iwlwifi = true;}'
|
||||||
|
@ -194,17 +195,26 @@ let
|
||||||
};
|
};
|
||||||
}; # end of configfile derivation
|
}; # end of configfile derivation
|
||||||
|
|
||||||
kernel = (callPackage ./manual-config.nix { inherit buildPackages; }) (basicArgs // {
|
kernel = (callPackage ./manual-config.nix { inherit lib stdenv buildPackages; }) (basicArgs // {
|
||||||
inherit modDirVersion kernelPatches randstructSeed lib stdenv extraMakeFlags extraMeta configfile;
|
inherit kernelPatches randstructSeed extraMakeFlags extraMeta configfile;
|
||||||
pos = builtins.unsafeGetAttrPos "version" args;
|
pos = builtins.unsafeGetAttrPos "version" args;
|
||||||
|
|
||||||
config = { CONFIG_MODULES = "y"; CONFIG_FW_LOADER = "m"; };
|
config = { CONFIG_MODULES = "y"; CONFIG_FW_LOADER = "m"; };
|
||||||
});
|
} // lib.optionalAttrs (modDirVersion != null) { inherit modDirVersion; });
|
||||||
|
|
||||||
passthru = basicArgs // {
|
passthru = basicArgs // {
|
||||||
features = kernelFeatures;
|
features = kernelFeatures;
|
||||||
inherit commonStructuredConfig structuredExtraConfig extraMakeFlags isZen isHardened isLibre modDirVersion;
|
inherit commonStructuredConfig structuredExtraConfig extraMakeFlags isZen isHardened isLibre;
|
||||||
isXen = lib.warn "The isXen attribute is deprecated. All Nixpkgs kernels that support it now have Xen enabled." true;
|
isXen = lib.warn "The isXen attribute is deprecated. All Nixpkgs kernels that support it now have Xen enabled." true;
|
||||||
|
|
||||||
|
# Adds dependencies needed to edit the config:
|
||||||
|
# nix-shell '<nixpkgs>' -A linux.configEnv --command 'make nconfig'
|
||||||
|
configEnv = kernel.overrideAttrs (old: {
|
||||||
|
nativeBuildInputs = old.nativeBuildInputs or [] ++ (with buildPackages; [
|
||||||
|
pkg-config ncurses
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
passthru = kernel.passthru // (removeAttrs passthru [ "passthru" ]);
|
passthru = kernel.passthru // (removeAttrs passthru [ "passthru" ]);
|
||||||
tests = let
|
tests = let
|
||||||
overridableKernel = finalKernel // {
|
overridableKernel = finalKernel // {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, modDirVersionArg ? null, ... } @ args:
|
{ lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, ... } @ args:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ buildLinux (args // rec {
|
||||||
version = "4.14.302";
|
version = "4.14.302";
|
||||||
|
|
||||||
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
|
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
|
||||||
modDirVersion = if (modDirVersionArg == null) then concatStringsSep "." (take 3 (splitVersion "${version}.0")) else modDirVersionArg;
|
modDirVersion = versions.pad 3 version;
|
||||||
|
|
||||||
# branchVersion needs to be x.y
|
# branchVersion needs to be x.y
|
||||||
extraMeta.branch = versions.majorMinor version;
|
extraMeta.branch = versions.majorMinor version;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, modDirVersionArg ? null, ... } @ args:
|
{ lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, ... } @ args:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ buildLinux (args // rec {
|
||||||
version = "4.19.269";
|
version = "4.19.269";
|
||||||
|
|
||||||
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
|
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
|
||||||
modDirVersion = if (modDirVersionArg == null) then concatStringsSep "." (take 3 (splitVersion "${version}.0")) else modDirVersionArg;
|
modDirVersion = versions.pad 3 version;
|
||||||
|
|
||||||
# branchVersion needs to be x.y
|
# branchVersion needs to be x.y
|
||||||
extraMeta.branch = versions.majorMinor version;
|
extraMeta.branch = versions.majorMinor version;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, modDirVersionArg ? null, ... } @ args:
|
{ lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, ... } @ args:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ buildLinux (args // rec {
|
||||||
version = "5.10.161";
|
version = "5.10.161";
|
||||||
|
|
||||||
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
|
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
|
||||||
modDirVersion = if (modDirVersionArg == null) then concatStringsSep "." (take 3 (splitVersion "${version}.0")) else modDirVersionArg;
|
modDirVersion = versions.pad 3 version;
|
||||||
|
|
||||||
# branchVersion needs to be x.y
|
# branchVersion needs to be x.y
|
||||||
extraMeta.branch = versions.majorMinor version;
|
extraMeta.branch = versions.majorMinor version;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, modDirVersionArg ? null, ... } @ args:
|
{ lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, ... } @ args:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ buildLinux (args // rec {
|
||||||
version = "5.15.85";
|
version = "5.15.85";
|
||||||
|
|
||||||
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
|
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
|
||||||
modDirVersion = if (modDirVersionArg == null) then concatStringsSep "." (take 3 (splitVersion "${version}.0")) else modDirVersionArg;
|
modDirVersion = versions.pad 3 version;
|
||||||
|
|
||||||
# branchVersion needs to be x.y
|
# branchVersion needs to be x.y
|
||||||
extraMeta.branch = versions.majorMinor version;
|
extraMeta.branch = versions.majorMinor version;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, modDirVersionArg ? null, ... } @ args:
|
{ lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, ... } @ args:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ buildLinux (args // rec {
|
||||||
version = "5.4.228";
|
version = "5.4.228";
|
||||||
|
|
||||||
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
|
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
|
||||||
modDirVersion = if (modDirVersionArg == null) then concatStringsSep "." (take 3 (splitVersion "${version}.0")) else modDirVersionArg;
|
modDirVersion = versions.pad 3 version;
|
||||||
|
|
||||||
# branchVersion needs to be x.y
|
# branchVersion needs to be x.y
|
||||||
extraMeta.branch = versions.majorMinor version;
|
extraMeta.branch = versions.majorMinor version;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, modDirVersionArg ? null, ... } @ args:
|
{ lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, ... } @ args:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ buildLinux (args // rec {
|
||||||
version = "6.0.15";
|
version = "6.0.15";
|
||||||
|
|
||||||
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
|
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
|
||||||
modDirVersion = if (modDirVersionArg == null) then concatStringsSep "." (take 3 (splitVersion "${version}.0")) else modDirVersionArg;
|
modDirVersion = versions.pad 3 version;
|
||||||
|
|
||||||
# branchVersion needs to be x.y
|
# branchVersion needs to be x.y
|
||||||
extraMeta.branch = versions.majorMinor version;
|
extraMeta.branch = versions.majorMinor version;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, modDirVersionArg ? null, ... } @ args:
|
{ lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, ... } @ args:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ buildLinux (args // rec {
|
||||||
version = "6.1.1";
|
version = "6.1.1";
|
||||||
|
|
||||||
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
|
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
|
||||||
modDirVersion = if (modDirVersionArg == null) then concatStringsSep "." (take 3 (splitVersion "${version}.0")) else modDirVersionArg;
|
modDirVersion = versions.pad 3 version;
|
||||||
|
|
||||||
# branchVersion needs to be x.y
|
# branchVersion needs to be x.y
|
||||||
extraMeta.branch = versions.majorMinor version;
|
extraMeta.branch = versions.majorMinor version;
|
||||||
|
|
|
@ -13,8 +13,7 @@ in buildLinux (args // {
|
||||||
inherit version;
|
inherit version;
|
||||||
|
|
||||||
# modDirVersion needs a patch number, change X.Y-rtZ to X.Y.0-rtZ.
|
# modDirVersion needs a patch number, change X.Y-rtZ to X.Y.0-rtZ.
|
||||||
modDirVersion = if (builtins.match "[^.]*[.][^.]*-.*" version) == null then version
|
modDirVersion = lib.versions.pad 3 version;
|
||||||
else lib.replaceStrings ["-"] [".0-"] version;
|
|
||||||
|
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
url = "mirror://kernel/linux/kernel/v5.x/linux-${kversion}.tar.xz";
|
url = "mirror://kernel/linux/kernel/v5.x/linux-${kversion}.tar.xz";
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, modDirVersionArg ? null, ... } @ args:
|
{ lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, ... } @ args:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ buildLinux (args // rec {
|
||||||
extraMeta.branch = lib.versions.majorMinor version;
|
extraMeta.branch = lib.versions.majorMinor version;
|
||||||
|
|
||||||
# modDirVersion needs to be x.y.z, will always add .0
|
# modDirVersion needs to be x.y.z, will always add .0
|
||||||
modDirVersion = if (modDirVersionArg == null) then builtins.replaceStrings ["-"] [".0-"] version else modDirVersionArg;
|
modDirVersion = versions.pad 3 version;
|
||||||
|
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
url = "https://git.kernel.org/torvalds/t/linux-${version}.tar.gz";
|
url = "https://git.kernel.org/torvalds/t/linux-${version}.tar.gz";
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
{ lib, buildPackages, runCommand, nettools, bc, bison, flex, perl, rsync, gmp, libmpc, mpfr, openssl
|
{ lib, stdenv, buildPackages, runCommand, nettools, bc, bison, flex, perl, rsync, gmp, libmpc, mpfr, openssl
|
||||||
, libelf, cpio, elfutils, zstd, python3Minimal, zlib, pahole
|
, libelf, cpio, elfutils, zstd, python3Minimal, zlib, pahole
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
lib_ = lib;
|
||||||
|
stdenv_ = stdenv;
|
||||||
|
|
||||||
readConfig = configfile: import (runCommand "config.nix" {} ''
|
readConfig = configfile: import (runCommand "config.nix" {} ''
|
||||||
echo "{" > "$out"
|
echo "{" > "$out"
|
||||||
while IFS='=' read key val; do
|
while IFS='=' read key val; do
|
||||||
|
@ -12,18 +15,16 @@ let
|
||||||
done < "${configfile}"
|
done < "${configfile}"
|
||||||
echo "}" >> $out
|
echo "}" >> $out
|
||||||
'').outPath;
|
'').outPath;
|
||||||
in {
|
in lib.makeOverridable ({
|
||||||
lib,
|
|
||||||
# Allow overriding stdenv on each buildLinux call
|
|
||||||
stdenv,
|
|
||||||
# The kernel version
|
# The kernel version
|
||||||
version,
|
version,
|
||||||
# Position of the Linux build expression
|
# Position of the Linux build expression
|
||||||
pos ? null,
|
pos ? null,
|
||||||
# Additional kernel make flags
|
# Additional kernel make flags
|
||||||
extraMakeFlags ? [],
|
extraMakeFlags ? [],
|
||||||
# The version of the kernel module directory
|
# The name of the kernel module directory
|
||||||
modDirVersion ? version,
|
# Needs to be X.Y.Z[-extra], so pad with zeros if needed.
|
||||||
|
modDirVersion ? lib.versions.pad 3 version,
|
||||||
# The kernel source (tarball, git checkout, etc.)
|
# The kernel source (tarball, git checkout, etc.)
|
||||||
src,
|
src,
|
||||||
# a list of { name=..., patch=..., extraConfig=...} patches
|
# a list of { name=..., patch=..., extraConfig=...} patches
|
||||||
|
@ -36,7 +37,7 @@ in {
|
||||||
# Custom seed used for CONFIG_GCC_PLUGIN_RANDSTRUCT if enabled. This is
|
# Custom seed used for CONFIG_GCC_PLUGIN_RANDSTRUCT if enabled. This is
|
||||||
# automatically extended with extra per-version and per-config values.
|
# automatically extended with extra per-version and per-config values.
|
||||||
randstructSeed ? "",
|
randstructSeed ? "",
|
||||||
# Use defaultMeta // extraMeta
|
# Extra meta attributes
|
||||||
extraMeta ? {},
|
extraMeta ? {},
|
||||||
|
|
||||||
# for module compatibility
|
# for module compatibility
|
||||||
|
@ -47,7 +48,7 @@ in {
|
||||||
# Whether to utilize the controversial import-from-derivation feature to parse the config
|
# Whether to utilize the controversial import-from-derivation feature to parse the config
|
||||||
allowImportFromDerivation ? false,
|
allowImportFromDerivation ? false,
|
||||||
# ignored
|
# ignored
|
||||||
features ? null,
|
features ? null, lib ? lib_, stdenv ? stdenv_,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -386,4 +387,4 @@ stdenv.mkDerivation ((drvAttrs config stdenv.hostPlatform.linux-kernel kernelPat
|
||||||
++ extraMakeFlags;
|
++ extraMakeFlags;
|
||||||
|
|
||||||
karch = stdenv.hostPlatform.linuxArch;
|
karch = stdenv.hostPlatform.linuxArch;
|
||||||
} // (optionalAttrs (pos != null) { inherit pos; }))
|
} // (optionalAttrs (pos != null) { inherit pos; })))
|
||||||
|
|
|
@ -16,7 +16,7 @@ let
|
||||||
|
|
||||||
xanmodKernelFor = { version, suffix ? "xanmod1", hash, variant }: buildLinux (args // rec {
|
xanmodKernelFor = { version, suffix ? "xanmod1", hash, variant }: buildLinux (args // rec {
|
||||||
inherit version;
|
inherit version;
|
||||||
modDirVersion = "${version}-${suffix}";
|
modDirVersion = lib.versions.pad 3 "${version}-${suffix}";
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "xanmod";
|
owner = "xanmod";
|
||||||
|
|
|
@ -18,7 +18,7 @@ let
|
||||||
};
|
};
|
||||||
zenKernelsFor = { version, suffix, sha256, isLqx }: buildLinux (args // {
|
zenKernelsFor = { version, suffix, sha256, isLqx }: buildLinux (args // {
|
||||||
inherit version;
|
inherit version;
|
||||||
modDirVersion = "${lib.concatStringsSep "." (lib.take 3 (lib.splitVersion version ++ [ "0" "0" ]))}-${suffix}";
|
modDirVersion = lib.versions.pad 3 "${version}-${suffix}";
|
||||||
isZen = true;
|
isZen = true;
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
|
|
|
@ -25546,7 +25546,7 @@ with pkgs;
|
||||||
linuxPackages_custom_tinyconfig_kernel = let
|
linuxPackages_custom_tinyconfig_kernel = let
|
||||||
base = linuxPackages.kernel;
|
base = linuxPackages.kernel;
|
||||||
tinyLinuxPackages = linuxKernel.customPackage {
|
tinyLinuxPackages = linuxKernel.customPackage {
|
||||||
inherit (base) version src;
|
inherit (base) version modDirVersion src;
|
||||||
allowImportFromDerivation = false;
|
allowImportFromDerivation = false;
|
||||||
configfile = linuxConfig {
|
configfile = linuxConfig {
|
||||||
makeTarget = "tinyconfig";
|
makeTarget = "tinyconfig";
|
||||||
|
|
|
@ -40,6 +40,7 @@ let
|
||||||
};
|
};
|
||||||
argsOverride = {
|
argsOverride = {
|
||||||
inherit version;
|
inherit version;
|
||||||
|
modDirVersion = modDirVersion' + kernelPatches.hardened.${kernel.meta.branch}.extra;
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
url = "mirror://kernel/linux/kernel/v${major}.x/linux-${version}.tar.xz";
|
url = "mirror://kernel/linux/kernel/v${major}.x/linux-${version}.tar.xz";
|
||||||
inherit sha256;
|
inherit sha256;
|
||||||
|
@ -48,7 +49,6 @@ let
|
||||||
kernelPatches = kernel.kernelPatches ++ [
|
kernelPatches = kernel.kernelPatches ++ [
|
||||||
kernelPatches.hardened.${kernel.meta.branch}
|
kernelPatches.hardened.${kernel.meta.branch}
|
||||||
];
|
];
|
||||||
modDirVersionArg = modDirVersion' + (kernelPatches.hardened.${kernel.meta.branch}).extra;
|
|
||||||
isHardened = true;
|
isHardened = true;
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
|
@ -593,11 +593,11 @@ in {
|
||||||
linux_hardkernel_latest = packages.hardkernel_4_14;
|
linux_hardkernel_latest = packages.hardkernel_4_14;
|
||||||
};
|
};
|
||||||
|
|
||||||
manualConfig = makeOverridable (callPackage ../os-specific/linux/kernel/manual-config.nix {});
|
manualConfig = callPackage ../os-specific/linux/kernel/manual-config.nix {};
|
||||||
|
|
||||||
customPackage = { version, src, configfile, allowImportFromDerivation ? true }:
|
customPackage = { version, src, modDirVersion ? lib.versions.pad 3 version, configfile, allowImportFromDerivation ? true }:
|
||||||
recurseIntoAttrs (packagesFor (manualConfig {
|
recurseIntoAttrs (packagesFor (manualConfig {
|
||||||
inherit version src configfile lib stdenv allowImportFromDerivation;
|
inherit version src modDirVersion configfile allowImportFromDerivation;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
# Derive one of the default .config files
|
# Derive one of the default .config files
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue