linux: use lib.versions.pad for modDirVersion

This commit is contained in:
Naïm Favier 2022-12-21 12:49:37 +01:00
parent 0355479715
commit fc346c5e62
No known key found for this signature in database
GPG Key ID: 95AFCE8211908325
15 changed files with 32 additions and 23 deletions

View File

@ -29,7 +29,8 @@
structuredExtraConfig ? {}
, # 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
# certain features in this kernel. E.g. `{iwlwifi = true;}'
@ -195,15 +196,15 @@ let
}; # end of configfile derivation
kernel = (callPackage ./manual-config.nix { inherit buildPackages; }) (basicArgs // {
inherit modDirVersion kernelPatches randstructSeed lib stdenv extraMakeFlags extraMeta configfile;
inherit kernelPatches randstructSeed lib stdenv extraMakeFlags extraMeta configfile;
pos = builtins.unsafeGetAttrPos "version" args;
config = { CONFIG_MODULES = "y"; CONFIG_FW_LOADER = "m"; };
});
} // lib.optionalAttrs (modDirVersion != null) { inherit modDirVersion; });
passthru = basicArgs // {
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;
passthru = kernel.passthru // (removeAttrs passthru [ "passthru" ]);
tests = let

View File

@ -6,7 +6,7 @@ buildLinux (args // rec {
version = "4.14.302";
# 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
extraMeta.branch = versions.majorMinor version;
@ -16,3 +16,4 @@ buildLinux (args // rec {
sha256 = "102c9h0byr9v4bxzkdh7mnw1grm47ji6lf6l1gjlwah7f46j6ap3";
};
} // (args.argsOverride or {}))
// lib.optionalAttrs (modDirVersionArg != null) { modDirVersion = modDirVersionArg; } # legacy

View File

@ -6,7 +6,7 @@ buildLinux (args // rec {
version = "4.19.269";
# 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
extraMeta.branch = versions.majorMinor version;
@ -16,3 +16,4 @@ buildLinux (args // rec {
sha256 = "02mjb16xxfj984vibpxvhjl84y5yg0jgzjccjdxnn8db4k9aa2vf";
};
} // (args.argsOverride or {}))
// lib.optionalAttrs (modDirVersionArg != null) { modDirVersion = modDirVersionArg; } # legacy

View File

@ -6,7 +6,7 @@ buildLinux (args // rec {
version = "5.10.159";
# 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
extraMeta.branch = versions.majorMinor version;
@ -16,3 +16,4 @@ buildLinux (args // rec {
sha256 = "19yfi5vknxnw0cb8274q3pb5zjs6ny04n16m8xjdfdmznrbvza8v";
};
} // (args.argsOverride or {}))
// lib.optionalAttrs (modDirVersionArg != null) { modDirVersion = modDirVersionArg; } # legacy

View File

@ -6,7 +6,7 @@ buildLinux (args // rec {
version = "5.15.83";
# 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
extraMeta.branch = versions.majorMinor version;
@ -16,3 +16,4 @@ buildLinux (args // rec {
sha256 = "1wvzfhzqq9dps508wmp2gblfz93ipppnjzqm0n8pi1acq11hhna0";
};
} // (args.argsOverride or { }))
// lib.optionalAttrs (modDirVersionArg != null) { modDirVersion = modDirVersionArg; } # legacy

View File

@ -6,7 +6,7 @@ buildLinux (args // rec {
version = "5.4.227";
# 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
extraMeta.branch = versions.majorMinor version;
@ -16,3 +16,4 @@ buildLinux (args // rec {
sha256 = "14q5gy48j78vwnqivrgpdhj778n2jq5l7yiw5na1rwqmfh1wbvsy";
};
} // (args.argsOverride or {}))
// lib.optionalAttrs (modDirVersionArg != null) { modDirVersion = modDirVersionArg; } # legacy

View File

@ -6,7 +6,7 @@ buildLinux (args // rec {
version = "6.0.13";
# 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
extraMeta.branch = versions.majorMinor version;
@ -16,3 +16,4 @@ buildLinux (args // rec {
sha256 = "191dlxcmbx8vy6z2k04jq2kr6hwnaknsnsyycvqnjmvmdf6i3lq8";
};
} // (args.argsOverride or { }))
// lib.optionalAttrs (modDirVersionArg != null) { modDirVersion = modDirVersionArg; } # legacy

