2021-03-08 21:35:29 +01:00
|
|
|
{ nixpkgs, nixpkgs-unstable, nixpkgs-master, custom, hostname, rlib, inputs }:
|
2021-03-14 10:58:29 +01:00
|
|
|
{ config, lib, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
nvidia-offload = nixpkgs.writeShellScriptBin "nvidia-offload" ''
|
|
|
|
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?";
|
|
|
|
type = types.oneOf ["nvidia"];
|
2020-12-26 23:36:50 +01:00
|
|
|
};
|
2021-03-14 10:58:29 +01:00
|
|
|
prime = mkEnableOption "NVidia PRIME support";
|
|
|
|
xmonad = mkEnableOption "Enable xmonad";
|
2020-12-26 23:36:50 +01:00
|
|
|
|
2021-03-14 10:58:29 +01:00
|
|
|
intelBusId = mkOption {
|
|
|
|
type = types.string;
|
|
|
|
};
|
|
|
|
nvidiaBusId = mkOption {
|
|
|
|
type = types.string;
|
2020-12-26 23:36:50 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-03-14 10:58:29 +01:00
|
|
|
config = mkIf cfg.enable {
|
|
|
|
services.xserver = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
windowManager = mkIf cfg.xmonad {
|
|
|
|
xmonad.enable = true;
|
|
|
|
xmonad.enableContribAndExtras = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
displayManager = mkIf cfg.xmonad {
|
|
|
|
defaultSession = "none+xmonad";
|
|
|
|
};
|
|
|
|
|
|
|
|
videoDrivers = [ "nvidia" ];
|
|
|
|
|
|
|
|
libinput.enable = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
hardware = {
|
|
|
|
opengl.driSupport32Bit = true;
|
|
|
|
# opengl.extraPackages32 = with pkgs.pkgsi686Linux; [ libva ]; # What does this do??
|
|
|
|
};
|
|
|
|
|
|
|
|
environment.systemPackages = mkIf (cfg.prime && cfg.gpu == "nvidia") [ nvidia-offload ];
|
|
|
|
|
|
|
|
hardware.nvidia.prime = mkIf cfg.prime {
|
|
|
|
offload.enable = true;
|
|
|
|
|
|
|
|
intelBusId = cfg.intelBusId;
|
|
|
|
nvidiaBusId = cfg.nvidiaBusId;
|
|
|
|
};
|
2020-12-26 23:36:50 +01:00
|
|
|
};
|
|
|
|
}
|