mirror of
https://github.com/NixOS/nixos-hardware.git
synced 2025-11-07 02:18:47 +08:00
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:
56
nxp/common/bsp/imx-linux-builder.nix
Normal file
56
nxp/common/bsp/imx-linux-builder.nix
Normal 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 { })
|
||||
)
|
||||
Reference in New Issue
Block a user