refactor: make the whole thing more generic

This commit is contained in:
2024-04-02 16:28:57 +02:00
parent 7b648e1955
commit 651f3ad808
193 changed files with 763 additions and 521 deletions

View File

@@ -0,0 +1,22 @@
{ pkgs, lib, config, ... }:
with lib;
let cfg = config.hardware.audio.preset.pipewire;
in {
options.hardware.audio.preset.pipewire = {
enable = mkEnableOption "Enable pipewire with sane defaults";
};
config = mkIf cfg.enable {
hardware.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
jack.enable = true;
};
};
}

View File

@@ -0,0 +1,39 @@
xkb_symbols "cc1-thea"
{
include "us(basic)"
include "level3(ralt_switch)"
key <AE11> {[minus, underscore, at]};
key <AE12> {[equal, question, ssharp]};
key <LatQ> {[q, Q, asterisk]};
key <LatW> {[w, W, 9]};
key <LatE> {[e, E, braceleft]};
key <LatR> {[r, R, 1]};
key <LatT> {[t, T, braceright]};
key <LatY> {[y, Y, bar]};
key <LatU> {[u, U, 5]};
key <LatI> {[i, I, exclam]};
key <LatO> {[o, O, 3]};
key <LatP> {[p, P, greater]};
key <LatA> {[a, A, 0]};
key <LatS> {[s, S, 4]};
key <LatD> {[d, D, parenright]};
key <LatF> {[f, F, 6]};
key <LatG> {[g, G, asciicircum]};
key <LatH> {[h, H, bracketright]};
key <LatJ> {[j, J, percent]};
key <LatK> {[k, K, 7]};
key <LatL> {[l, L, slash]};
key <AC10> {[semicolon, colon, dollar, EuroSign]};
key <AC11> {[apostrophe, quotedbl, ampersand]};
key <LatZ> {[z, Z, dead_diaeresis]};
key <LatX> {[x, X, plus]};
key <LatC> {[c, C, parenleft]};
key <LatV> {[v, V, less]};
key <LatB> {[b, B, 8]};
key <LatN> {[n, N, 2]};
key <LatM> {[m, M, bracketleft, mu]};
key <AB08> {[comma, numbersign, grave]};
key <AB09> {[period, asciitilde, backslash]};
};

View File

@@ -0,0 +1,29 @@
{ pkgs, lib, config, username, ... }:
with lib;
let cfg = config.hardware.cc1;
in {
options.hardware.cc1 = {
enable = mkEnableOption "Enable CC1 optimizations";
layout = mkOption {
type = with lib.types; enum [ "cc1-thea" ];
default = "cc1-thea";
};
};
config = mkIf cfg.enable {
# TODO: per-device layout?
console.useXkbConfig = true;
services.xserver.xkb = {
layout = cfg.layout;
extraLayouts.cc1-thea = {
description = "A CC1 optimized layout";
languages = [ "eng" "ger" ];
symbolsFile = ./${cfg.layout};
};
};
users.users.${username}.extraGroups = [ "dialout" ];
};
}

View File

@@ -0,0 +1,17 @@
{ pkgs, lib, config, username, ... }:
with lib;
let cfg = config.hardware.fv43u;
in {
options.hardware.fv43u = {
enable =
mkEnableOption "Enable optimisations for the Gigabyte FV43U monitor";
};
config = mkIf cfg.enable {
fonts.fontconfig.subpixel.rgba = "bgr";
hardware.gbmonctl.enable = true;
boot.kernelParams = [ "video=3840x2160@144" ];
};
}

View File

@@ -0,0 +1,23 @@
{ pkgs, lib, config, ... }:
with lib;
let cfg = config.hardware.gbmonctl;
in {
options.hardware.gbmonctl = {
enable = mkOption {
type = types.bool;
default = false;
description = mkDoc ''
Enables a CLI tool to change monitor settings over USB to the Gigabyte M32U
In theory any Gigabyte Monitor that uses a Realtek HID device (presumably the M28U also uses this) to control it over OSD sidekick should have the same protocol, but this is the only one I own.
'';
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.gbmonctl ];
services.udev.packages = [ pkgs.gbmonctl ];
};
}

View File

@@ -0,0 +1,51 @@
{ pkgs, lib, config, ... }:
with lib;
let cfg = config.hardware.nvidia.preset.proprietary;
in {
options.hardware.nvidia.preset.proprietary = {
enable = mkEnableOption
"Enable proprietary NVIDIA driver support with some sane defaults";
};
config = mkIf cfg.enable {
hardware.opengl = {
enable = true;
driSupport = true;
driSupport32Bit = true;
extraPackages = with pkgs; [ libvdpau-va-gl nvidia-vaapi-driver ];
};
services.xserver.videoDrivers = [ "nvidia" ];
boot.kernelParams = [ "nvidia_drm.fbdev=1" ];
boot.kernelModules =
[ "nvidia" "nvidia_modeset" "nvidia_uvm" "nvidia_drm" ];
boot.initrd.kernelModules =
[ "nvidia" "nvidia_modeset" "nvidia_uvm" "nvidia_drm" ];
hardware.nvidia = {
modesetting.enable = true;
# seems to cause crashes on sleep
powerManagement.enable = false;
open = true;
nvidiaSettings = false;
# no idea if this actually does anything...
nvidiaPersistenced = false;
};
environment = {
variables = {
VDPAU_DRIVER = "va_gl";
LIBVA_DRIVER_NAME = "nvidia";
};
systemPackages = with pkgs; [
glxinfo
nvtopPackages.nvidia
libva-utils
vulkan-tools
];
};
};
}

View File

@@ -0,0 +1,22 @@
{ pkgs, lib, config, ... }:
with lib;
let cfg = config.hardware.virtual-camera;
in {
options.hardware.virtual-camera = {
enable = mkEnableOption "Enable the virtual camera";
};
config = mkIf cfg.enable {
boot = {
# Virtual Camera/Mic
kernelModules = [ "v4l2loopback" "snd-aloop" "sg" ];
extraModulePackages = with config.boot.kernelPackages;
[ v4l2loopback.out ];
extraModprobeConfig = ''
options v4l2loopback exclusive_caps=1 card_label="Virtual Camera"
'';
};
};
}