diff --git a/flake.lock b/flake.lock index 918a369..b0c483b 100755 --- a/flake.lock +++ b/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", diff --git a/flake.nix b/flake.nix index 6a17724..e58c0ad 100755 --- a/flake.nix +++ b/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 diff --git a/nixos/hardware/apple/imac/18-3/default.nix b/nixos/hardware/apple/imac/18-3/default.nix deleted file mode 100644 index c1922a7..0000000 --- a/nixos/hardware/apple/imac/18-3/default.nix +++ /dev/null @@ -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..useDHCP`. - networking.useDHCP = lib.mkDefault true; - # networking.interfaces.enp4s0f0.useDHCP = lib.mkDefault true; - # networking.interfaces.wlp3s0.useDHCP = lib.mkDefault true; -} diff --git a/nixos/hardware/lenovo/legion/81fw/default.nix b/nixos/hardware/lenovo/legion/81fw/default.nix index 8cb06a3..b6d9384 100644 --- a/nixos/hardware/lenovo/legion/81fw/default.nix +++ b/nixos/hardware/lenovo/legion/81fw/default.nix @@ -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..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"; } diff --git a/nixos/modules/hardware/components/cpu/default.nix b/nixos/modules/hardware/components/cpu/default.nix deleted file mode 100644 index 024255e..0000000 --- a/nixos/modules/hardware/components/cpu/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{...}: { - imports = [ - ./intel.nix - ]; -} diff --git a/nixos/modules/hardware/components/cpu/intel.nix b/nixos/modules/hardware/components/cpu/intel.nix deleted file mode 100755 index 8e4ed18..0000000 --- a/nixos/modules/hardware/components/cpu/intel.nix +++ /dev/null @@ -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"; - }; -} diff --git a/nixos/modules/hardware/components/default.nix b/nixos/modules/hardware/components/default.nix index 08405b1..1bd6a41 100644 --- a/nixos/modules/hardware/components/default.nix +++ b/nixos/modules/hardware/components/default.nix @@ -1,7 +1,5 @@ {...}: { imports = [ - ./cpu - ./gpu ./misc ]; } diff --git a/nixos/modules/hardware/components/gpu/amd.nix b/nixos/modules/hardware/components/gpu/amd.nix deleted file mode 100644 index 21d7876..0000000 --- a/nixos/modules/hardware/components/gpu/amd.nix +++ /dev/null @@ -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}" - ]; - }; -} diff --git a/nixos/modules/hardware/components/gpu/default.nix b/nixos/modules/hardware/components/gpu/default.nix deleted file mode 100644 index f1995cb..0000000 --- a/nixos/modules/hardware/components/gpu/default.nix +++ /dev/null @@ -1,7 +0,0 @@ -{...}: { - imports = [ - ./amd.nix - ./intel.nix - ./nvidia.nix - ]; -} diff --git a/nixos/modules/hardware/components/gpu/intel.nix b/nixos/modules/hardware/components/gpu/intel.nix deleted file mode 100644 index 848092a..0000000 --- a/nixos/modules/hardware/components/gpu/intel.nix +++ /dev/null @@ -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]; - }; - }; -} diff --git a/nixos/modules/hardware/components/gpu/nvidia.nix b/nixos/modules/hardware/components/gpu/nvidia.nix deleted file mode 100755 index f94857b..0000000 --- a/nixos/modules/hardware/components/gpu/nvidia.nix +++ /dev/null @@ -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 - }; - }; -} diff --git a/nixos/modules/hardware/components/misc/default.nix b/nixos/modules/hardware/components/misc/default.nix index 492ff1a..ca4fda4 100644 --- a/nixos/modules/hardware/components/misc/default.nix +++ b/nixos/modules/hardware/components/misc/default.nix @@ -2,7 +2,6 @@ imports = [ ./audio.nix ./bluetooth.nix - ./fstrim.nix ./tpm.nix ]; } diff --git a/nixos/modules/hardware/components/misc/fstrim.nix b/nixos/modules/hardware/components/misc/fstrim.nix deleted file mode 100644 index 82e2a23..0000000 --- a/nixos/modules/hardware/components/misc/fstrim.nix +++ /dev/null @@ -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; - }; -} diff --git a/nixos/profiles/core/default.nix b/nixos/profiles/core/default.nix index d2f6b6f..4da299e 100644 --- a/nixos/profiles/core/default.nix +++ b/nixos/profiles/core/default.nix @@ -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"} ''; diff --git a/nixos/profiles/device-type/desktop/default.nix b/nixos/profiles/device-type/desktop/default.nix index 5d697b6..97573ee 100644 --- a/nixos/profiles/device-type/desktop/default.nix +++ b/nixos/profiles/device-type/desktop/default.nix @@ -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; }