nixos: hardware: use nixos-hardware
This commit is contained in:
parent
881c33bbc7
commit
f8f66a088f
15 changed files with 40 additions and 236 deletions
16
flake.lock
16
flake.lock
|
@ -329,6 +329,21 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixos-hardware": {
|
||||
"locked": {
|
||||
"lastModified": 1702453208,
|
||||
"narHash": "sha256-0wRi9SposfE2wHqjuKt8WO2izKB/ASDOV91URunIqgo=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixos-hardware",
|
||||
"rev": "7763c6fd1f299cb9361ff2abf755ed9619ef01d6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"repo": "nixos-hardware",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpak": {
|
||||
"inputs": {
|
||||
"flake-parts": [
|
||||
|
@ -504,6 +519,7 @@
|
|||
"impermanence": "impermanence",
|
||||
"lanzaboote": "lanzaboote",
|
||||
"nix-darwin": "nix-darwin",
|
||||
"nixos-hardware": "nixos-hardware",
|
||||
"nixpak": "nixpak",
|
||||
"nixpak-pkgs": "nixpak-pkgs",
|
||||
"nixpkgs": "nixpkgs",
|
||||
|
|
11
flake.nix
11
flake.nix
|
@ -33,7 +33,9 @@
|
|||
url = "github:hyprwm/hyprland-plugins";
|
||||
inputs.hyprland.follows = "hyprland";
|
||||
};
|
||||
impermanence.url = "github:nix-community/impermanence";
|
||||
impermanence = {
|
||||
url = "github:nix-community/impermanence";
|
||||
};
|
||||
lanzaboote = {
|
||||
url = "github:nix-community/lanzaboote";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
@ -48,6 +50,9 @@
|
|||
url = "github:LnL7/nix-darwin";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
nixos-hardware = {
|
||||
url = "github:NixOS/nixos-hardware";
|
||||
};
|
||||
nixpak = {
|
||||
url = "github:nixpak/nixpak";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
@ -139,10 +144,6 @@
|
|||
|
||||
# TODO: Unused, Soon(TM)
|
||||
#daeuniverse.url = "github:daeuniverse/flake.nix";
|
||||
#nixos-hardware = {
|
||||
# url = "github:NixOS/nixos-hardware/master";
|
||||
# #inputs.nixpkgs.follows = "nixpkgs";
|
||||
#};
|
||||
|
||||
## Non-Flake
|
||||
### My NeoVim configuration
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
modulesPath,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
../../../hardware/misc/audio.nix
|
||||
../../../hardware/misc/bluetooth.nix
|
||||
../../../hardware/misc/opengl.nix
|
||||
../../../hardware/cpu/intel.nix
|
||||
../../../hardware/gpu/amd.nix
|
||||
(modulesPath + "/hardware/network/broadcom-43xx.nix")
|
||||
(modulesPath + "/installer/scan/not-detected.nix") # what is this
|
||||
];
|
||||
|
||||
boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" "sdhci_pci"];
|
||||
|
||||
# Options from github:NixOS/nixos-hardware
|
||||
boot.kernelParams = ["hid_apple.iso_layout=0"];
|
||||
hardware.facetimehd.enable = true; # TODO: Camera already works before adding this, not sure what is the point...
|
||||
|
||||
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||
# still possible to use this option, but it's recommended to use it in conjunction
|
||||
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
||||
networking.useDHCP = lib.mkDefault true;
|
||||
# networking.interfaces.enp4s0f0.useDHCP = lib.mkDefault true;
|
||||
# networking.interfaces.wlp3s0.useDHCP = lib.mkDefault true;
|
||||
}
|
|
@ -1,38 +1,24 @@
|
|||
{
|
||||
lib,
|
||||
modulesPath,
|
||||
inputs,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
(modulesPath + "/installer/scan/not-detected.nix") # what is this
|
||||
(modulesPath + "/installer/scan/not-detected.nix")
|
||||
inputs.nixos-hardware.nixosModules.lenovo-legion-y530-15ich
|
||||
];
|
||||
|
||||
myFlake.hardware.components = {
|
||||
cpu.intel.enable = true;
|
||||
|
||||
gpu.intel.enable = true;
|
||||
gpu.nvidia.enable = true;
|
||||
gpu.nvidia.prime = true;
|
||||
|
||||
misc.audio.enable = true;
|
||||
misc.bluetooth.enable = true;
|
||||
misc.fstrim.enable = true;
|
||||
misc.tpm.enable = true;
|
||||
myFlake.hardware.components.misc = {
|
||||
audio.enable = true;
|
||||
bluetooth.enable = true;
|
||||
tpm.enable = true;
|
||||
};
|
||||
|
||||
boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "usbhid"];
|
||||
boot.initrd.kernelModules = [];
|
||||
boot.kernelModules = ["kvm-intel"];
|
||||
boot.extraModulePackages = [];
|
||||
|
||||
# Nvidia PRIME
|
||||
hardware.nvidia.prime = {
|
||||
nvidiaBusId = "PCI:1:0:0";
|
||||
intelBusId = "PCI:0:2:0";
|
||||
};
|
||||
|
||||
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||
# still possible to use this option, but it's recommended to use it in conjunction
|
||||
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
||||
networking.useDHCP = lib.mkDefault true;
|
||||
# networking.interfaces.enp7s0.useDHCP = lib.mkDefault true;
|
||||
# networking.interfaces.wlan0.useDHCP = lib.mkDefault true;
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
}
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
{...}: {
|
||||
imports = [
|
||||
./intel.nix
|
||||
];
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
cfg = config.myFlake.hardware.components.cpu.intel;
|
||||
in {
|
||||
options = {
|
||||
myFlake.hardware.components.cpu.intel.enable = lib.mkEnableOption "Whether to enable Intel CPU.";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
boot.kernelModules = ["kvm-intel"];
|
||||
hardware.cpu.intel.updateMicrocode = config.hardware.enableRedistributableFirmware;
|
||||
nixpkgs.hostPlatform = "x86_64-linux";
|
||||
};
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
{...}: {
|
||||
imports = [
|
||||
./cpu
|
||||
./gpu
|
||||
./misc
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
cfg = config.myFlake.hardware.components.gpu.amd;
|
||||
in {
|
||||
options = {
|
||||
myFlake.hardware.components.gpu.amd.enable = lib.mkEnableOption "Whether to enable AMD GPU.";
|
||||
};
|
||||
|
||||
# https://nixos.wiki/wiki/AMD_GPU
|
||||
config = lib.mkIf cfg.enable {
|
||||
hardware.opengl = {
|
||||
enable = true;
|
||||
driSupport = true;
|
||||
driSupport32Bit = true;
|
||||
};
|
||||
|
||||
boot.initrd.kernelModules = ["amdgpu"];
|
||||
services.xserver.videoDrivers = ["amdgpu"];
|
||||
|
||||
# OpenCL
|
||||
hardware.opengl = {
|
||||
extraPackages = with pkgs; [
|
||||
amdvlk
|
||||
rocm-opencl-icd
|
||||
rocm-opencl-runtime
|
||||
];
|
||||
# Only available on unstable
|
||||
extraPackages32 = with pkgs; [
|
||||
driversi686Linux.amdvlk
|
||||
];
|
||||
};
|
||||
|
||||
# HIP
|
||||
systemd.tmpfiles.rules = [
|
||||
"L+ /opt/rocm/hip - - - - ${pkgs.hip}"
|
||||
];
|
||||
};
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
{...}: {
|
||||
imports = [
|
||||
./amd.nix
|
||||
./intel.nix
|
||||
./nvidia.nix
|
||||
];
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
cfg = config.myFlake.hardware.components.gpu.intel;
|
||||
in {
|
||||
options = {
|
||||
myFlake.hardware.components.gpu.intel.enable = lib.mkEnableOption "Whether to enable Intel GPU.";
|
||||
};
|
||||
|
||||
# https://nixos.wiki/wiki/Intel_Graphics
|
||||
config = lib.mkIf cfg.enable {
|
||||
hardware.opengl = {
|
||||
enable = true;
|
||||
driSupport = true;
|
||||
driSupport32Bit = true;
|
||||
};
|
||||
|
||||
nixpkgs.config.packageOverrides = pkgs: {vaapiIntel = pkgs.intel-vaapi-driver.override {enableHybridCodec = true;};};
|
||||
hardware.opengl = {
|
||||
extraPackages = with pkgs; [
|
||||
intel-media-driver # libva_driver_name=ihd
|
||||
intel-vaapi-driver # libva_driver_name=i965 (older but works better for firefox/chromium)
|
||||
vaapiVdpau
|
||||
libvdpau-va-gl
|
||||
intel-compute-runtime # intel opencl
|
||||
intel-media-driver # intel vaapi
|
||||
];
|
||||
extraPackages32 = with pkgs; [pkgsi686Linux.vaapiIntel];
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
cfg = config.myFlake.hardware.components.gpu.nvidia;
|
||||
in {
|
||||
options = {
|
||||
myFlake.hardware.components.gpu.nvidia.enable = lib.mkEnableOption "Whether to enable NVIDIA GPU.";
|
||||
myFlake.hardware.components.gpu.nvidia.prime = lib.mkEnableOption "Whether to enable NVIDIA Prime.";
|
||||
};
|
||||
|
||||
# https://nixos.wiki/wiki/Nvidia
|
||||
config = lib.mkIf cfg.enable {
|
||||
# Enable OpenGL
|
||||
hardware.opengl = {
|
||||
enable = true;
|
||||
driSupport = true;
|
||||
driSupport32Bit = true;
|
||||
};
|
||||
|
||||
# Load nvidia driver for Xorg and Wayland
|
||||
services.xserver.videoDrivers = ["nvidia"];
|
||||
|
||||
nixpkgs.config.nvidia.acceptLicense = true;
|
||||
hardware.nvidia = {
|
||||
package = config.boot.kernelPackages.nvidiaPackages.legacy_470;
|
||||
modesetting.enable = true;
|
||||
};
|
||||
|
||||
# cfg.prime
|
||||
hardware.nvidia.prime = lib.mkIf cfg.prime {
|
||||
offload = {
|
||||
enable = true;
|
||||
enableOffloadCmd = true;
|
||||
};
|
||||
|
||||
#sync.enable = true;
|
||||
#reverseSync.enable = true;
|
||||
|
||||
### Device specific, please put those configuration in `machines/your-machine.nix`
|
||||
# nvidiaBusId = "PCI:1:0:0";
|
||||
# intelBusId = "PCI:0:2:0";
|
||||
};
|
||||
|
||||
environment.sessionVariables = {
|
||||
"GAMEMODERUNEXEC" = lib.mkIf (config.hardware.nvidia.prime.offload.enable || config.programs.gamemode.enable) "nvidia-offload"; # gamemode: nvidia offload
|
||||
};
|
||||
};
|
||||
}
|
|
@ -2,7 +2,6 @@
|
|||
imports = [
|
||||
./audio.nix
|
||||
./bluetooth.nix
|
||||
./fstrim.nix
|
||||
./tpm.nix
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
cfg = config.myFlake.hardware.components.misc.fstrim;
|
||||
in {
|
||||
options = {
|
||||
myFlake.hardware.components.misc.fstrim.enable = lib.mkEnableOption "Whether to enable SSD triming in background.";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.fstrim.enable = true;
|
||||
};
|
||||
}
|
|
@ -50,16 +50,20 @@
|
|||
};
|
||||
};
|
||||
|
||||
# WORKAROUND: Revert to NVIDIA version 470.223.02 due to performance issues in version 545.29.06,
|
||||
# this shouldn't affect non-nvidia machines.
|
||||
nixpkgs.config.nvidia.acceptLicense = true;
|
||||
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.legacy_470;
|
||||
|
||||
# Services
|
||||
services = {
|
||||
getty.greetingLine = let
|
||||
inherit (config.system) nixos;
|
||||
inherit (config.myFlake.hardware.components) gpu;
|
||||
in ''
|
||||
NixOS ${nixos.label} ${nixos.codeName} (\m) - \l
|
||||
${lib.strings.optionalString gpu.nvidia.enable
|
||||
${lib.strings.optionalString (builtins.elem "nvidia" config.services.xserver.videoDrivers)
|
||||
"--my-next-gpu-wont-be-nvidia"}
|
||||
${lib.strings.optionalString gpu.amd.enable
|
||||
${lib.strings.optionalString (builtins.elem "amdgpu" config.boot.initrd.kernelModules)
|
||||
"[ 5.996722] amdgpu 0000:67:00.0: Fatal error during GPU init"}
|
||||
'';
|
||||
|
||||
|
|
|
@ -9,6 +9,5 @@
|
|||
services.system76-scheduler.enable = true;
|
||||
services.power-profiles-daemon.enable = true;
|
||||
services.thermald.enable = true;
|
||||
services.fwupd.enable = true;
|
||||
#services.printing.enable = true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue