modules.system.kernel: fix kernel build failed

This commit is contained in:
2025-09-16 17:50:39 +08:00
parent 136583cf51
commit 6c6a234a26
2 changed files with 30 additions and 20 deletions

View File

@@ -68,15 +68,19 @@ inputs:
{
hibernate-progress = [{ name = "hibernate-progress"; patch = ./hibernate-progress.patch; }];
btrfs =
[{
name = "btrfs";
patch = inputs.pkgs.fetchurl
{
url = "https://github.com/kakra/linux/pull/36.patch";
sha256 = "0wimihsvrxib6g23jcqdbvqlkqk6nbqjswfx9bzmpm1vlvzxj8m0";
};
structuredExtraConfig.BTRFS_EXPERIMENTAL = inputs.lib.kernel.yes;
}];
let configName =
if inputs.config.nixos.system.kernel.variant == "xanmod-unstable" then "structuredExtraConfig"
else "extraStructuredConfig";
in
[{
name = "btrfs";
patch = inputs.pkgs.fetchurl
{
url = "https://github.com/kakra/linux/pull/36.patch";
sha256 = "0wimihsvrxib6g23jcqdbvqlkqk6nbqjswfx9bzmpm1vlvzxj8m0";
};
${configName}.BTRFS_EXPERIMENTAL = inputs.lib.kernel.yes;
}];
};
in builtins.concatLists (builtins.map (name: patches.${name}) kernel.patches);
};

View File

@@ -21,16 +21,22 @@ inputs:
nixpkgs = nixpkgs // { nixRoot = null; nixos = true; inherit (inputs.config.nixos.model) arch; };
};
boot.kernelPatches = inputs.lib.mkIf (nixpkgs.march != null)
[{
name = "native kernel";
patch = null;
structuredExtraConfig =
let kernelConfig = { znver2 = "MZEN2"; znver3 = "MZEN3"; znver4 = "MZEN4"; znver5 = "MZEN5"; };
in
{
GENERIC_CPU = inputs.lib.kernel.no;
${kernelConfig.${nixpkgs.march} or "M${inputs.lib.toUpper nixpkgs.march}"} = inputs.lib.kernel.yes;
};
}];
(
let configName =
if inputs.config.nixos.system.kernel.variant == "xanmod-unstable" then "structuredExtraConfig"
else "extraStructuredConfig";
in
[{
name = "native kernel";
patch = null;
${configName} =
let kernelConfig = { znver2 = "MZEN2"; znver3 = "MZEN3"; znver4 = "MZEN4"; znver5 = "MZEN5"; };
in
{
GENERIC_CPU = inputs.lib.kernel.no;
${kernelConfig.${nixpkgs.march} or "M${inputs.lib.toUpper nixpkgs.march}"} = inputs.lib.kernel.yes;
};
}]
);
};
}