1
0
Fork 0

Move Lenovo Legion configs into nixos-hardware

This commit is contained in:
Aires 2024-04-06 20:42:50 -04:00
parent 1fde84a001
commit 12e98d14a4
5 changed files with 20 additions and 86 deletions

View file

@ -188,6 +188,22 @@
"type": "github"
}
},
"nixos-hardware-16arha7": {
"locked": {
"lastModified": 1712449958,
"narHash": "sha256-QDJaTsWRA42nidOWhS3hN3v9IiQW8SvEY2yPF9qbqzA=",
"owner": "8bitbuddhist",
"repo": "nixos-hardware",
"rev": "defa95f33bf4749ce8e3f60621ad3aeefa656229",
"type": "github"
},
"original": {
"owner": "8bitbuddhist",
"ref": "lenovo-legion-16ARHA7",
"repo": "nixos-hardware",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1682741954,
@ -273,6 +289,7 @@
"lanzaboote": "lanzaboote",
"nix-flatpak": "nix-flatpak",
"nixos-hardware": "nixos-hardware",
"nixos-hardware-16arha7": "nixos-hardware-16arha7",
"nixpkgs": "nixpkgs_2"
}
},

View file

@ -15,6 +15,7 @@
# Hardware configurations
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
nixos-hardware-16arha7.url = "github:8bitbuddhist/nixos-hardware/lenovo-legion-16ARHA7";
# Home-manager
home-manager = {
@ -25,7 +26,7 @@
# TODO: Add Disko - https://github.com/nix-community/disko
};
outputs = inputs@{ self, nixpkgs, lanzaboote, nix-flatpak, home-manager, nixos-hardware, ... }:
outputs = inputs@{ self, nixpkgs, lanzaboote, nix-flatpak, home-manager, nixos-hardware, nixos-hardware-16arha7, ... }:
let
inherit (self) outputs;
inherit (nixpkgs) lib;
@ -69,7 +70,6 @@
Haven = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = defaultModules.base ++ [
nixos-hardware.nixosModules.common-cpu-amd
nixos-hardware.nixosModules.common-cpu-amd-pstate
./hosts/Haven
];
@ -86,9 +86,7 @@
Shura = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = defaultModules.base ++ [
nixos-hardware.nixosModules.common-cpu-amd
nixos-hardware.nixosModules.common-cpu-amd-pstate
nixos-hardware.nixosModules.common-gpu-amd
nixos-hardware-16arha7.nixosModules.lenovo-legion-16arha7
./hosts/Shura
];
};

View file

