1
0
Fork 0
mirror of https://github.com/NixOS/nixos-hardware synced 2024-12-18 15:49:45 +01:00
nixos-hardware/microsoft/surface/common/kernel/linux-package.nix

56 lines
1.5 KiB
Nix
Raw Normal View History

2023-11-26 00:42:11 +01:00
{ pkgs,
lib,
fetchurl,
buildLinux,
linuxPackagesFor,
}:
let
inherit (builtins) elem;
inherit (lib) recurseIntoAttrs types versions;
2023-11-26 00:42:11 +01:00
repos = pkgs.callPackage ../repos.nix {};
linuxPackage =
2023-11-26 00:42:11 +01: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-26 01:01:52 +01:00
{ patchSrc ? (repos.linux-surface + "/patches/${versions.majorMinor version}"),
2023-11-26 00:42:11 +01:00
version,
patchFn,
}: pkgs.callPackage patchFn {
inherit (lib) kernel;
inherit version patchSrc;
};
versionsOf = version:
# Provides a list of versions that can be used as an enum option for this full version:
[ version (versions.majorMinor version) ];
versionsOfEnum = version:
# 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:
2024-07-25 03:47:52 +02:00
elem kernelVersion (versionsOf version);
2023-11-26 00:42:11 +01:00
in {
inherit linuxPackage repos surfacePatches versionsOf isVersionOf versionsOfEnum;
}