2021-04-11 00:25:36 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2021-03-14 10:58:29 +01:00
|
|
|
with lib;
|
|
|
|
let
|
2021-03-14 22:22:45 +01:00
|
|
|
xserver-enable = config.services.xserver.enable;
|
2021-04-11 00:25:36 +02:00
|
|
|
nvidia-offload = pkgs.writeShellScriptBin "nvidia-offload" ''
|
2021-03-14 10:58:29 +01:00
|
|
|
export __NV_PRIME_RENDER_OFFLOAD=1
|
|
|
|
export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
|
|
|
|
export __GLX_VENDOR_LIBRARY_NAME=nvidia
|
|
|
|
export __VK_LAYER_NV_optimus=NVIDIA_only
|
|
|
|
exec -a "$0" "$@"
|
|
|
|
'';
|
|
|
|
cfg = config.magic_rb.xserver;
|
|
|
|
in
|
2020-12-26 23:36:50 +01:00
|
|
|
{
|
2021-03-14 10:58:29 +01:00
|
|
|
options.magic_rb.xserver = {
|
|
|
|
enable = mkEnableOption "XServer for my setup style";
|
|
|
|
gpu = mkOption {
|
|
|
|
description = "Which GPU type do you have?";
|
2021-03-14 22:22:45 +01:00
|
|
|
type = types.enum ["nvidia"];
|
2020-12-26 23:36:50 +01:00
|
|
|
};
|
|
|
|
|
2021-03-14 22:22:45 +01:00
|
|
|
nvidia = mkOption {
|
|
|
|
description = "NVidia section";
|
|
|
|
type = types.submodule {
|
|
|
|
options = {
|
2022-04-15 09:53:16 +02:00
|
|
|
primeOffload = mkEnableOption "NVidia PRIME sync support";
|
|
|
|
primeSync = mkEnableOption "NVidia PRIME offload support";
|
2021-03-14 22:22:45 +01:00
|
|
|
|
|
|
|
intelBusId = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
};
|
|
|
|
nvidiaBusId = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
|
|
|
};
|
|
|
|
|
|
|
|
linux-5-11-patch = mkEnableOption "Linux 5.11 compat patch";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
default = {};
|
2020-12-26 23:36:50 +01:00
|
|
|
};
|
2021-03-14 22:22:45 +01:00
|
|
|
xmonad = mkEnableOption "Enable xmonad";
|
2021-04-11 00:25:36 +02:00
|
|
|
lightdm = mkEnableOption "Enable lightdm";
|
2021-05-12 23:57:02 +02:00
|
|
|
qwertyNeo2 = mkEnableOption "Add custom qwerty neo layout.";
|
2021-06-27 18:55:40 +02:00
|
|
|
mimickInTty = mkEnableOption "Mimick xkb set keyboard layouts in TTYs.";
|
2020-12-26 23:36:50 +01:00
|
|
|
};
|
|
|
|
|
2021-03-14 22:22:45 +01:00
|
|
|
config = mkIf cfg.enable (mkMerge [
|
|
|
|
{
|
|
|
|
services.xserver = {
|
|
|
|
enable = true;
|
2021-03-14 10:58:29 +01:00
|
|
|
|
2021-03-14 22:22:45 +01:00
|
|
|
windowManager = mkIf cfg.xmonad {
|
|
|
|
xmonad.enable = true;
|
|
|
|
xmonad.enableContribAndExtras = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
displayManager = mkIf cfg.xmonad {
|
2021-04-11 00:25:36 +02:00
|
|
|
lightdm.enable = mkIf cfg.lightdm true;
|
2021-03-14 22:22:45 +01:00
|
|
|
defaultSession = "none+xmonad";
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
libinput.enable = true;
|
2021-03-14 10:58:29 +01:00
|
|
|
};
|
|
|
|
|
2021-03-14 22:22:45 +01:00
|
|
|
hardware = {
|
2022-04-15 09:53:16 +02:00
|
|
|
opengl.enable = true;
|
2021-03-14 22:22:45 +01:00
|
|
|
opengl.driSupport32Bit = true;
|
2021-03-14 10:58:29 +01:00
|
|
|
};
|
2021-03-14 22:22:45 +01:00
|
|
|
}
|
|
|
|
(mkIf (cfg.gpu == "nvidia") {
|
|
|
|
services.xserver.videoDrivers = [ "nvidia" ];
|
2022-04-15 09:53:16 +02:00
|
|
|
hardware.nvidia.modesetting.enable = mkIf cfg.nvidia.primeSync true;
|
2021-03-14 10:58:29 +01:00
|
|
|
|
2022-04-15 09:53:16 +02:00
|
|
|
services.xserver.deviceSection = mkIf cfg.nvidia.primeSync ''
|
|
|
|
Option "Coolbits" "28"
|
|
|
|
Option "UseEvents" "on"
|
|
|
|
'';
|
|
|
|
|
|
|
|
environment.systemPackages = mkIf cfg.nvidia.primeOffload
|
2021-04-11 00:25:36 +02:00
|
|
|
[ nvidia-offload pkgs.libglvnd ];
|
2021-03-14 10:58:29 +01:00
|
|
|
|
2022-04-15 09:53:16 +02:00
|
|
|
hardware.nvidia.prime = mkIf (cfg.nvidia.primeSync || cfg.nvidia.primeOffload) {
|
|
|
|
sync.enable = cfg.nvidia.primeSync;
|
|
|
|
offload.enable = cfg.nvidia.primeOffload;
|
2021-03-14 22:22:45 +01:00
|
|
|
|
|
|
|
intelBusId = cfg.nvidia.intelBusId;
|
|
|
|
nvidiaBusId = cfg.nvidia.nvidiaBusId;
|
|
|
|
};
|
|
|
|
})
|
2021-05-12 23:57:02 +02:00
|
|
|
(mkIf cfg.qwertyNeo2 {
|
2021-03-14 22:22:45 +01:00
|
|
|
services.xserver = {
|
2021-06-27 18:55:40 +02:00
|
|
|
layout = "de,de";
|
2022-01-26 20:38:03 +01:00
|
|
|
xkbVariant = "koy,neo_qwerty";
|
2021-06-27 18:55:40 +02:00
|
|
|
xkbOptions = "ctrl:swap_lalt_lctl_lwin, altwin:menu_win, grp:sclk_toggle";
|
2021-05-28 09:01:35 +02:00
|
|
|
|
|
|
|
extraLayouts."neo_qwerty" = {
|
|
|
|
description = "QWERTY neo2 layout.";
|
|
|
|
languages = [ "de" ];
|
|
|
|
symbolsFile = ./qwerty_neo.xkb;
|
|
|
|
};
|
2021-03-14 22:22:45 +01:00
|
|
|
};
|
|
|
|
})
|
2021-06-27 18:55:40 +02:00
|
|
|
(mkIf cfg.mimickInTty {
|
|
|
|
console.useXkbConfig = true;
|
|
|
|
})
|
2021-03-14 22:22:45 +01:00
|
|
|
]);
|
2020-12-26 23:36:50 +01:00
|
|
|
}
|