2023-11-25 18:42:11 -05:00
|
|
|
{ pkgs,
|
|
|
|
lib,
|
|
|
|
fetchurl,
|
2022-12-04 23:32:25 -05:00
|
|
|
buildLinux,
|
|
|
|
linuxPackagesFor,
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2024-01-31 03:31:15 -05:00
|
|
|
inherit (builtins) elem;
|
|
|
|
inherit (lib) recurseIntoAttrs types versions;
|
|
|
|
|
2023-11-25 18:42:11 -05:00
|
|
|
repos = pkgs.callPackage ../repos.nix {};
|
2022-12-04 23:32:25 -05:00
|
|
|
|
2024-01-30 18:00:03 -05:00
|
|
|
linuxPackage =
|
2023-11-25 18:42:11 -05:00
|
|
|
{ url ? "mirror://kernel/linux/kernel/v${versions.major version}.x/linux-${version}.tar.xz",
|
|
|
|
sha256 ? null,
|
|
|
|
src ? (fetchurl { inherit url sha256; }),
|
|
|
|
version,
|
|
|
|
modDirVersion ? (versions.pad 3 version),
|
|
|
|
kernelPatches ? [],
|
|
|
|
...
|
|
|
|
} @ args: let
|
|
|
|
inherit (builtins) removeAttrs;
|
|
|
|
|
|
|
|
args' = {
|
|
|
|
inherit src version modDirVersion kernelPatches;
|
|
|
|
} // removeAttrs args [ "url" "sha256" ];
|
|
|
|
linuxPackage = buildLinux args';
|
|
|
|
linuxPackages' = recurseIntoAttrs (linuxPackagesFor linuxPackage);
|
|
|
|
in linuxPackages';
|
|
|
|
|
|
|
|
surfacePatches =
|
2023-11-25 19:01:52 -05:00
|
|
|
{ patchSrc ? (repos.linux-surface + "/patches/${versions.majorMinor version}"),
|
2023-11-25 18:42:11 -05:00
|
|
|
version,
|
|
|
|
patchFn,
|
|
|
|
}: pkgs.callPackage patchFn {
|
|
|
|
inherit (lib) kernel;
|
|
|
|
inherit version patchSrc;
|
|
|
|
};
|
|
|
|
|
2024-01-31 03:31:15 -05:00
|
|
|
versionsOf = version:
|
|
|
|
# Provides a list of versions that can be used as an enum option for this full version:
|
|
|
|
[ version (versions.majorMinor version) ];
|
|
|
|
|
2024-01-31 03:36:14 -05:00
|
|
|
versionsOfEnum = version:
|
2024-01-31 03:31:15 -05:00
|
|
|
# Provide an enum option for versions of this kernel:
|
|
|
|
types.enum (versionsOf version);
|
|
|
|
|
|
|
|
isVersionOf = kernelVersion: version:
|
|
|
|
# Test if the provided version is considered one of the list of versions from above:
|
|
|
|
elem version (versionsOf version);
|
|
|
|
|
2023-11-25 18:42:11 -05:00
|
|
|
in {
|
2024-01-31 03:36:14 -05:00
|
|
|
inherit linuxPackage repos surfacePatches versionsOf isVersionOf versionsOfEnum;
|
2022-12-04 23:32:25 -05:00
|
|
|
}
|