Merge pull request #207095 from ncfavier/linux-custom-kernel

authored by Naïm Favier and committed by GitHub 3fc528ff b25ad6c1

+189 -160
+15
lib/tests/misc.nix
··· 212 212 expected = [ "1" "2" "3" ]; 213 213 }; 214 214 215 + testPadVersionLess = { 216 + expr = versions.pad 3 "1.2"; 217 + expected = "1.2.0"; 218 + }; 219 + 220 + testPadVersionLessExtra = { 221 + expr = versions.pad 3 "1.3-rc1"; 222 + expected = "1.3.0-rc1"; 223 + }; 224 + 225 + testPadVersionMore = { 226 + expr = versions.pad 3 "1.2.3.4"; 227 + expected = "1.2.3"; 228 + }; 229 + 215 230 testIsStorePath = { 216 231 expr = 217 232 let goodPath =
+15
lib/versions.nix
··· 46 46 builtins.concatStringsSep "." 47 47 (lib.take 2 (splitVersion v)); 48 48 49 + /* Pad a version string with zeros to match the given number of components. 50 + 51 + Example: 52 + pad 3 "1.2" 53 + => "1.2.0" 54 + pad 3 "1.3-rc1" 55 + => "1.3.0-rc1" 56 + pad 3 "1.2.3.4" 57 + => "1.2.3" 58 + */ 59 + pad = n: version: let 60 + numericVersion = lib.head (lib.splitString "-" version); 61 + versionSuffix = lib.removePrefix numericVersion version; 62 + in lib.concatStringsSep "." (lib.take n (lib.splitVersion numericVersion ++ lib.genList (_: "0") n)) + versionSuffix; 63 + 49 64 }
+45 -38
nixos/doc/manual/configuration/linux-kernel.chapter.md
··· 82 82 sets the kernel's TCP keepalive time to 120 seconds. To see the 83 83 available parameters, run `sysctl -a`. 84 84 85 - ## Customize your kernel {#sec-linux-config-customizing} 85 + ## Building a custom kernel {#sec-linux-config-customizing} 86 86 87 - The first step before compiling the kernel is to generate an appropriate 88 - `.config` configuration. Either you pass your own config via the 89 - `configfile` setting of `linuxKernel.manualConfig`: 87 + You can customize the default kernel configuration by overriding the arguments for your kernel package: 90 88 91 89 ```nix 92 - custom-kernel = let base_kernel = linuxKernel.kernels.linux_4_9; 93 - in super.linuxKernel.manualConfig { 94 - inherit (super) stdenv hostPlatform; 95 - inherit (base_kernel) src; 96 - version = "${base_kernel.version}-custom"; 97 - 98 - configfile = /home/me/my_kernel_config; 99 - allowImportFromDerivation = true; 100 - }; 90 + pkgs.linux_latest.override { 91 + ignoreConfigErrors = true; 92 + autoModules = false; 93 + kernelPreferBuiltin = true; 94 + extraStructuredConfig = with lib.kernel; { 95 + DEBUG_KERNEL = yes; 96 + FRAME_POINTER = yes; 97 + KGDB = yes; 98 + KGDB_SERIAL_CONSOLE = yes; 99 + DEBUG_INFO = yes; 100 + }; 101 + } 101 102 ``` 102 103 103 - You can edit the config with this snippet (by default `make 104 - menuconfig` won\'t work out of the box on nixos): 104 + See `pkgs/os-specific/linux/kernel/generic.nix` for details on how these arguments 105 + affect the generated configuration. You can also build a custom version of Linux by calling 106 + `pkgs.buildLinux` directly, which requires the `src` and `version` arguments to be specified. 107 + 108 + To use your custom kernel package in your NixOS configuration, set 105 109 106 - ```ShellSession 107 - nix-shell -E 'with import <nixpkgs> {}; kernelToOverride.overrideAttrs (o: {nativeBuildInputs=o.nativeBuildInputs ++ [ pkg-config ncurses ];})' 110 + ```nix 111 + boot.kernelPackages = pkgs.linuxPackagesFor yourCustomKernel; 108 112 ``` 109 113 110 - or you can let nixpkgs generate the configuration. Nixpkgs generates it 111 - via answering the interactive kernel utility `make config`. The answers 112 - depend on parameters passed to 113 - `pkgs/os-specific/linux/kernel/generic.nix` (which you can influence by 114 - overriding `extraConfig, autoModules, 115 - modDirVersion, preferBuiltin, extraConfig`). 114 + Note that this method will use the common configuration defined in `pkgs/os-specific/linux/kernel/common-config.nix`, 115 + which is suitable for a NixOS system. 116 + 117 + If you already have a generated configuration file, you can build a kernel that uses it with `pkgs.linuxManualConfig`: 116 118 117 119 ```nix 118 - mptcp93.override ({ 119 - name="mptcp-local"; 120 + let 121 + baseKernel = pkgs.linux_latest; 122 + in pkgs.linuxManualConfig { 123 + inherit (baseKernel) src modDirVersion; 124 + version = "${baseKernel.version}-custom"; 125 + configfile = ./my_kernel_config; 126 + allowImportFromDerivation = true; 127 + } 128 + ``` 120 129 121 - ignoreConfigErrors = true; 122 - autoModules = false; 123 - kernelPreferBuiltin = true; 130 + ::: {.note} 131 + The build will fail if `modDirVersion` does not match the source's `kernel.release` file, 132 + so `modDirVersion` should remain tied to `src`. 133 + ::: 124 134 125 - enableParallelBuilding = true; 135 + To edit the `.config` file for Linux X.Y, proceed as follows: 126 136 127 - extraConfig = '' 128 - DEBUG_KERNEL y 129 - FRAME_POINTER y 130 - KGDB y 131 - KGDB_SERIAL_CONSOLE y 132 - DEBUG_INFO y 133 - ''; 134 - }); 137 + ```ShellSession 138 + $ nix-shell '<nixpkgs>' -A linuxKernel.kernels.linux_X_Y.configEnv 139 + $ unpackPhase 140 + $ cd linux-* 141 + $ make nconfig 135 142 ``` 136 143 137 144 ## Developing kernel modules {#sec-linux-config-developing-modules} 138 145 139 - When developing kernel modules it\'s often convenient to run 146 + When developing kernel modules it's often convenient to run 140 147 edit-compile-run loop as quickly as possible. See below snippet as an 141 148 example of developing `mellanox` drivers. 142 149
+61 -44
nixos/doc/manual/from_md/configuration/linux-kernel.chapter.xml
··· 96 96 available parameters, run <literal>sysctl -a</literal>. 97 97 </para> 98 98 <section xml:id="sec-linux-config-customizing"> 99 - <title>Customize your kernel</title> 99 + <title>Building a custom kernel</title> 100 100 <para> 101 - The first step before compiling the kernel is to generate an 102 - appropriate <literal>.config</literal> configuration. Either you 103 - pass your own config via the <literal>configfile</literal> setting 104 - of <literal>linuxKernel.manualConfig</literal>: 101 + You can customize the default kernel configuration by overriding 102 + the arguments for your kernel package: 105 103 </para> 106 104 <programlisting language="bash"> 107 - custom-kernel = let base_kernel = linuxKernel.kernels.linux_4_9; 108 - in super.linuxKernel.manualConfig { 109 - inherit (super) stdenv hostPlatform; 110 - inherit (base_kernel) src; 111 - version = &quot;${base_kernel.version}-custom&quot;; 112 - 113 - configfile = /home/me/my_kernel_config; 114 - allowImportFromDerivation = true; 115 - }; 105 + pkgs.linux_latest.override { 106 + ignoreConfigErrors = true; 107 + autoModules = false; 108 + kernelPreferBuiltin = true; 109 + extraStructuredConfig = with lib.kernel; { 110 + DEBUG_KERNEL = yes; 111 + FRAME_POINTER = yes; 112 + KGDB = yes; 113 + KGDB_SERIAL_CONSOLE = yes; 114 + DEBUG_INFO = yes; 115 + }; 116 + } 116 117 </programlisting> 117 118 <para> 118 - You can edit the config with this snippet (by default 119 - <literal>make menuconfig</literal> won't work out of the box on 120 - nixos): 119 + See <literal>pkgs/os-specific/linux/kernel/generic.nix</literal> 120 + for details on how these arguments affect the generated 121 + configuration. You can also build a custom version of Linux by 122 + calling <literal>pkgs.buildLinux</literal> directly, which 123 + requires the <literal>src</literal> and <literal>version</literal> 124 + arguments to be specified. 121 125 </para> 122 - <programlisting> 123 - nix-shell -E 'with import &lt;nixpkgs&gt; {}; kernelToOverride.overrideAttrs (o: {nativeBuildInputs=o.nativeBuildInputs ++ [ pkg-config ncurses ];})' 126 + <para> 127 + To use your custom kernel package in your NixOS configuration, set 128 + </para> 129 + <programlisting language="bash"> 130 + boot.kernelPackages = pkgs.linuxPackagesFor yourCustomKernel; 124 131 </programlisting> 125 132 <para> 126 - or you can let nixpkgs generate the configuration. Nixpkgs 127 - generates it via answering the interactive kernel utility 128 - <literal>make config</literal>. The answers depend on parameters 129 - passed to 130 - <literal>pkgs/os-specific/linux/kernel/generic.nix</literal> 131 - (which you can influence by overriding 132 - <literal>extraConfig, autoModules, modDirVersion, preferBuiltin, extraConfig</literal>). 133 + Note that this method will use the common configuration defined in 134 + <literal>pkgs/os-specific/linux/kernel/common-config.nix</literal>, 135 + which is suitable for a NixOS system. 136 + </para> 137 + <para> 138 + If you already have a generated configuration file, you can build 139 + a kernel that uses it with 140 + <literal>pkgs.linuxManualConfig</literal>: 133 141 </para> 134 142 <programlisting language="bash"> 135 - mptcp93.override ({ 136 - name=&quot;mptcp-local&quot;; 137 - 138 - ignoreConfigErrors = true; 139 - autoModules = false; 140 - kernelPreferBuiltin = true; 141 - 142 - enableParallelBuilding = true; 143 - 144 - extraConfig = '' 145 - DEBUG_KERNEL y 146 - FRAME_POINTER y 147 - KGDB y 148 - KGDB_SERIAL_CONSOLE y 149 - DEBUG_INFO y 150 - ''; 151 - }); 143 + let 144 + baseKernel = pkgs.linux_latest; 145 + in pkgs.linuxManualConfig { 146 + inherit (baseKernel) src modDirVersion; 147 + version = &quot;${baseKernel.version}-custom&quot;; 148 + configfile = ./my_kernel_config; 149 + allowImportFromDerivation = true; 150 + } 151 + </programlisting> 152 + <note> 153 + <para> 154 + The build will fail if <literal>modDirVersion</literal> does not 155 + match the source’s <literal>kernel.release</literal> file, so 156 + <literal>modDirVersion</literal> should remain tied to 157 + <literal>src</literal>. 158 + </para> 159 + </note> 160 + <para> 161 + To edit the <literal>.config</literal> file for Linux X.Y, proceed 162 + as follows: 163 + </para> 164 + <programlisting> 165 + $ nix-shell '&lt;nixpkgs&gt;' -A linuxKernel.kernels.linux_X_Y.configEnv 166 + $ unpackPhase 167 + $ cd linux-* 168 + $ make nconfig 152 169 </programlisting> 153 170 </section> 154 171 <section xml:id="sec-linux-config-developing-modules"> 155 172 <title>Developing kernel modules</title> 156 173 <para> 157 - When developing kernel modules it's often convenient to run 174 + When developing kernel modules it’s often convenient to run 158 175 edit-compile-run loop as quickly as possible. See below snippet as 159 176 an example of developing <literal>mellanox</literal> drivers. 160 177 </para>
+2 -1
nixos/lib/testing/legacy.nix
··· 3 3 inherit (lib) mkIf mkOption types; 4 4 in 5 5 { 6 - # This needs options.warnings, which we don't have (yet?). 6 + # This needs options.warnings and options.assertions, which we don't have (yet?). 7 7 # imports = [ 8 8 # (lib.mkRenamedOptionModule [ "machine" ] [ "nodes" "machine" ]) 9 + # (lib.mkRemovedOptionModule [ "minimal" ] "The minimal kernel module was removed as it was broken and not used any more in nixpkgs.") 9 10 # ]; 10 11 11 12 options = {
+1 -9
nixos/lib/testing/nodes.nix
··· 23 23 nixpkgs.config.allowAliases = false; 24 24 }) 25 25 testModuleArgs.config.extraBaseModules 26 - ] ++ optional config.minimal ../../modules/testing/minimal-kernel.nix; 26 + ]; 27 27 }; 28 28 29 29 ··· 75 75 An attribute set of arbitrary values that will be made available as module arguments during the resolution of module `imports`. 76 76 77 77 Note that it is not possible to override these from within the NixOS configurations. If you argument is not relevant to `imports`, consider setting {option}`defaults._module.args.<name>` instead. 78 - ''; 79 - }; 80 - 81 - minimal = mkOption { 82 - type = types.bool; 83 - default = false; 84 - description = mdDoc '' 85 - Enable to configure all [{option}`nodes`](#test-opt-nodes) to run with a minimal kernel. 86 78 ''; 87 79 }; 88 80
-28
nixos/modules/testing/minimal-kernel.nix
··· 1 - { config, pkgs, lib, ... }: 2 - 3 - let 4 - configfile = builtins.storePath (builtins.toFile "config" (lib.concatStringsSep "\n" 5 - (map (builtins.getAttr "configLine") config.system.requiredKernelConfig)) 6 - ); 7 - 8 - origKernel = pkgs.buildLinux { 9 - inherit (pkgs.linux) src version stdenv; 10 - inherit configfile; 11 - allowImportFromDerivation = true; 12 - kernelPatches = [ pkgs.kernelPatches.cifs_timeout_2_6_38 ]; 13 - }; 14 - 15 - kernel = origKernel // (derivation (origKernel.drvAttrs // { 16 - configurePhase = '' 17 - runHook preConfigure 18 - mkdir ../build 19 - make $makeFlags "''${makeFlagsArray[@]}" mrproper 20 - make $makeFlags "''${makeFlagsArray[@]}" KCONFIG_ALLCONFIG=${configfile} allnoconfig 21 - runHook postConfigure 22 - ''; 23 - })); 24 - 25 - kernelPackages = pkgs.linuxPackagesFor kernel; 26 - in { 27 - boot.kernelPackages = kernelPackages; 28 - }
+15 -5
pkgs/os-specific/linux/kernel/generic.nix
··· 29 29 structuredExtraConfig ? {} 30 30 31 31 , # The version number used for the module directory 32 - modDirVersion ? version 32 + # If unspecified, this is determined automatically from the version. 33 + modDirVersion ? null 33 34 34 35 , # An attribute set whose attributes express the availability of 35 36 # certain features in this kernel. E.g. `{iwlwifi = true;}' ··· 194 195 }; 195 196 }; # end of configfile derivation 196 197 197 - kernel = (callPackage ./manual-config.nix { inherit buildPackages; }) (basicArgs // { 198 - inherit modDirVersion kernelPatches randstructSeed lib stdenv extraMakeFlags extraMeta configfile; 198 + kernel = (callPackage ./manual-config.nix { inherit lib stdenv buildPackages; }) (basicArgs // { 199 + inherit kernelPatches randstructSeed extraMakeFlags extraMeta configfile; 199 200 pos = builtins.unsafeGetAttrPos "version" args; 200 201 201 202 config = { CONFIG_MODULES = "y"; CONFIG_FW_LOADER = "m"; }; 202 - }); 203 + } // lib.optionalAttrs (modDirVersion != null) { inherit modDirVersion; }); 203 204 204 205 passthru = basicArgs // { 205 206 features = kernelFeatures; 206 - inherit commonStructuredConfig structuredExtraConfig extraMakeFlags isZen isHardened isLibre modDirVersion; 207 + inherit commonStructuredConfig structuredExtraConfig extraMakeFlags isZen isHardened isLibre; 207 208 isXen = lib.warn "The isXen attribute is deprecated. All Nixpkgs kernels that support it now have Xen enabled." true; 209 + 210 + # Adds dependencies needed to edit the config: 211 + # nix-shell '<nixpkgs>' -A linux.configEnv --command 'make nconfig' 212 + configEnv = kernel.overrideAttrs (old: { 213 + nativeBuildInputs = old.nativeBuildInputs or [] ++ (with buildPackages; [ 214 + pkg-config ncurses 215 + ]); 216 + }); 217 + 208 218 passthru = kernel.passthru // (removeAttrs passthru [ "passthru" ]); 209 219 tests = let 210 220 overridableKernel = finalKernel // {
+2 -2
pkgs/os-specific/linux/kernel/linux-4.14.nix
··· 1 - { lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, modDirVersionArg ? null, ... } @ args: 1 + { lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, ... } @ args: 2 2 3 3 with lib; 4 4 ··· 6 6 version = "4.14.302"; 7 7 8 8 # modDirVersion needs to be x.y.z, will automatically add .0 if needed 9 - modDirVersion = if (modDirVersionArg == null) then concatStringsSep "." (take 3 (splitVersion "${version}.0")) else modDirVersionArg; 9 + modDirVersion = versions.pad 3 version; 10 10 11 11 # branchVersion needs to be x.y 12 12 extraMeta.branch = versions.majorMinor version;
+2 -2
pkgs/os-specific/linux/kernel/linux-4.19.nix
··· 1 - { lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, modDirVersionArg ? null, ... } @ args: 1 + { lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, ... } @ args: 2 2 3 3 with lib; 4 4 ··· 6 6 version = "4.19.269"; 7 7 8 8 # modDirVersion needs to be x.y.z, will automatically add .0 if needed 9 - modDirVersion = if (modDirVersionArg == null) then concatStringsSep "." (take 3 (splitVersion "${version}.0")) else modDirVersionArg; 9 + modDirVersion = versions.pad 3 version; 10 10 11 11 # branchVersion needs to be x.y 12 12 extraMeta.branch = versions.majorMinor version;
+2 -2
pkgs/os-specific/linux/kernel/linux-5.10.nix
··· 1 - { lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, modDirVersionArg ? null, ... } @ args: 1 + { lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, ... } @ args: 2 2 3 3 with lib; 4 4 ··· 6 6 version = "5.10.161"; 7 7 8 8 # modDirVersion needs to be x.y.z, will automatically add .0 if needed 9 - modDirVersion = if (modDirVersionArg == null) then concatStringsSep "." (take 3 (splitVersion "${version}.0")) else modDirVersionArg; 9 + modDirVersion = versions.pad 3 version; 10 10 11 11 # branchVersion needs to be x.y 12 12 extraMeta.branch = versions.majorMinor version;
+2 -2
pkgs/os-specific/linux/kernel/linux-5.15.nix
··· 1 - { lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, modDirVersionArg ? null, ... } @ args: 1 + { lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, ... } @ args: 2 2 3 3 with lib; 4 4 ··· 6 6 version = "5.15.85"; 7 7 8 8 # modDirVersion needs to be x.y.z, will automatically add .0 if needed 9 - modDirVersion = if (modDirVersionArg == null) then concatStringsSep "." (take 3 (splitVersion "${version}.0")) else modDirVersionArg; 9 + modDirVersion = versions.pad 3 version; 10 10 11 11 # branchVersion needs to be x.y 12 12 extraMeta.branch = versions.majorMinor version;
+2 -2
pkgs/os-specific/linux/kernel/linux-5.4.nix
··· 1 - { lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, modDirVersionArg ? null, ... } @ args: 1 + { lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, ... } @ args: 2 2 3 3 with lib; 4 4 ··· 6 6 version = "5.4.228"; 7 7 8 8 # modDirVersion needs to be x.y.z, will automatically add .0 if needed 9 - modDirVersion = if (modDirVersionArg == null) then concatStringsSep "." (take 3 (splitVersion "${version}.0")) else modDirVersionArg; 9 + modDirVersion = versions.pad 3 version; 10 10 11 11 # branchVersion needs to be x.y 12 12 extraMeta.branch = versions.majorMinor version;
+2 -2
pkgs/os-specific/linux/kernel/linux-6.0.nix
··· 1 - { lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, modDirVersionArg ? null, ... } @ args: 1 + { lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, ... } @ args: 2 2 3 3 with lib; 4 4 ··· 6 6 version = "6.0.15"; 7 7 8 8 # modDirVersion needs to be x.y.z, will automatically add .0 if needed 9 - modDirVersion = if (modDirVersionArg == null) then concatStringsSep "." (take 3 (splitVersion "${version}.0")) else modDirVersionArg; 9 + modDirVersion = versions.pad 3 version; 10 10 11 11 # branchVersion needs to be x.y 12 12 extraMeta.branch = versions.majorMinor version;
+2 -2
pkgs/os-specific/linux/kernel/linux-6.1.nix
··· 1 - { lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, modDirVersionArg ? null, ... } @ args: 1 + { lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, ... } @ args: 2 2 3 3 with lib; 4 4 ··· 6 6 version = "6.1.1"; 7 7 8 8 # modDirVersion needs to be x.y.z, will automatically add .0 if needed 9 - modDirVersion = if (modDirVersionArg == null) then concatStringsSep "." (take 3 (splitVersion "${version}.0")) else modDirVersionArg; 9 + modDirVersion = versions.pad 3 version; 10 10 11 11 # branchVersion needs to be x.y 12 12 extraMeta.branch = versions.majorMinor version;
+1 -2
pkgs/os-specific/linux/kernel/linux-rt-5.10.nix
··· 13 13 inherit version; 14 14 15 15 # modDirVersion needs a patch number, change X.Y-rtZ to X.Y.0-rtZ. 16 - modDirVersion = if (builtins.match "[^.]*[.][^.]*-.*" version) == null then version 17 - else lib.replaceStrings ["-"] [".0-"] version; 16 + modDirVersion = lib.versions.pad 3 version; 18 17 19 18 src = fetchurl { 20 19 url = "mirror://kernel/linux/kernel/v5.x/linux-${kversion}.tar.xz";
+2 -2
pkgs/os-specific/linux/kernel/linux-testing.nix
··· 1 - { lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, modDirVersionArg ? null, ... } @ args: 1 + { lib, buildPackages, fetchurl, perl, buildLinux, nixosTests, ... } @ args: 2 2 3 3 with lib; 4 4 ··· 7 7 extraMeta.branch = lib.versions.majorMinor version; 8 8 9 9 # modDirVersion needs to be x.y.z, will always add .0 10 - modDirVersion = if (modDirVersionArg == null) then builtins.replaceStrings ["-"] [".0-"] version else modDirVersionArg; 10 + modDirVersion = versions.pad 3 version; 11 11 12 12 src = fetchurl { 13 13 url = "https://git.kernel.org/torvalds/t/linux-${version}.tar.gz";
+11 -10
pkgs/os-specific/linux/kernel/manual-config.nix
··· 1 - { lib, buildPackages, runCommand, nettools, bc, bison, flex, perl, rsync, gmp, libmpc, mpfr, openssl 1 + { lib, stdenv, buildPackages, runCommand, nettools, bc, bison, flex, perl, rsync, gmp, libmpc, mpfr, openssl 2 2 , libelf, cpio, elfutils, zstd, python3Minimal, zlib, pahole 3 3 }: 4 4 5 5 let 6 + lib_ = lib; 7 + stdenv_ = stdenv; 8 + 6 9 readConfig = configfile: import (runCommand "config.nix" {} '' 7 10 echo "{" > "$out" 8 11 while IFS='=' read key val; do ··· 12 15 done < "${configfile}" 13 16 echo "}" >> $out 14 17 '').outPath; 15 - in { 16 - lib, 17 - # Allow overriding stdenv on each buildLinux call 18 - stdenv, 18 + in lib.makeOverridable ({ 19 19 # The kernel version 20 20 version, 21 21 # Position of the Linux build expression 22 22 pos ? null, 23 23 # Additional kernel make flags 24 24 extraMakeFlags ? [], 25 - # The version of the kernel module directory 26 - modDirVersion ? version, 25 + # The name of the kernel module directory 26 + # Needs to be X.Y.Z[-extra], so pad with zeros if needed. 27 + modDirVersion ? lib.versions.pad 3 version, 27 28 # The kernel source (tarball, git checkout, etc.) 28 29 src, 29 30 # a list of { name=..., patch=..., extraConfig=...} patches ··· 36 37 # Custom seed used for CONFIG_GCC_PLUGIN_RANDSTRUCT if enabled. This is 37 38 # automatically extended with extra per-version and per-config values. 38 39 randstructSeed ? "", 39 - # Use defaultMeta // extraMeta 40 + # Extra meta attributes 40 41 extraMeta ? {}, 41 42 42 43 # for module compatibility ··· 47 48 # Whether to utilize the controversial import-from-derivation feature to parse the config 48 49 allowImportFromDerivation ? false, 49 50 # ignored 50 - features ? null, 51 + features ? null, lib ? lib_, stdenv ? stdenv_, 51 52 }: 52 53 53 54 let ··· 386 387 ++ extraMakeFlags; 387 388 388 389 karch = stdenv.hostPlatform.linuxArch; 389 - } // (optionalAttrs (pos != null) { inherit pos; })) 390 + } // (optionalAttrs (pos != null) { inherit pos; })))
+1 -1
pkgs/os-specific/linux/kernel/xanmod-kernels.nix
··· 16 16 17 17 xanmodKernelFor = { version, suffix ? "xanmod1", hash, variant }: buildLinux (args // rec { 18 18 inherit version; 19 - modDirVersion = "${version}-${suffix}"; 19 + modDirVersion = lib.versions.pad 3 "${version}-${suffix}"; 20 20 21 21 src = fetchFromGitHub { 22 22 owner = "xanmod";
+1 -1
pkgs/os-specific/linux/kernel/zen-kernels.nix
··· 18 18 }; 19 19 zenKernelsFor = { version, suffix, sha256, isLqx }: buildLinux (args // { 20 20 inherit version; 21 - modDirVersion = "${lib.concatStringsSep "." (lib.take 3 (lib.splitVersion version ++ [ "0" "0" ]))}-${suffix}"; 21 + modDirVersion = lib.versions.pad 3 "${version}-${suffix}"; 22 22 isZen = true; 23 23 24 24 src = fetchFromGitHub {
+1 -1
pkgs/top-level/all-packages.nix
··· 25546 25546 linuxPackages_custom_tinyconfig_kernel = let 25547 25547 base = linuxPackages.kernel; 25548 25548 tinyLinuxPackages = linuxKernel.customPackage { 25549 - inherit (base) version src; 25549 + inherit (base) version modDirVersion src; 25550 25550 allowImportFromDerivation = false; 25551 25551 configfile = linuxConfig { 25552 25552 makeTarget = "tinyconfig";
+4 -4
pkgs/top-level/linux-kernels.nix
··· 40 40 }; 41 41 argsOverride = { 42 42 inherit version; 43 + modDirVersion = modDirVersion' + kernelPatches.hardened.${kernel.meta.branch}.extra; 43 44 src = fetchurl { 44 45 url = "mirror://kernel/linux/kernel/v${major}.x/linux-${version}.tar.xz"; 45 46 inherit sha256; ··· 48 49 kernelPatches = kernel.kernelPatches ++ [ 49 50 kernelPatches.hardened.${kernel.meta.branch} 50 51 ]; 51 - modDirVersionArg = modDirVersion' + (kernelPatches.hardened.${kernel.meta.branch}).extra; 52 52 isHardened = true; 53 53 }; 54 54 in { ··· 593 593 linux_hardkernel_latest = packages.hardkernel_4_14; 594 594 }; 595 595 596 - manualConfig = makeOverridable (callPackage ../os-specific/linux/kernel/manual-config.nix {}); 596 + manualConfig = callPackage ../os-specific/linux/kernel/manual-config.nix {}; 597 597 598 - customPackage = { version, src, configfile, allowImportFromDerivation ? true }: 598 + customPackage = { version, src, modDirVersion ? lib.versions.pad 3 version, configfile, allowImportFromDerivation ? true }: 599 599 recurseIntoAttrs (packagesFor (manualConfig { 600 - inherit version src configfile lib stdenv allowImportFromDerivation; 600 + inherit version src modDirVersion configfile allowImportFromDerivation; 601 601 })); 602 602 603 603 # Derive one of the default .config files