diff --git a/pkgs/os-specific/linux/msi-ec/default.nix b/pkgs/os-specific/linux/msi-ec/default.nix new file mode 100644 index 000000000000000..85d84c4de426b3c --- /dev/null +++ b/pkgs/os-specific/linux/msi-ec/default.nix @@ -0,0 +1,52 @@ +{ + stdenv, + lib, + fetchFromGitHub, + linuxPackages, + kernel ? linuxPackages.kernel, + ... +}: +stdenv.mkDerivation rec { + pname = "msi-ec-kmods"; + version = "0.08"; + + src = fetchFromGitHub { + owner = "m1dugh"; + repo = "msi-ec"; + rev = "60aad95e2c8948140232f4c4d70f4ceba821d5a5"; + hash = "sha256-qgM4KeGoLvbVsii5YR3GTGi2MVlU+JeArzEoA+6A3a0="; + }; + + dontMakeSourcesWritable = false; + + patchPhase = '' + cp ${./patches/Makefile} ./Makefile + ''; + + hardeningDisable = [ + "pic" + ]; + + KERNELDIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"; + + makeFlags = kernel.makeFlags ++ [ + "KERNELDIR=${KERNELDIR}" + "INSTALL_MOD_PATH=$(out)" + ]; + + nativeBuildInputs = kernel.moduleBuildDependencies; + + buildFlags = [ "modules" ]; + installTargets = [ "modules_install" ]; + + enableParallelBuilding = true; + + meta = with lib; { + description = "Kernel modules for MSI Embedded controller"; + homepage = "https://github.com/m1dugh/msi-ec"; + license = licenses.gpl2; + maintainers = [ maintainers.m1dugh ]; + platforms = platforms.linux; + broken = kernel.kernelOlder "6.2"; + }; +} diff --git a/pkgs/os-specific/linux/msi-ec/patches/Makefile b/pkgs/os-specific/linux/msi-ec/patches/Makefile new file mode 100644 index 000000000000000..a783b770e373c41 --- /dev/null +++ b/pkgs/os-specific/linux/msi-ec/patches/Makefile @@ -0,0 +1,21 @@ +# 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/ +.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 diff --git a/pkgs/top-level/linux-kernels.nix b/pkgs/top-level/linux-kernels.nix index cbcee495efd8319..f105725864e9070 100644 --- a/pkgs/top-level/linux-kernels.nix +++ b/pkgs/top-level/linux-kernels.nix @@ -615,6 +615,8 @@ in { nullfs = callPackage ../os-specific/linux/nullfs { }; + msi-ec = callPackage ../os-specific/linux/msi-ec { }; + } // lib.optionalAttrs config.allowAliases { ati_drivers_x11 = throw "ati drivers are no longer supported by any kernel >=4.1"; # added 2021-05-18; hid-nintendo = throw "hid-nintendo was added in mainline kernel version 5.16"; # Added 2023-07-30