View File

@ -6,7 +6,7 @@ buildLinux (args // rec {
version = "6.1";
# 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
extraMeta.branch = versions.majorMinor version;
@ -16,3 +16,4 @@ buildLinux (args // rec {
sha256 = "sha256-LKHxcFGkMPb+0RluSVJxdQcXGs/ZfZZXchJQJwOyXes=";
};
} // (args.argsOverride or { }))
// lib.optionalAttrs (modDirVersionArg != null) { modDirVersion = modDirVersionArg; } # legacy

View File

@ -13,8 +13,7 @@ in buildLinux (args // {
inherit version;
# modDirVersion needs a patch number, change X.Y-rtZ to X.Y.0-rtZ.
modDirVersion = if (builtins.match "[^.]*[.][^.]*-.*" version) == null then version
else lib.replaceStrings ["-"] [".0-"] version;
modDirVersion = lib.versions.pad 3 version;
src = fetchurl {
url = "mirror://kernel/linux/kernel/v5.x/linux-${kversion}.tar.xz";

View File

@ -7,7 +7,7 @@ buildLinux (args // rec {
extraMeta.branch = lib.versions.majorMinor version;
# 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 {
url = "https://git.kernel.org/torvalds/t/linux-${version}.tar.gz";
@ -18,3 +18,4 @@ buildLinux (args // rec {
extraMeta.hydraPlatforms = [];
} // (args.argsOverride or {}))
// lib.optionalAttrs (modDirVersionArg != null) { modDirVersion = modDirVersionArg; } # legacy

View File

@ -22,8 +22,9 @@ in {
pos ? null,
# Additional kernel make flags
extraMakeFlags ? [],
# The version of the kernel module directory
modDirVersion ? version,
# The name of the kernel module directory
# 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.)
src,
# a list of { name=..., patch=..., extraConfig=...} patches
@ -36,7 +37,7 @@ in {
# Custom seed used for CONFIG_GCC_PLUGIN_RANDSTRUCT if enabled. This is
# automatically extended with extra per-version and per-config values.
randstructSeed ? "",
# Use defaultMeta // extraMeta
# Extra meta attributes
extraMeta ? {},
# for module compatibility

View File

@ -16,7 +16,7 @@ let
xanmodKernelFor = { version, suffix ? "xanmod1", hash, variant }: buildLinux (args // rec {
inherit version;
modDirVersion = "${version}-${suffix}";
modDirVersion = lib.versions.pad 3 "${version}-${suffix}";
src = fetchFromGitHub {
owner = "xanmod";

View File

@ -18,7 +18,7 @@ let
};
zenKernelsFor = { version, suffix, sha256, isLqx }: buildLinux (args // {
inherit version;
modDirVersion = "${lib.concatStringsSep "." (lib.take 3 (lib.splitVersion version ++ [ "0" "0" ]))}-${suffix}";
modDirVersion = lib.versions.pad 3 "${version}-${suffix}";
isZen = true;
src = fetchFromGitHub {

View File

@ -25470,7 +25470,7 @@ with pkgs;
linuxPackages_custom_tinyconfig_kernel = let
base = linuxPackages.kernel;
tinyLinuxPackages = linuxKernel.customPackage {
inherit (base) version src;
inherit (base) version modDirVersion src;
allowImportFromDerivation = false;
configfile = linuxConfig {
makeTarget = "tinyconfig";

View File

@ -40,6 +40,7 @@ let
};
argsOverride = {
inherit version;
modDirVersion = modDirVersion' + kernelPatches.hardened.${kernel.meta.branch}.extra;
src = fetchurl {
url = "mirror://kernel/linux/kernel/v${major}.x/linux-${version}.tar.xz";
inherit sha256;
@ -48,7 +49,6 @@ let
kernelPatches = kernel.kernelPatches ++ [
kernelPatches.hardened.${kernel.meta.branch}
];
modDirVersionArg = modDirVersion' + (kernelPatches.hardened.${kernel.meta.branch}).extra;
isHardened = true;
};
in {
@ -595,9 +595,9 @@ in {
manualConfig = makeOverridable (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 {
inherit version src configfile lib stdenv allowImportFromDerivation;
inherit version src modDirVersion configfile lib stdenv allowImportFromDerivation;
}));
# Derive one of the default .config files