nixos/xserver: introduce attr display to xserver.drivers
Specifically for NVIDIA so that only the device section would be created
This commit is contained in:
parent
e8daa1e35c
commit
632a8a7bb2
|
@ -30,7 +30,7 @@ in
|
||||||
nixpkgs.config.xorg.abiCompat = "1.19";
|
nixpkgs.config.xorg.abiCompat = "1.19";
|
||||||
|
|
||||||
services.xserver.drivers = singleton
|
services.xserver.drivers = singleton
|
||||||
{ name = "amdgpu"; modules = [ package ]; };
|
{ name = "amdgpu"; modules = [ package ]; display = true; };
|
||||||
|
|
||||||
hardware.opengl.package = package;
|
hardware.opengl.package = package;
|
||||||
hardware.opengl.package32 = package32;
|
hardware.opengl.package32 = package32;
|
||||||
|
|
|
@ -21,7 +21,7 @@ in
|
||||||
nixpkgs.config.xorg.abiCompat = "1.17";
|
nixpkgs.config.xorg.abiCompat = "1.17";
|
||||||
|
|
||||||
services.xserver.drivers = singleton
|
services.xserver.drivers = singleton
|
||||||
{ name = "fglrx"; modules = [ ati_x11 ]; };
|
{ name = "fglrx"; modules = [ ati_x11 ]; display = true; };
|
||||||
|
|
||||||
hardware.opengl.package = ati_x11;
|
hardware.opengl.package = ati_x11;
|
||||||
hardware.opengl.package32 = pkgs.pkgsi686Linux.linuxPackages.ati_drivers_x11.override { libsOnly = true; kernel = null; };
|
hardware.opengl.package32 = pkgs.pkgsi686Linux.linuxPackages.ati_drivers_x11.override { libsOnly = true; kernel = null; };
|
||||||
|
|
|
@ -125,8 +125,7 @@ in
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
assertion = !syncCfg.enable ||
|
assertion = syncCfg.enable -> pCfg.nvidiaBusId != "" && pCfg.intelBusId != "";
|
||||||
(pCfg.nvidiaBusId != "" && pCfg.intelBusId != "");
|
|
||||||
message = ''
|
message = ''
|
||||||
When NVIDIA Optimus via PRIME is enabled, the GPU bus IDs must configured.
|
When NVIDIA Optimus via PRIME is enabled, the GPU bus IDs must configured.
|
||||||
'';
|
'';
|
||||||
|
@ -145,9 +144,17 @@ in
|
||||||
# - Configure the display manager to run specific `xrandr` commands which will
|
# - Configure the display manager to run specific `xrandr` commands which will
|
||||||
# configure/enable displays connected to the Intel GPU.
|
# configure/enable displays connected to the Intel GPU.
|
||||||
|
|
||||||
services.xserver.drivers = singleton {
|
services.xserver.drivers = optional syncCfg.enable {
|
||||||
|
name = "modesetting";
|
||||||
|
display = false;
|
||||||
|
deviceSection = ''
|
||||||
|
BusID "${pCfg.intelBusId}"
|
||||||
|
Option "AccelMethod" "none"
|
||||||
|
'';
|
||||||
|
} ++ singleton {
|
||||||
name = "nvidia";
|
name = "nvidia";
|
||||||
modules = [ nvidia_x11.bin ];
|
modules = [ nvidia_x11.bin ];
|
||||||
|
display = true;
|
||||||
deviceSection = optionalString syncCfg.enable
|
deviceSection = optionalString syncCfg.enable
|
||||||
''
|
''
|
||||||
BusID "${pCfg.nvidiaBusId}"
|
BusID "${pCfg.nvidiaBusId}"
|
||||||
|
@ -160,19 +167,9 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
services.xserver.extraConfig = optionalString syncCfg.enable
|
services.xserver.serverLayoutSection = optionalString syncCfg.enable ''
|
||||||
''
|
Inactive "Device-modesetting[0]"
|
||||||
Section "Device"
|
'';
|
||||||
Identifier "nvidia-optimus-intel"
|
|
||||||
Driver "modesetting"
|
|
||||||
BusID "${pCfg.intelBusId}"
|
|
||||||
Option "AccelMethod" "none"
|
|
||||||
EndSection
|
|
||||||
'';
|
|
||||||
services.xserver.serverLayoutSection = optionalString syncCfg.enable
|
|
||||||
''
|
|
||||||
Inactive "nvidia-optimus-intel"
|
|
||||||
'';
|
|
||||||
|
|
||||||
services.xserver.displayManager.setupCommands = optionalString syncCfg.enable ''
|
services.xserver.displayManager.setupCommands = optionalString syncCfg.enable ''
|
||||||
# Added by nvidia configuration module for Optimus/PRIME.
|
# Added by nvidia configuration module for Optimus/PRIME.
|
||||||
|
|
|
@ -574,7 +574,7 @@ in
|
||||||
then { modules = [xorg.${"xf86video" + name}]; }
|
then { modules = [xorg.${"xf86video" + name}]; }
|
||||||
else null)
|
else null)
|
||||||
knownVideoDrivers;
|
knownVideoDrivers;
|
||||||
in optional (driver != null) ({ inherit name; modules = []; driverName = name; } // driver));
|
in optional (driver != null) ({ inherit name; modules = []; driverName = name; display = true; } // driver));
|
||||||
|
|
||||||
assertions = [
|
assertions = [
|
||||||
{ assertion = config.security.polkit.enable;
|
{ assertion = config.security.polkit.enable;
|
||||||
|
@ -749,7 +749,7 @@ in
|
||||||
${cfg.serverLayoutSection}
|
${cfg.serverLayoutSection}
|
||||||
# Reference the Screen sections for each driver. This will
|
# Reference the Screen sections for each driver. This will
|
||||||
# cause the X server to try each in turn.
|
# cause the X server to try each in turn.
|
||||||
${flip concatMapStrings cfg.drivers (d: ''
|
${flip concatMapStrings (filter (d: d.display) cfg.drivers) (d: ''
|
||||||
Screen "Screen-${d.name}[0]"
|
Screen "Screen-${d.name}[0]"
|
||||||
'')}
|
'')}
|
||||||
EndSection
|
EndSection
|
||||||
|
@ -773,42 +773,44 @@ in
|
||||||
${driver.deviceSection or ""}
|
${driver.deviceSection or ""}
|
||||||
${xrandrDeviceSection}
|
${xrandrDeviceSection}
|
||||||
EndSection
|
EndSection
|
||||||
|
${optionalString driver.display ''
|
||||||
|
|
||||||
Section "Screen"
|
Section "Screen"
|
||||||
Identifier "Screen-${driver.name}[0]"
|
Identifier "Screen-${driver.name}[0]"
|
||||||
Device "Device-${driver.name}[0]"
|
Device "Device-${driver.name}[0]"
|
||||||
${optionalString (cfg.monitorSection != "") ''
|
${optionalString (cfg.monitorSection != "") ''
|
||||||
Monitor "Monitor[0]"
|
Monitor "Monitor[0]"
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${cfg.screenSection}
|
${cfg.screenSection}
|
||||||
${driver.screenSection or ""}
|
${driver.screenSection or ""}
|
||||||
|
|
||||||
${optionalString (cfg.defaultDepth != 0) ''
|
${optionalString (cfg.defaultDepth != 0) ''
|
||||||
DefaultDepth ${toString cfg.defaultDepth}
|
DefaultDepth ${toString cfg.defaultDepth}
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${optionalString
|
${optionalString
|
||||||
(driver.name != "virtualbox" &&
|
(driver.name != "virtualbox" &&
|
||||||
(cfg.resolutions != [] ||
|
(cfg.resolutions != [] ||
|
||||||
cfg.extraDisplaySettings != "" ||
|
cfg.extraDisplaySettings != "" ||
|
||||||
cfg.virtualScreen != null))
|
cfg.virtualScreen != null))
|
||||||
(let
|
(let
|
||||||
f = depth:
|
f = depth:
|
||||||
''
|
''
|
||||||
SubSection "Display"
|
SubSection "Display"
|
||||||
Depth ${toString depth}
|
Depth ${toString depth}
|
||||||
${optionalString (cfg.resolutions != [])
|
${optionalString (cfg.resolutions != [])
|
||||||
"Modes ${concatMapStrings (res: ''"${toString res.x}x${toString res.y}"'') cfg.resolutions}"}
|
"Modes ${concatMapStrings (res: ''"${toString res.x}x${toString res.y}"'') cfg.resolutions}"}
|
||||||
${cfg.extraDisplaySettings}
|
${cfg.extraDisplaySettings}
|
||||||
${optionalString (cfg.virtualScreen != null)
|
${optionalString (cfg.virtualScreen != null)
|
||||||
"Virtual ${toString cfg.virtualScreen.x} ${toString cfg.virtualScreen.y}"}
|
"Virtual ${toString cfg.virtualScreen.x} ${toString cfg.virtualScreen.y}"}
|
||||||
EndSubSection
|
EndSubSection
|
||||||
'';
|
'';
|
||||||
in concatMapStrings f [8 16 24]
|
in concatMapStrings f [8 16 24]
|
||||||
)}
|
)}
|
||||||
|
|
||||||
EndSection
|
EndSection
|
||||||
|
''}
|
||||||
'')}
|
'')}
|
||||||
|
|
||||||
${xrandrMonitorSections}
|
${xrandrMonitorSections}
|
||||||
|
|
Loading…
Reference in a new issue