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.
This commit is contained in:
Simon Bruder 2021-01-29 15:50:16 +01:00
parent 55fb2cfdda
commit 05a72217aa
Signed by: simon
GPG key ID: 8D3C82F9F309F8EC
13 changed files with 38 additions and 110 deletions

View file

@ -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 = [

View file

@ -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;

View file

@ -3,6 +3,8 @@
{
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
<nixos-hardware/common/cpu/intel>
<nixos-hardware/common/pc/ssd>
];
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
];
}

View file

@ -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;

View file

@ -3,6 +3,8 @@
{
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
<nixos-hardware/common/cpu/intel>
<nixos-hardware/common/pc/ssd>
];
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
];
}

View file

@ -1,5 +0,0 @@
{
imports = [
./intel.nix
];
}

View file

@ -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;
};
}

View file

@ -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

View file

@ -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";
# };
# }
#];
};
}

View file

@ -1,7 +0,0 @@
{ lib, ... }:
{
imports = [
./amd.nix
./intel.nix
];
}

View file

@ -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
];
};
}

View file

@ -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;
};
}

View file

@ -23,6 +23,18 @@
"url": "https://github.com/krebs/krops/archive/c2fa48550f2bb46009b9cecdb9ac838dc402ce19.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.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/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
"branch": "nixos-20.09",
"description": "Nix Packages collection",