Created
March 28, 2025 11:21
-
-
Save caniko/ebc7054fa073e12b9a749daf63e75a77 to your computer and use it in GitHub Desktop.
asus-kernel.nix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs, lib, ... }: | |
{ | |
# ASUS G14 Patched Kernel based off of Arch Linux Kernel | |
# Source: https://github.com/Kamokuma5/nix_config/blob/main/nixos_config/nixos_modules/asus-kernel.nix | |
boot.kernelPackages = | |
let | |
linux_g14_pkg = | |
{ | |
fetchzip, | |
fetchgit, | |
buildLinux, | |
... | |
}@args: | |
let | |
# Get all patches from the asus-linux for Arch project | |
patch_dir = fetchgit { | |
fetchSubmodules = false; | |
url = "https://gitlab.com/dragonn/linux-g14.git/"; | |
rev = "83010b4bc2a12fe18ab3532b6eea60e90db18d91"; | |
hash = "sha256-ShKxLGb7tO97onL3AopNBMnN6Yoa0Eri2eHct0zS9y0="; | |
}; | |
## Get all top-level patch files from patch_dir | |
patchFiles = builtins.readDir patch_dir; | |
## Filter for only `.patch` files | |
unsortedPatchList = lib.mapAttrsToList ( | |
name: _: | |
builtins.trace "Found patch: ${name}" { | |
inherit name; | |
patch = "${patch_dir}/${name}"; | |
} | |
) (lib.filterAttrs (name: _type: lib.hasSuffix ".patch" name) patchFiles); | |
patchList = builtins.sort (a: b: a.name < b.name) unsortedPatchList; | |
in | |
buildLinux ( | |
args | |
// rec { | |
inherit patchList; | |
version = "6.13.8-arch1"; | |
# Get kernel source from arch GitHub repo | |
defconfig = "${patch_dir}/config"; | |
src = fetchzip { | |
url = "https://github.com/archlinux/linux/archive/refs/tags/v${version}.tar.gz"; | |
hash = "sha256-VzKdm8pHbeRk099IIddDlWNldAG8iYyF7K6lExmFRQE="; | |
}; | |
} | |
// (args.argsOverride or { }) | |
); | |
linux_g14 = pkgs.callPackage linux_g14_pkg { }; | |
in | |
pkgs.recurseIntoAttrs (pkgs.linuxPackagesFor linux_g14); | |
services = { | |
# supergfxd controls GPU switching | |
supergfxd.enable = true; | |
# ASUS specific software. This also installs asusctl. | |
asusd = { | |
enable = true; | |
enableUserService = true; | |
}; | |
# Dependency of asusd | |
power-profiles-daemon.enable = true; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment