From 158f86bb326dd3529f288bb476464f61679a41c3 Mon Sep 17 00:00:00 2001 From: mexisme Date: Mon, 28 Nov 2022 20:23:51 +1300 Subject: [PATCH] DRY the MS Surface kernel module --- microsoft/surface/kernel/default.nix | 38 +++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/microsoft/surface/kernel/default.nix b/microsoft/surface/kernel/default.nix index 354fe90..1a1ca6b 100644 --- a/microsoft/surface/kernel/default.nix +++ b/microsoft/surface/kernel/default.nix @@ -1,5 +1,37 @@ -{ config, lib, pkgs, ... }: +{ lib, + buildLinux, + callPackage, + linuxPackagesFor, + ... +}: -{ - boot.kernelPackages = pkgs.callPackage ./linux-5.16.11.nix { }; +# To test the kernel build: +# nix-build -E "with import {}; (pkgs.callPackage ./. {}).kernel" + +let + inherit (lib) kernel recurseIntoAttrs; + repos = callPackage ../repos.nix {}; + + linuxPackage = + { version, + modDirVersion ? version, + branch, + src, + kernelPatches ? [], + ... + }: let + buildLinux' = buildLinux { + inherit version src kernelPatches; + modDirVersion = version; + extraMeta.branch = branch; + }; + linuxPackagesFor' = (linuxPackagesFor buildLinux'); + in recurseIntoAttrs linuxPackagesFor'; + + linux-5_16_11 = linuxPackage ( + callPackage ./linux-5.16.11.nix { inherit repos; } + ); + +in { + boot.kernelPackages = linux-5_16_11; }