@ -1,11 +1,5 @@
# Lenovo Legion S7 16ARHA7 configuration
{ config, lib, pkgs, modulesPath, ... }:
let
lenovo-speaker-fix-module = pkgs.callPackage ./patches/lenovo-16ARHA7_speaker-fix.nix {
# Make sure the module targets the same kernel as your system is using.
inherit (config.boot.kernelPackages) kernel;
};
in
{
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
@ -33,10 +27,6 @@ in
};
kernelModules = [ "kvm-amd" ];
# Add kernel patch to enable sound over the speakers.
# Patch sourced from https://github.com/christian-bendiksen/kernel-6.8.0-63.16ARHA7.fc40
extraModulePackages = [ lenovo-speaker-fix-module ];
};
fileSystems = {

View file

@ -1,38 +0,0 @@
# Patch sourced from https://github.com/christian-bendiksen/kernel-6.8.0-63.16ARHA7.fc40
{ pkgs, lib, kernel ? pkgs.linuxPackages_latest.kernel }:
pkgs.stdenv.mkDerivation {
pname = "lenovo-16ARHA7-speaker-fix-module";
inherit (kernel) src version postPatch nativeBuildInputs;
kernel_dev = kernel.dev;
kernelVersion = kernel.modDirVersion;
modulePath = "sound/pci/hda/";
buildPhase = ''
BUILT_KERNEL=$kernel_dev/lib/modules/$kernelVersion/build
cp $BUILT_KERNEL/Module.symvers .
cp $BUILT_KERNEL/.config .
cp $kernel_dev/vmlinux .
make "-j$NIX_BUILD_CORES" modules_prepare
make "-j$NIX_BUILD_CORES" M=$modulePath modules
'';
installPhase = ''
make \
INSTALL_MOD_PATH="$out" \
XZ="xz -T$NIX_BUILD_CORES" \
M="$modulePath" \
modules_install
'';
patches = [ ./lenovo_16ARHA7_sound_fix.patch ];
meta = {
description = "Patch to get the speakers working for Lenovo Legion Slim 7 Gen 7 AMD (16ARHA7)";
license = lib.licenses.gpl3;
};
}

View file

@ -1,33 +0,0 @@
diff -rupN linux-6.8-9791-ge5eb28f6d1af/sound/pci/hda/cs35l41_hda_property.c linux-6.8-9791-ge5eb28f6d1af-patched/sound/pci/hda/cs35l41_hda_property.c
--- linux-6.8-9791-ge5eb28f6d1af/sound/pci/hda/cs35l41_hda_property.c 2024-03-15 02:03:09.000000000 +0100
+++ linux-6.8-9791-ge5eb28f6d1af-patched/sound/pci/hda/cs35l41_hda_property.c 2024-03-17 12:23:48.183404375 +0100
@@ -115,6 +115,8 @@ static const struct cs35l41_config cs35l
{ "17AA38B5", 2, EXTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 0, 1, -1, 0, 0, 0 },
{ "17AA38B6", 2, EXTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 0, 1, -1, 0, 0, 0 },
{ "17AA38B7", 2, EXTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 0, 1, -1, 0, 0, 0 },
+ { "17AA3877", 2, EXTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 0, 1, -1, 0, 0, 0 },
+ { "17AA3878", 2, EXTERNAL, { CS35L41_LEFT, CS35L41_RIGHT, 0, 0 }, 0, 1, -1, 0, 0, 0 },
{}
};
@@ -503,6 +505,8 @@ static const struct cs35l41_prop_model c
{ "CSC3551", "17AA38B5", generic_dsd_config },
{ "CSC3551", "17AA38B6", generic_dsd_config },
{ "CSC3551", "17AA38B7", generic_dsd_config },
+ { "CSC3551", "17AA3877", generic_dsd_config },
+ { "CSC3551", "17AA3878", generic_dsd_config },
{}
};
diff -rupN linux-6.8-9791-ge5eb28f6d1af/sound/pci/hda/patch_realtek.c linux-6.8-9791-ge5eb28f6d1af-patched/sound/pci/hda/patch_realtek.c
--- linux-6.8-9791-ge5eb28f6d1af/sound/pci/hda/patch_realtek.c 2024-03-15 02:03:09.000000000 +0100
+++ linux-6.8-9791-ge5eb28f6d1af-patched/sound/pci/hda/patch_realtek.c 2024-03-17 12:18:22.241570472 +0100
@@ -10263,6 +10263,8 @@ static const struct snd_pci_quirk alc269
SND_PCI_QUIRK(0x17aa, 0x38b5, "Legion Slim 7 16IRH8", ALC287_FIXUP_CS35L41_I2C_2),
SND_PCI_QUIRK(0x17aa, 0x38b6, "Legion Slim 7 16APH8", ALC287_FIXUP_CS35L41_I2C_2),
SND_PCI_QUIRK(0x17aa, 0x38b7, "Legion Slim 7 16APH8", ALC287_FIXUP_CS35L41_I2C_2),
+ SND_PCI_QUIRK(0x17aa, 0x3877, "Legion S7 16ARHA7", ALC287_FIXUP_CS35L41_I2C_2),
+ SND_PCI_QUIRK(0x17aa, 0x3878, "Legion S7 16ARHA7", ALC287_FIXUP_CS35L41_I2C_2),
SND_PCI_QUIRK(0x17aa, 0x38ba, "Yoga S780-14.5 Air AMD quad YC", ALC287_FIXUP_TAS2781_I2C),
SND_PCI_QUIRK(0x17aa, 0x38bb, "Yoga S780-14.5 Air AMD quad AAC", ALC287_FIXUP_TAS2781_I2C),
SND_PCI_QUIRK(0x17aa, 0x38be, "Yoga S980-14.5 proX YC Dual", ALC287_FIXUP_TAS2781_I2C),