mirror of
https://github.com/Gerg-L/nixos.git
synced 2025-12-10 00:43:56 -05:00
bully the xserver module into submission
This commit is contained in:
parent
d54aee78da
commit
9f014f7dfa
2 changed files with 55 additions and 55 deletions
|
|
@ -41,11 +41,13 @@ Section "Device"
|
||||||
Identifier "nvidia"
|
Identifier "nvidia"
|
||||||
Driver "nvidia"
|
Driver "nvidia"
|
||||||
BusID "PCI:1:0:0"
|
BusID "PCI:1:0:0"
|
||||||
|
Option "SidebandSocketPath" "/run/nvidia-xdriver/"
|
||||||
EndSection
|
EndSection
|
||||||
|
|
||||||
Section "Screen"
|
Section "Screen"
|
||||||
Identifier "nvidia"
|
Identifier "nvidia"
|
||||||
Device "nvidia"
|
Device "nvidia"
|
||||||
|
Option "RandRRotation" "on"
|
||||||
Option "AllowEmptyInitialConfiguration"
|
Option "AllowEmptyInitialConfiguration"
|
||||||
EndSection
|
EndSection
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,36 +5,11 @@
|
||||||
config,
|
config,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
###TAKEN FROM HERE:https://github.com/NixOS/nixpkgs/blob/0e347b1a77a08ef429ea2bdf878eab6af99f90dc/nixos/modules/services/x11/xserver.nix#L106-L136
|
/*
|
||||||
|
This section is just me bullying
|
||||||
|
the xserver module to do what I want when I want it to
|
||||||
|
*/
|
||||||
let
|
let
|
||||||
xcfg = config.services.xserver;
|
|
||||||
xserverbase =
|
|
||||||
let
|
|
||||||
fontsForXServer = config.fonts.packages ++ [
|
|
||||||
pkgs.xorg.fontadobe100dpi
|
|
||||||
pkgs.xorg.fontadobe75dpi
|
|
||||||
];
|
|
||||||
fontpath = lib.optionalString (xcfg.fontPath != null) ''FontPath "${xcfg.fontPath}"'';
|
|
||||||
in
|
|
||||||
''
|
|
||||||
echo 'Section "Files"' >> $out
|
|
||||||
echo "${fontpath}" >> $out
|
|
||||||
for i in ${toString fontsForXServer}; do
|
|
||||||
if test "''${i:0:''${#NIX_STORE}}" == "$NIX_STORE"; then
|
|
||||||
for j in $(find $i -name fonts.dir); do
|
|
||||||
echo " FontPath \"$(dirname $j)\"" >> $out
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
${lib.concatMapStrings (m: ''
|
|
||||||
echo " ModulePath \"${m}/lib/xorg/modules\"" >> "$out"
|
|
||||||
'') xcfg.modules}
|
|
||||||
echo '${xcfg.filesSection}' >> $out
|
|
||||||
echo 'EndSection' >> $out
|
|
||||||
echo >> $out
|
|
||||||
'';
|
|
||||||
###END OF TAKEN PART
|
|
||||||
|
|
||||||
cfg_monitors = pkgs.writeShellApplication {
|
cfg_monitors = pkgs.writeShellApplication {
|
||||||
name = "cfg_monitors";
|
name = "cfg_monitors";
|
||||||
runtimeInputs = [
|
runtimeInputs = [
|
||||||
|
|
@ -52,23 +27,35 @@ let
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
environment.etc = {
|
environment.etc = {
|
||||||
"Xorg/1_mon.conf".source = pkgs.runCommand "1_mon.conf" { } (
|
"Xorg/1_mon.conf".source = "${self}/hosts/gerg-desktop/1_mon.conf";
|
||||||
xserverbase
|
"Xorg/2_mon.conf".source = "${self}/hosts/gerg-desktop/2_mon.conf";
|
||||||
+ ''
|
|
||||||
cat ${self}/hosts/gerg-desktop/1_mon.conf >> $out
|
|
||||||
''
|
|
||||||
);
|
|
||||||
"Xorg/2_mon.conf".source = pkgs.runCommand "2_mon.conf" { } (
|
|
||||||
xserverbase
|
|
||||||
+ ''
|
|
||||||
cat ${self}/hosts/gerg-desktop/1_mon.conf >> $out
|
|
||||||
''
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
services.xserver = {
|
||||||
|
config = lib.mkForce "";
|
||||||
|
|
||||||
|
displayManager.sessionCommands = lib.mkBefore ''
|
||||||
|
if ! [ -e "/etc/Xorg/ONE_MONITOR" ] ; then
|
||||||
|
${lib.getExe cfg_monitors}
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.tmpfiles.rules = [
|
||||||
|
"L /etc/X11/xorg.conf.d/99-custom.conf - - - - /etc/Xorg/2_mon.conf"
|
||||||
|
|
||||||
|
# Everything from here down is almost sane
|
||||||
|
"L+ /var/lib/libvirt/qemu/Windows.xml - - - - ${self}/hosts/gerg-desktop/Windows.xml"
|
||||||
|
];
|
||||||
|
|
||||||
boot = {
|
boot = {
|
||||||
kernelParams = [
|
kernelParams = [
|
||||||
"iommu=pt"
|
"iommu=pt"
|
||||||
"amd_iommu=on"
|
"amd_iommu=on"
|
||||||
|
/*
|
||||||
|
Switch to this if for a Intel cpu
|
||||||
|
"intel_iommu=on"
|
||||||
|
*/
|
||||||
"vfio_iommu_type1.allow_unsafe_interrupts=1"
|
"vfio_iommu_type1.allow_unsafe_interrupts=1"
|
||||||
"kvm.ignore_msrs=1"
|
"kvm.ignore_msrs=1"
|
||||||
];
|
];
|
||||||
|
|
@ -77,7 +64,7 @@ in
|
||||||
libvirtd = {
|
libvirtd = {
|
||||||
enable = true;
|
enable = true;
|
||||||
qemu = {
|
qemu = {
|
||||||
#don't hook evdev at vm start
|
# Patch to disable hooking the mouse via evdev at VM startup
|
||||||
package = pkgs.qemu_kvm.overrideAttrs (old: {
|
package = pkgs.qemu_kvm.overrideAttrs (old: {
|
||||||
patches = old.patches ++ [
|
patches = old.patches ++ [
|
||||||
(builtins.toFile "qemu.diff" ''
|
(builtins.toFile "qemu.diff" ''
|
||||||
|
|
@ -124,13 +111,6 @@ in
|
||||||
|
|
||||||
programs.virt-manager.enable = true;
|
programs.virt-manager.enable = true;
|
||||||
|
|
||||||
services.xserver.displayManager.xserverArgs = lib.mkAfter [ "-config /etc/Xorg/active.conf" ];
|
|
||||||
services.xserver.displayManager.sessionCommands = lib.mkBefore ''
|
|
||||||
if ! [ -e "/etc/Xorg/ONE_MONITOR" ] ; then
|
|
||||||
${lib.getExe cfg_monitors}
|
|
||||||
fi
|
|
||||||
|
|
||||||
'';
|
|
||||||
virtualisation.libvirtd.hooks.qemu = {
|
virtualisation.libvirtd.hooks.qemu = {
|
||||||
"AAA" = lib.getExe (
|
"AAA" = lib.getExe (
|
||||||
pkgs.writeShellApplication {
|
pkgs.writeShellApplication {
|
||||||
|
|
@ -151,28 +131,49 @@ in
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$OPERATION" == "prepare" ]; then
|
if [ "$OPERATION" == "prepare" ]; then
|
||||||
|
# Stop display-manager
|
||||||
systemctl stop display-manager.service
|
systemctl stop display-manager.service
|
||||||
|
|
||||||
|
# Un-bind driver
|
||||||
modprobe -r -a nvidia_uvm nvidia_drm nvidia nvidia_modeset
|
modprobe -r -a nvidia_uvm nvidia_drm nvidia nvidia_modeset
|
||||||
|
|
||||||
|
# Detach GPU
|
||||||
virsh nodedev-detach pci_0000_01_00_0
|
virsh nodedev-detach pci_0000_01_00_0
|
||||||
virsh nodedev-detach pci_0000_01_00_1
|
virsh nodedev-detach pci_0000_01_00_1
|
||||||
|
|
||||||
|
# Set allowed CPUs
|
||||||
systemctl set-property --runtime -- user.slice AllowedCPUs=8-15,24-31
|
systemctl set-property --runtime -- user.slice AllowedCPUs=8-15,24-31
|
||||||
systemctl set-property --runtime -- system.slice AllowedCPUs=8-15,24-31
|
systemctl set-property --runtime -- system.slice AllowedCPUs=8-15,24-31
|
||||||
systemctl set-property --runtime -- init.scope AllowedCPUs=8-15,24-31
|
systemctl set-property --runtime -- init.scope AllowedCPUs=8-15,24-31
|
||||||
ln -fs /etc/Xorg/1_mon.conf /etc/Xorg/active.conf
|
|
||||||
|
# Dual gpu/monitor stuff
|
||||||
|
ln -fs /etc/Xorg/1_mon.conf /etc/X11/xorg.conf.d/99-custom.conf
|
||||||
touch /etc/Xorg/ONE_MONITOR
|
touch /etc/Xorg/ONE_MONITOR
|
||||||
systemctl start display-manager.service
|
systemctl start display-manager.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$OPERATION" == "release" ]; then
|
if [ "$OPERATION" == "release" ]; then
|
||||||
|
|
||||||
|
# Dual gpu/monitor stuff
|
||||||
systemctl stop display-manager.service
|
systemctl stop display-manager.service
|
||||||
|
|
||||||
|
# Allow all CPUs
|
||||||
systemctl set-property --runtime -- user.slice AllowedCPUs=0-31
|
systemctl set-property --runtime -- user.slice AllowedCPUs=0-31
|
||||||
systemctl set-property --runtime -- system.slice AllowedCPUs=0-31
|
systemctl set-property --runtime -- system.slice AllowedCPUs=0-31
|
||||||
systemctl set-property --runtime -- init.scope AllowedCPUs=0-31
|
systemctl set-property --runtime -- init.scope AllowedCPUs=0-31
|
||||||
|
|
||||||
|
# Re-attach GPU
|
||||||
virsh nodedev-reattach pci_0000_01_00_0
|
virsh nodedev-reattach pci_0000_01_00_0
|
||||||
virsh nodedev-reattach pci_0000_01_00_1
|
virsh nodedev-reattach pci_0000_01_00_1
|
||||||
|
|
||||||
|
# Re-bind Driver
|
||||||
modprobe -a nvidia_uvm nvidia_drm nvidia nvidia_modeset
|
modprobe -a nvidia_uvm nvidia_drm nvidia nvidia_modeset
|
||||||
ln -fs /etc/Xorg/2_mon.conf /etc/Xorg/active.conf
|
|
||||||
|
# Dual gpu/monitor stuff
|
||||||
|
ln -fs /etc/Xorg/2_mon.conf /etc/X11/xorg.conf.d/99-custom.conf
|
||||||
rm /etc/Xorg/ONE_MONITOR
|
rm /etc/Xorg/ONE_MONITOR
|
||||||
|
|
||||||
|
# Restart display-manager
|
||||||
systemctl start display-manager.service
|
systemctl start display-manager.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -180,9 +181,6 @@ in
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
systemd.tmpfiles.rules = [
|
|
||||||
"L /etc/Xorg/active.conf - - - - /etc/Xorg/2_mon.conf"
|
|
||||||
"L+ /var/lib/libvirt/qemu/Windows.xml - - - - ${self}/hosts/gerg-desktop/Windows.xml"
|
|
||||||
];
|
|
||||||
#_file
|
#_file
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue