msi-ec: 0-unstable-2024-09-19 -> 0-unstable-2024-11-04

This commit is contained in:
m1dugh 2024-11-04 11:40:34 +01:00
parent 7c7453a8dd
commit dd086ca402
3 changed files with 33 additions and 40 deletions

View File

@ -8,26 +8,18 @@
}: }:
stdenv.mkDerivation { stdenv.mkDerivation {
pname = "msi-ec-kmods"; pname = "msi-ec-kmods";
version = "0-unstable-2024-09-19"; version = "0-unstable-2024-11-04";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "BeardOverflow"; owner = "BeardOverflow";
repo = "msi-ec"; repo = "msi-ec";
rev = "94c2a45c04a07096e10d7cb1240e1a201a025dc0"; rev = "be6f7156cd15f6ecf9d48dfcc30cbd1f693916b8";
hash = "sha256-amJUoIf5Sl62BLyHLeam2fzN1s+APoWh2dH5QVfJhCs="; hash = "sha256-gImiP4OaBt80n+qgVnbhd0aS/zW+05o3DzGCw0jq+0g=";
}; };
dontMakeSourcesWritable = false; dontMakeSourcesWritable = false;
postPatch = patches = [ ./patches/makefile.patch ];
let
targets = builtins.filter (v: v != "") [
(lib.strings.optionalString (kernel.kernelOlder "6.2") "older-kernel-patch")
(lib.strings.optionalString (kernel.kernelAtLeast "6.11") "6.11-kernel-patch")
];
commands = builtins.map (target: "make ${target}") targets;
in
lib.concatStringsSep "\n" ([ "cp ${./patches/Makefile} ./Makefile" ] ++ commands);
hardeningDisable = [ "pic" ]; hardeningDisable = [ "pic" ];
@ -48,6 +40,6 @@ stdenv.mkDerivation {
license = lib.licenses.gpl2Plus; license = lib.licenses.gpl2Plus;
maintainers = [ lib.maintainers.m1dugh ]; maintainers = [ lib.maintainers.m1dugh ];
platforms = lib.platforms.linux; platforms = lib.platforms.linux;
broken = kernel.kernelOlder "6.2"; broken = kernel.kernelOlder "5.5";
}; };
} }

View File

@ -1,27 +0,0 @@
# Out of the box, the build with this Makefile only works in FHS environments,
# such as on Ubuntu or Debian. On NixOS, you either need to open an FHS
# environment using a Nix shell or build this from a specially crafted Nix
# derivation.
#
# This file follows the conventions written down here:
# https://docs.kernel.org/kbuild/modules.html
# Make it possible to override the kernel src tree location from Nix derivation.
KERNEL ?= $(shell uname -r)
KERNELDIR ?= /lib/modules/$(KERNEL)/build/
ccflags-y := -std=gnu11 -Wno-declaration-after-statement
.PHONY: default
default: modules
# -m: Build as module.
obj-m = msi-ec.o
.PHONY: modules
modules:
@#"M=": Module source. Special variable of the kernel's main Makefile.
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
.PHONY: modules_install
modules_install:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
6.11-kernel-patch:
git apply 6.11-kernel.patch
older-kernel-patch:
git apply older-kernel.patch

View File

@ -0,0 +1,28 @@
diff --git a/Makefile b/Makefile
index bffcbd4..fd1d8a3 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
VERSION := 0.08
DKMS_ROOT_PATH := /usr/src/msi_ec-$(VERSION)
TARGET ?= $(shell uname -r)
+KERNELDIR ?= /lib/modules/$(TARGET)/build/
ccflags-y := -std=gnu11 -Wno-declaration-after-statement
@@ -10,11 +11,14 @@ obj-m += msi-ec.o
all: modules
modules:
- @$(MAKE) -C /lib/modules/$(TARGET)/build M=$(CURDIR) modules
+ @$(MAKE) -C $(KERNELDIR) M=$(CURDIR) modules
clean:
@$(MAKE) -C /lib/modules/$(TARGET)/build M=$(CURDIR) clean
+modules_install:
+ @$(MAKE) -C $(KERNELDIR) M=$(CURDIR) modules_install
+
load:
insmod msi-ec.ko