refactor(nxp): parameterize i.MX platform builders to reduce duplication

This refactoring reduces code duplication across i.MX93, i.MX8MP, and
i.MX8MQ platforms by extracting common build logic into parameterized
shared builders. This makes it easier to maintain and add new i.MX
platforms while ensuring consistency across all platforms.
This commit is contained in:
Jörg Thalheim
2025-10-29 16:03:39 +01:00
parent 8b405e9c6d
commit 688ee555de
14 changed files with 398 additions and 598 deletions

View File

@@ -0,0 +1,56 @@
# Parameterized Linux kernel builder for i.MX platforms
# This builder is used across i.MX93, i.MX8MP, i.MX8MQ and similar platforms
{ lib, pkgs, ... }@args:
let
inherit (pkgs) buildLinux;
# Import common kernel configuration
kernelConfig = import ../lib/kernel-config.nix;
in
# Platform-specific parameters
{
pname,
version,
src,
defconfig ? "imx_v8_defconfig",
# Optional parameters
extraConfig ? "",
kernelPatches ? [ ],
autoModules ? false,
ignoreConfigErrors ? true,
extraMeta ? { },
}:
let
# Combine common i.MX kernel config with platform-specific config
finalExtraConfig = kernelConfig.imxCommonKernelConfig + extraConfig;
in
buildLinux (
args
// rec {
inherit
version
defconfig
kernelPatches
autoModules
ignoreConfigErrors
;
name = pname;
# modDirVersion needs to be x.y.z, will automatically add .0 if needed
modDirVersion = version;
extraConfig = finalExtraConfig;
inherit src;
meta =
with lib;
{
homepage = "https://github.com/nxp-imx/linux-imx";
license = [ licenses.gpl2Only ];
platforms = [ "aarch64-linux" ];
}
// extraMeta;
}
// (args.argsOverride or { })
)