diff --git a/flake.lock b/flake.lock index 1d6dd84e..e2d670bd 100644 --- a/flake.lock +++ b/flake.lock @@ -437,26 +437,6 @@ "type": "github" } }, - "nixhw": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1727291538, - "narHash": "sha256-80ll70/S/rENWSp63jxpPnENSlM3BcO6vh/1DjjPIrs=", - "owner": "alyraffauf", - "repo": "nixhw", - "rev": "193e927e1d6b9f567ac9beb04fe7ca16e45a4edb", - "type": "github" - }, - "original": { - "owner": "alyraffauf", - "repo": "nixhw", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1727264057, @@ -554,7 +534,6 @@ "home-manager": "home-manager_2", "iio-hyprland": "iio-hyprland", "lanzaboote": "lanzaboote", - "nixhw": "nixhw", "nixpkgs": "nixpkgs", "nixpkgs-unstable": "nixpkgs-unstable", "nur": "nur", diff --git a/flake.nix b/flake.nix index feef103c..07926002 100644 --- a/flake.nix +++ b/flake.nix @@ -30,11 +30,6 @@ url = "github:nix-community/lanzaboote/v0.4.1"; }; - nixhw = { - inputs.nixpkgs.follows = "nixpkgs"; - url = "github:alyraffauf/nixhw"; - }; - nur.url = "github:nix-community/NUR"; stylix = { @@ -137,6 +132,21 @@ }; nixosModules = { + hw-framework-13-amd-7000 = import ./hwModules/framework/13/amd-7000; + hw-framework-13-intel-11th = import ./hwModules/framework/13/intel-11th; + hw-lenovo-yoga-9i-intel-13th = import ./hwModules/lenovo/yoga-9i/intel-13th; + hw-thinkpad-t440p = import ./hwModules/thinkpad/t440p; + + hw-common-amd-cpu = import ./hwModules/common/gpu/amd; + hw-common-amd-gpu = import ./hwModules/common/cpu/amd; + hw-common-bluetooth = import ./hwModules/common/bluetooth; + hw-common-intel-cpu = import ./hwModules/common/cpu/intel; + hw-common-intel-gpu = import ./hwModules/common/gpu/intel; + hw-common-laptop = import ./hwModules/common/laptop; + hw-common-laptop-amd-gpu = import ./hwModules/common/laptop/amd-gpu.nix; + hw-common-laptop-intel-cpu = import ./hwModules/common/laptop/intel-cpu.nix; + hw-common-ssd = import ./hwModules/common/ssd; + common-auto-upgrade = import ./common/autoUpgrade.nix; common-base = import ./common/base.nix; common-locale = import ./common/locale.nix; diff --git a/hosts/fallarbor/default.nix b/hosts/fallarbor/default.nix index b7e3c2db..fcc3374b 100644 --- a/hosts/fallarbor/default.nix +++ b/hosts/fallarbor/default.nix @@ -10,7 +10,6 @@ ./home.nix ./secrets.nix ./stylix.nix - self.inputs.nixhw.nixosModules.framework-13-intel-11th self.nixosModules.common-base self.nixosModules.common-locale self.nixosModules.common-mauville-share @@ -18,6 +17,7 @@ self.nixosModules.common-overlays self.nixosModules.common-pkgs self.nixosModules.common-wifi-profiles + self.nixosModules.hw-framework-13-intel-11th ]; boot.loader = { diff --git a/hosts/lavaridge/default.nix b/hosts/lavaridge/default.nix index 78349f6e..e0d9fd1c 100644 --- a/hosts/lavaridge/default.nix +++ b/hosts/lavaridge/default.nix @@ -10,7 +10,6 @@ ./secrets.nix ./stylix.nix (import ./../../disko/luks-btrfs-subvolumes.nix {disks = ["/dev/nvme0n1"];}) - self.inputs.nixhw.nixosModules.framework-13-amd-7000 self.nixosModules.common-auto-upgrade self.nixosModules.common-base self.nixosModules.common-locale @@ -20,6 +19,7 @@ self.nixosModules.common-pkgs self.nixosModules.common-tailscale self.nixosModules.common-wifi-profiles + self.nixosModules.hw-framework-13-amd-7000 ]; boot = { diff --git a/hosts/mauville/default.nix b/hosts/mauville/default.nix index cf18d487..00b73df5 100644 --- a/hosts/mauville/default.nix +++ b/hosts/mauville/default.nix @@ -14,10 +14,6 @@ in { ./raffauflabs.nix ./secrets.nix ./stylix.nix - self.inputs.nixhw.nixosModules.common-amd-cpu - self.inputs.nixhw.nixosModules.common-amd-gpu - self.inputs.nixhw.nixosModules.common-bluetooth - self.inputs.nixhw.nixosModules.common-ssd self.nixosModules.common-auto-upgrade self.nixosModules.common-base self.nixosModules.common-locale @@ -26,6 +22,10 @@ in { self.nixosModules.common-pkgs self.nixosModules.common-tailscale self.nixosModules.common-wifi-profiles + self.nixosModules.hw-common-amd-cpu + self.nixosModules.hw-common-amd-gpu + self.nixosModules.hw-common-bluetooth + self.nixosModules.hw-common-ssd ]; boot = { diff --git a/hosts/petalburg/default.nix b/hosts/petalburg/default.nix index 2f7c38b9..5306986c 100644 --- a/hosts/petalburg/default.nix +++ b/hosts/petalburg/default.nix @@ -10,7 +10,6 @@ ./secrets.nix ./stylix.nix (import ./../../disko/luks-btrfs-subvolumes.nix {disks = ["/dev/nvme0n1"];}) - self.inputs.nixhw.nixosModules.lenovo-yoga-9i-intel-13th self.nixosModules.common-auto-upgrade self.nixosModules.common-base self.nixosModules.common-locale @@ -20,6 +19,7 @@ self.nixosModules.common-pkgs self.nixosModules.common-tailscale self.nixosModules.common-wifi-profiles + self.nixosModules.hw-lenovo-yoga-9i-intel-13th ]; boot = { diff --git a/hosts/rustboro/default.nix b/hosts/rustboro/default.nix index 01f9ff26..b8a63984 100644 --- a/hosts/rustboro/default.nix +++ b/hosts/rustboro/default.nix @@ -10,7 +10,6 @@ ./secrets.nix ./stylix.nix (import ./../../disko/luks-btrfs-subvolumes.nix {disks = ["/dev/sda"];}) - self.inputs.nixhw.nixosModules.thinkpad-t440p self.nixosModules.common-auto-upgrade self.nixosModules.common-base self.nixosModules.common-locale @@ -20,6 +19,7 @@ self.nixosModules.common-pkgs self.nixosModules.common-tailscale self.nixosModules.common-wifi-profiles + self.nixosModules.hw-thinkpad-t440p ]; boot = { diff --git a/hosts/slateport/default.nix b/hosts/slateport/default.nix index 403be865..7117f4a0 100644 --- a/hosts/slateport/default.nix +++ b/hosts/slateport/default.nix @@ -8,10 +8,6 @@ ./raffauflabs.nix ./secrets.nix (import ./../../disko/btrfs-subvolumes.nix {disks = ["/dev/sda"];}) - self.inputs.nixhw.nixosModules.common-bluetooth - self.inputs.nixhw.nixosModules.common-intel-cpu - self.inputs.nixhw.nixosModules.common-intel-gpu - self.inputs.nixhw.nixosModules.common-ssd self.nixosModules.common-auto-upgrade self.nixosModules.common-base self.nixosModules.common-locale @@ -21,6 +17,10 @@ self.nixosModules.common-pkgs self.nixosModules.common-tailscale self.nixosModules.common-wifi-profiles + self.nixosModules.hw-common-bluetooth + self.nixosModules.hw-common-intel-cpu + self.nixosModules.hw-common-intel-gpu + self.nixosModules.hw-common-ssd ]; boot = { diff --git a/hwModules/common/bluetooth/default.nix b/hwModules/common/bluetooth/default.nix new file mode 100644 index 00000000..9b88bee7 --- /dev/null +++ b/hwModules/common/bluetooth/default.nix @@ -0,0 +1,22 @@ +{ + lib, + pkgs, + ... +}: { + hardware = { + bluetooth.enable = true; + + pulseaudio = { + enable = lib.mkForce false; + package = pkgs.pulseaudioFull; # Use extra Bluetooth codecs like aptX + + extraConfig = '' + load-module module-bluetooth-discover + load-module module-bluetooth-policy + load-module module-switch-on-connect + ''; + + support32Bit = true; + }; + }; +} diff --git a/hwModules/common/cpu/amd/default.nix b/hwModules/common/cpu/amd/default.nix new file mode 100644 index 00000000..ea8f5069 --- /dev/null +++ b/hwModules/common/cpu/amd/default.nix @@ -0,0 +1,9 @@ +{lib, ...}: { + boot = { + kernelModules = ["kvm-amd"]; + kernelParams = ["amd_pstate=active"]; + }; + + hardware.cpu.amd.updateMicrocode = true; + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; +} diff --git a/hwModules/common/cpu/intel/default.nix b/hwModules/common/cpu/intel/default.nix new file mode 100644 index 00000000..cadcf602 --- /dev/null +++ b/hwModules/common/cpu/intel/default.nix @@ -0,0 +1,5 @@ +{lib, ...}: { + boot.kernelModules = ["kvm-intel"]; + hardware.cpu.intel.updateMicrocode = true; + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; +} diff --git a/hwModules/common/gpu/amd/default.nix b/hwModules/common/gpu/amd/default.nix new file mode 100644 index 00000000..a3d3cc3f --- /dev/null +++ b/hwModules/common/gpu/amd/default.nix @@ -0,0 +1,14 @@ +{...}: { + environment.variables.VDPAU_DRIVER = "radeonsi"; + + hardware.amdgpu = { + initrd.enable = true; + + amdvlk = { + enable = true; + support32Bit.enable = true; + }; + + opencl.enable = true; + }; +} diff --git a/hwModules/common/gpu/intel/default.nix b/hwModules/common/gpu/intel/default.nix new file mode 100644 index 00000000..bab35eaa --- /dev/null +++ b/hwModules/common/gpu/intel/default.nix @@ -0,0 +1,32 @@ +{pkgs, ...}: { + boot.initrd.kernelModules = ["i915"]; + + environment.sessionVariables = { + LIBVA_DRIVER_NAME = "iHD"; + VDPAU_DRIVER = "va_gl"; + }; + + hardware = { + intel-gpu-tools.enable = true; + + opengl = { + enable = true; + driSupport = true; + driSupport32Bit = true; + + extraPackages = with pkgs; [ + intel-media-driver # LIBVA_DRIVER_NAME=iHD + (intel-vaapi-driver.override {enableHybridCodec = true;}) + libvdpau-va-gl + ]; + + extraPackages32 = with pkgs.driversi686Linux; [ + intel-media-driver # LIBVA_DRIVER_NAME=iHD + (intel-vaapi-driver.override {enableHybridCodec = true;}) + libvdpau-va-gl + ]; + }; + }; + + services.xserver.videoDrivers = ["modesetting"]; +} diff --git a/hwModules/common/laptop/amd-gpu.nix b/hwModules/common/laptop/amd-gpu.nix new file mode 100644 index 00000000..ea8f50d4 --- /dev/null +++ b/hwModules/common/laptop/amd-gpu.nix @@ -0,0 +1,2 @@ +{...}: { +} diff --git a/hwModules/common/laptop/default.nix b/hwModules/common/laptop/default.nix new file mode 100644 index 00000000..6d290ce9 --- /dev/null +++ b/hwModules/common/laptop/default.nix @@ -0,0 +1,27 @@ +{ + lib, + pkgs, + ... +}: { + services = { + pipewire.wireplumber.extraConfig = { + # Pipewire eats battery by never disabling the camera. + "10-disable-camera" = { + "wireplumber.profiles" = { + main = { + "monitor.libcamera" = "disabled"; + }; + }; + }; + }; + + power-profiles-daemon.enable = lib.mkDefault true; + + udev.extraRules = '' + SUBSYSTEM=="power_supply", ATTR{online}=="1", ACTION=="change", RUN+="${lib.getExe pkgs.power-profiles-daemon} set balanced" + SUBSYSTEM=="power_supply", ATTR{online}=="0", ACTION=="change", RUN+="${lib.getExe pkgs.power-profiles-daemon} set power-saver" + ''; + + upower.enable = lib.mkDefault true; + }; +} diff --git a/hwModules/common/laptop/intel-cpu.nix b/hwModules/common/laptop/intel-cpu.nix new file mode 100644 index 00000000..115f1026 --- /dev/null +++ b/hwModules/common/laptop/intel-cpu.nix @@ -0,0 +1,4 @@ +{...}: { + powerManagement.powertop.enable = true; + services.thermald.enable = true; +} diff --git a/hwModules/common/ssd/default.nix b/hwModules/common/ssd/default.nix new file mode 100644 index 00000000..d9e3b4da --- /dev/null +++ b/hwModules/common/ssd/default.nix @@ -0,0 +1,3 @@ +{...}: { + services.fstrim.enable = true; +} diff --git a/hwModules/framework/13/amd-7000/default.nix b/hwModules/framework/13/amd-7000/default.nix new file mode 100644 index 00000000..09c55be4 --- /dev/null +++ b/hwModules/framework/13/amd-7000/default.nix @@ -0,0 +1,30 @@ +{ + lib, + pkgs, + ... +}: { + imports = [ + ../../../common/bluetooth + ../../../common/cpu/amd + ../../../common/gpu/amd + ../../../common/laptop + ../../../common/laptop/amd-gpu.nix + ../../../common/ssd + ../../common.nix + ../common.nix + ]; + + boot = { + initrd.availableKernelModules = ["nvme" "sd_mod" "thunderbolt" "usb_storage" "xhci_pci"]; + extraModprobeConfig = '' + options snd_hda_intel power_save=1 + ''; + kernelPackages = lib.mkDefault pkgs.linuxPackages_latest; + }; + + networking.networkmanager = { + enable = true; + wifi.powersave = true; + wifi.backend = "iwd"; + }; +} diff --git a/hwModules/framework/13/common.nix b/hwModules/framework/13/common.nix new file mode 100644 index 00000000..ea8f50d4 --- /dev/null +++ b/hwModules/framework/13/common.nix @@ -0,0 +1,2 @@ +{...}: { +} diff --git a/hwModules/framework/13/intel-11th/default.nix b/hwModules/framework/13/intel-11th/default.nix new file mode 100644 index 00000000..28c2c772 --- /dev/null +++ b/hwModules/framework/13/intel-11th/default.nix @@ -0,0 +1,28 @@ +{ + lib, + pkgs, + ... +}: { + imports = [ + ../../../common/bluetooth + ../../../common/cpu/intel + ../../../common/gpu/intel + ../../../common/laptop + ../../../common/laptop/intel-cpu.nix + ../../../common/ssd + ../../common.nix + ../common.nix + ]; + + boot = { + blacklistedKernelModules = ["cros-usbpd-charger"]; + initrd.availableKernelModules = ["xhci_pci" "thunderbolt" "nvme" "usb_storage" "sd_mod"]; + kernelPackages = lib.mkDefault pkgs.linuxPackages_latest; + + kernelParams = [ + "nvme.noacpi=1" # https://community.frame.work/t/linux-battery-life-tuning/6665/156 + ]; + }; + + hardware.acpilight.enable = true; +} diff --git a/hwModules/framework/common.nix b/hwModules/framework/common.nix new file mode 100644 index 00000000..aa7bba01 --- /dev/null +++ b/hwModules/framework/common.nix @@ -0,0 +1,35 @@ +{ + config, + lib, + pkgs, + ... +}: { + boot = { + extraModulePackages = with config.boot.kernelPackages; [ + framework-laptop-kmod + ]; + + kernelModules = [ + # https://github.com/DHowett/framework-laptop-kmod?tab=readme-ov-file#usage + "cros_ec_lpcs" + "cros_ec" + ]; + }; + + environment.systemPackages = [pkgs.framework-tool] ++ lib.optional (pkgs ? "fw-ectool") pkgs.fw-ectool; + + hardware = { + enableAllFirmware = true; + sensor.iio.enable = true; + }; + + services = { + fprintd.enable = true; + fwupd.enable = true; + + udev.extraRules = '' + # Ethernet expansion card support + ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0bda", ATTR{idProduct}=="8156", ATTR{power/autosuspend}="20" + ''; + }; +} diff --git a/hwModules/lenovo/common.nix b/hwModules/lenovo/common.nix new file mode 100644 index 00000000..abb1e686 --- /dev/null +++ b/hwModules/lenovo/common.nix @@ -0,0 +1,3 @@ +{...}: { + hardware.enableAllFirmware = true; +} diff --git a/hwModules/lenovo/yoga-9i/common.nix b/hwModules/lenovo/yoga-9i/common.nix new file mode 100644 index 00000000..4562e269 --- /dev/null +++ b/hwModules/lenovo/yoga-9i/common.nix @@ -0,0 +1,3 @@ +{...}: { + hardware.sensor.iio.enable = true; +} diff --git a/hwModules/lenovo/yoga-9i/intel-13th/default.nix b/hwModules/lenovo/yoga-9i/intel-13th/default.nix new file mode 100644 index 00000000..7cc1c0db --- /dev/null +++ b/hwModules/lenovo/yoga-9i/intel-13th/default.nix @@ -0,0 +1,21 @@ +{ + lib, + pkgs, + ... +}: { + imports = [ + ../../../common/bluetooth + ../../../common/cpu/intel + ../../../common/gpu/intel + ../../../common/laptop + ../../../common/laptop/intel-cpu.nix + ../../../common/ssd + ../../common.nix + ../common.nix + ]; + + boot = { + initrd.availableKernelModules = ["nvme" "sd_mod" "thunderbolt" "usb_storage" "xhci_pci"]; + kernelPackages = lib.mkDefault pkgs.linuxPackages_latest; + }; +} diff --git a/hwModules/thinkpad/common.nix b/hwModules/thinkpad/common.nix new file mode 100644 index 00000000..c1380c9d --- /dev/null +++ b/hwModules/thinkpad/common.nix @@ -0,0 +1,10 @@ +{...}: { + hardware = { + enableAllFirmware = true; + + trackpoint = { + enable = true; + emulateWheel = true; + }; + }; +} diff --git a/hwModules/thinkpad/t440p/default.nix b/hwModules/thinkpad/t440p/default.nix new file mode 100644 index 00000000..7858b514 --- /dev/null +++ b/hwModules/thinkpad/t440p/default.nix @@ -0,0 +1,32 @@ +{...}: { + imports = [ + ../../common/bluetooth + ../../common/cpu/intel + ../../common/gpu/intel + ../../common/laptop + ../../common/laptop/intel-cpu.nix + ../../common/ssd + ../common.nix + ]; + + boot = { + extraModprobeConfig = '' + options bbswitch use_acpi_to_detect_card_state=1 + options thinkpad_acpi force_load=1 fan_control=1 + ''; + + initrd.availableKernelModules = [ + "ahci" + "ehci_pci" + "rtsx_pci_sdmmc" + "sd_mod" + "sr_mod" + "usb_storage" + "xhci_pci" + ]; + }; + + powerManagement.cpuFreqGovernor = "ondemand"; + + services.fwupd.enable = true; +}