From 05a72217aa0f905f897c4f740b5ca368cda2e24e Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Fri, 29 Jan 2021 15:50:16 +0100 Subject: [PATCH] Use nixos-hardware for hardware configuration This removes the manual modules that use options to activate hardware configuration. It seems to general (e.g. newer Intel GPUs require different opencl icd) or not flexible enough (in case of the ssd module). Closes #21. --- deploy.nix | 4 +++ machines/nunotaba/configuration.nix | 3 -- machines/nunotaba/hardware-configuration.nix | 7 +++++ machines/sayuri/configuration.nix | 3 -- machines/sayuri/hardware-configuration.nix | 15 +++++++++ modules/cpu/default.nix | 5 --- modules/cpu/intel.nix | 11 ------- modules/default.nix | 3 -- modules/gpu/amd.nix | 32 -------------------- modules/gpu/default.nix | 7 ----- modules/gpu/intel.nix | 14 --------- modules/ssd.nix | 32 -------------------- nix/sources.json | 12 ++++++++ 13 files changed, 38 insertions(+), 110 deletions(-) delete mode 100644 modules/cpu/default.nix delete mode 100644 modules/cpu/intel.nix delete mode 100644 modules/gpu/amd.nix delete mode 100644 modules/gpu/default.nix delete mode 100644 modules/gpu/intel.nix delete mode 100644 modules/ssd.nix diff --git a/deploy.nix b/deploy.nix index bc4f712..171fa26 100644 --- a/deploy.nix +++ b/deploy.nix @@ -19,6 +19,10 @@ let url = https://github.com/NixOS/nixpkgs; shallow = true; }; + nixos-hardware.git = { + ref = sources.nixos-hardware.rev; + url = https://github.com/NixOS/nixos-hardware; + }; config.file = { path = toString ./.; filters = [ diff --git a/machines/nunotaba/configuration.nix b/machines/nunotaba/configuration.nix index 8269011..7d53761 100644 --- a/machines/nunotaba/configuration.nix +++ b/machines/nunotaba/configuration.nix @@ -8,14 +8,11 @@ ]; sbruder = { - cpu.intel.enable = true; docker.enable = true; games.enable = true; - gpu.intel.enable = true; gui.enable = true; media-proxy.enable = true; restic.enable = true; - ssd.enable = true; unfree.allowSoftware = true; wireguard.home = { enable = true; diff --git a/machines/nunotaba/hardware-configuration.nix b/machines/nunotaba/hardware-configuration.nix index 9c12924..b1910ef 100644 --- a/machines/nunotaba/hardware-configuration.nix +++ b/machines/nunotaba/hardware-configuration.nix @@ -3,6 +3,8 @@ { imports = [ (modulesPath + "/installer/scan/not-detected.nix") + + ]; boot = { @@ -27,6 +29,7 @@ "/" = { device = "/dev/disk/by-uuid/8937d1ac-23cb-456f-9c16-e348acc66bb7"; fsType = "ext4"; + options = [ "discard" "noatime" ]; }; "/boot" = { @@ -44,4 +47,8 @@ # Most of the time I want to use both screens at the same time and suspend it # regularily by closing the lid services.logind.lidSwitchDocked = config.services.logind.lidSwitch; + + hardware.opengl.extraPackages = with pkgs; [ + beignet # OpenCL for old intel GPU + ]; } diff --git a/machines/sayuri/configuration.nix b/machines/sayuri/configuration.nix index 92f7be4..2740c1c 100644 --- a/machines/sayuri/configuration.nix +++ b/machines/sayuri/configuration.nix @@ -8,10 +8,8 @@ ]; sbruder = { - cpu.intel.enable = true; docker.enable = true; games.enable = true; - gpu.amd.enable = true; gui.enable = true; media-proxy.enable = true; restic = { @@ -20,7 +18,6 @@ "/data" ]; }; - ssd.enable = true; unfree.allowSoftware = true; wireguard.home = { enable = true; diff --git a/machines/sayuri/hardware-configuration.nix b/machines/sayuri/hardware-configuration.nix index e76f56d..0b1d4f7 100644 --- a/machines/sayuri/hardware-configuration.nix +++ b/machines/sayuri/hardware-configuration.nix @@ -3,6 +3,8 @@ { imports = [ (modulesPath + "/installer/scan/not-detected.nix") + + ]; boot = { @@ -27,6 +29,7 @@ "/" = { device = "/dev/disk/by-uuid/024e31ab-aa98-4070-95be-7980043541ac"; fsType = "ext4"; + options = [ "discard" "noatime" ]; }; "/boot" = { @@ -50,4 +53,16 @@ ]; powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + + # GPU + hardware.opengl.extraPackages = with pkgs; [ + amdvlk + rocm-opencl-icd + ]; + + environment.systemPackages = with pkgs; [ + clinfo + radeontop + rocm-smi + ]; } diff --git a/modules/cpu/default.nix b/modules/cpu/default.nix deleted file mode 100644 index 7934478..0000000 --- a/modules/cpu/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ - imports = [ - ./intel.nix - ]; -} diff --git a/modules/cpu/intel.nix b/modules/cpu/intel.nix deleted file mode 100644 index ed1efd4..0000000 --- a/modules/cpu/intel.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ config, lib, ... }: -let - cfg = config.sbruder.cpu.intel; -in -{ - options.sbruder.cpu.intel.enable = lib.mkEnableOption "intel cpu configuration"; - - config = lib.mkIf cfg.enable { - hardware.cpu.intel.updateMicrocode = true; - }; -} diff --git a/modules/default.nix b/modules/default.nix index 9e6cb88..fe1c869 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -34,11 +34,9 @@ in # All modules are imported but non-essential modules are activated by # configuration options imports = [ - ./cpu ./cups.nix ./docker.nix ./fonts.nix - ./gpu ./grub.nix ./gui.nix ./initrd-ssh.nix @@ -52,7 +50,6 @@ in ./pulseaudio.nix ./restic.nix ./secrets.nix - ./ssd.nix ./ssh.nix ./tools.nix ./udev.nix diff --git a/modules/gpu/amd.nix b/modules/gpu/amd.nix deleted file mode 100644 index 8bfd356..0000000 --- a/modules/gpu/amd.nix +++ /dev/null @@ -1,32 +0,0 @@ -{ config, lib, pkgs, ... }: -let - cfg = config.sbruder.gpu.amd; -in -{ - options.sbruder.gpu.amd.enable = lib.mkEnableOption "amd gpu configuration"; - - config = lib.mkIf cfg.enable { - hardware.opengl.extraPackages = with pkgs; [ - amdvlk - rocm-opencl-icd - ]; - - environment.systemPackages = with pkgs; [ - clinfo - radeontop - rocm-smi - ]; - - # force RGB otput for HDMI (otherwise the default is YCbCr) - # see https://gitlab.freedesktop.org/drm/amd/-/issues/476 - #boot.kernelPatches = [ - # { - # name = "force-rgb"; - # patch = pkgs.fetchpatch { - # url = "https://gitlab.freedesktop.org/drm/amd/uploads/99b3664a49ec759075bde5c454e1d7c2/0001-force-rgb.patch"; - # sha256 = "03dhnlxx9vlj1x8izh3c3j4r9s75q47nx8kf6mbdxqfy3cj96mjm"; - # }; - # } - #]; - }; -} diff --git a/modules/gpu/default.nix b/modules/gpu/default.nix deleted file mode 100644 index 68eb19d..0000000 --- a/modules/gpu/default.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ lib, ... }: -{ - imports = [ - ./amd.nix - ./intel.nix - ]; -} diff --git a/modules/gpu/intel.nix b/modules/gpu/intel.nix deleted file mode 100644 index 103a6ed..0000000 --- a/modules/gpu/intel.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ config, lib, pkgs, ... }: -let - cfg = config.sbruder.gpu.intel; -in -{ - options.sbruder.gpu.intel.enable = lib.mkEnableOption "intel gpu configuration"; - - config = lib.mkIf cfg.enable { - hardware.opengl.extraPackages = with pkgs; [ - beignet - vaapiIntel - ]; - }; -} diff --git a/modules/ssd.nix b/modules/ssd.nix deleted file mode 100644 index 3230b0c..0000000 --- a/modules/ssd.nix +++ /dev/null @@ -1,32 +0,0 @@ -{ config, lib, ... }: -let - cfg = config.sbruder.ssd; -in -{ - options.sbruder.ssd = { - enable = lib.mkEnableOption "ssd optimisations"; - fileSystems = lib.mkOption { - type = lib.types.listOf lib.types.str; - default = [ "/" ]; - description = "List of file systems to apply optimisations to"; - }; - }; - - config = lib.mkIf cfg.enable { - fileSystems = builtins.listToAttrs - (builtins.map - (fs: { - name = fs; - value = { - options = [ - "discard" - "noatime" - "nodiratime" - ]; - }; - }) - cfg.fileSystems); - - services.fstrim.enable = true; - }; -} diff --git a/nix/sources.json b/nix/sources.json index 178e3cd..049dd91 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -23,6 +23,18 @@ "url": "https://github.com/krebs/krops/archive/c2fa48550f2bb46009b9cecdb9ac838dc402ce19.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, + "nixos-hardware": { + "branch": "master", + "description": "A collection of NixOS modules covering hardware quirks.", + "homepage": "", + "owner": "nixos", + "repo": "nixos-hardware", + "rev": "a0d8383c422f85f37fccee5af74b1cb4b52287d9", + "sha256": "08w3z19alqrnwpaxppcrlpyw7y5060xha81abhndaxryzvcld2hl", + "type": "tarball", + "url": "https://github.com/nixos/nixos-hardware/archive/a0d8383c422f85f37fccee5af74b1cb4b52287d9.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, "nixpkgs": { "branch": "nixos-20.09", "description": "Nix Packages collection",