mirror of
https://github.com/Gerg-L/nixos.git
synced 2025-12-10 00:43:56 -05:00
treewide reformat
This commit is contained in:
parent
de7683556e
commit
fc21bf9436
42 changed files with 1012 additions and 876 deletions
|
|
@ -1,4 +1,5 @@
|
|||
_: {
|
||||
_:
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
|
|
@ -7,55 +8,61 @@ _: {
|
|||
###TAKEN FROM HERE:https://github.com/NixOS/nixpkgs/blob/4787ebf7ae2ab071389be7ff86cf38edeee7e9f8/nixos/modules/services/x11/xserver.nix#L106-L136
|
||||
let
|
||||
xcfg = config.services.xserver;
|
||||
xserverbase = let
|
||||
fontsForXServer =
|
||||
config.fonts.packages
|
||||
++ [
|
||||
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
|
||||
for i in $(find ${toString xcfg.modules} -type d); do
|
||||
if test $(echo $i/*.so* | wc -w) -ne 0; then
|
||||
echo " ModulePath \"$i\"" >> $out
|
||||
fi
|
||||
done
|
||||
echo '${xcfg.filesSection}' >> $out
|
||||
echo 'EndSection' >> $out
|
||||
echo >> $out
|
||||
'';
|
||||
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
|
||||
for i in $(find ${toString xcfg.modules} -type d); do
|
||||
if test $(echo $i/*.so* | wc -w) -ne 0; then
|
||||
echo " ModulePath \"$i\"" >> $out
|
||||
fi
|
||||
done
|
||||
echo '${xcfg.filesSection}' >> $out
|
||||
echo 'EndSection' >> $out
|
||||
echo >> $out
|
||||
'';
|
||||
###END OF TAKEN PART
|
||||
|
||||
cfg_monitors = pkgs.writeShellApplication {
|
||||
name = "cfg_monitors";
|
||||
runtimeInputs = [pkgs.xorg.xrandr pkgs.xorg.xset pkgs.gawk pkgs.gnugrep];
|
||||
runtimeInputs = [
|
||||
pkgs.xorg.xrandr
|
||||
pkgs.xorg.xset
|
||||
pkgs.gawk
|
||||
pkgs.gnugrep
|
||||
];
|
||||
text = ''
|
||||
xrandr --output DP-0 --auto --mode 3440x1440 --rate 120 --primary --pos 0x0
|
||||
xrandr --output "$(xrandr | grep -e 'HDMI.* connected.*'| awk '{ print$1 }')" --auto --mode 1920x1080 --rate 144 --set TearFree on --pos 3440x360
|
||||
xset -dpms
|
||||
'';
|
||||
};
|
||||
in {
|
||||
in
|
||||
{
|
||||
environment.etc = {
|
||||
"Xorg/1_mon.conf".source = pkgs.runCommand "1_mon.conf" {} (
|
||||
"Xorg/1_mon.conf".source = pkgs.runCommand "1_mon.conf" { } (
|
||||
xserverbase
|
||||
+ ''
|
||||
cat ${./1_mon.conf} >> $out
|
||||
''
|
||||
);
|
||||
"Xorg/2_mon.conf".source = pkgs.runCommand "2_mon.conf" {} (
|
||||
"Xorg/2_mon.conf".source = pkgs.runCommand "2_mon.conf" { } (
|
||||
xserverbase
|
||||
+ ''
|
||||
cat ${./2_mon.conf} >> $out
|
||||
|
|
@ -74,10 +81,9 @@ in {
|
|||
enable = true;
|
||||
qemu = {
|
||||
#don't hook evdev at vm start
|
||||
package = pkgs.qemu_kvm.overrideAttrs (old: {
|
||||
patches =
|
||||
old.patches
|
||||
++ [
|
||||
package = pkgs.qemu_kvm.overrideAttrs (
|
||||
old: {
|
||||
patches = old.patches ++ [
|
||||
(pkgs.writeText "qemu.diff" ''
|
||||
diff --git a/ui/input-linux.c b/ui/input-linux.c
|
||||
index e572a2e..a9d76ba 100644
|
||||
|
|
@ -98,7 +104,8 @@ in {
|
|||
return;
|
||||
'')
|
||||
];
|
||||
});
|
||||
}
|
||||
);
|
||||
runAsRoot = true;
|
||||
ovmf.enable = true;
|
||||
verbatimConfig = ''
|
||||
|
|
@ -123,9 +130,14 @@ in {
|
|||
|
||||
programs.dconf.enable = true;
|
||||
|
||||
users.users.gerg.extraGroups = ["kvm" "libvirtd"];
|
||||
users.users.gerg.extraGroups = [
|
||||
"kvm"
|
||||
"libvirtd"
|
||||
];
|
||||
|
||||
services.xserver.displayManager.xserverArgs = lib.mkAfter ["-config /etc/Xorg/active.conf"];
|
||||
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}
|
||||
|
|
@ -133,47 +145,53 @@ in {
|
|||
|
||||
'';
|
||||
|
||||
systemd.tmpfiles.rules = let
|
||||
qemuHook = pkgs.writeShellApplication {
|
||||
name = "qemu-hook";
|
||||
systemd.tmpfiles.rules =
|
||||
let
|
||||
qemuHook = pkgs.writeShellApplication {
|
||||
name = "qemu-hook";
|
||||
|
||||
runtimeInputs = [pkgs.libvirt pkgs.systemd pkgs.kmod];
|
||||
text = ''
|
||||
GUEST_NAME="$1"
|
||||
OPERATION="$2"
|
||||
runtimeInputs = [
|
||||
pkgs.libvirt
|
||||
pkgs.systemd
|
||||
pkgs.kmod
|
||||
];
|
||||
text = ''
|
||||
GUEST_NAME="$1"
|
||||
OPERATION="$2"
|
||||
|
||||
if [ "$GUEST_NAME" == "Windows" ]; then
|
||||
if [ "$OPERATION" == "prepare" ]; then
|
||||
if [ "$GUEST_NAME" == "Windows" ]; then
|
||||
if [ "$OPERATION" == "prepare" ]; then
|
||||
systemctl stop display-manager.service
|
||||
modprobe -r -a nvidia_uvm nvidia_drm nvidia nvidia_modeset
|
||||
virsh nodedev-detach pci_0000_01_00_0
|
||||
virsh nodedev-detach pci_0000_01_00_1
|
||||
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 -- init.scope AllowedCPUs=8-15,24-31
|
||||
ln -fs /etc/Xorg/1_mon.conf /etc/Xorg/active.conf
|
||||
touch /etc/Xorg/ONE_MONITOR
|
||||
systemctl start display-manager.service
|
||||
fi
|
||||
if [ "$OPERATION" == "release" ]; then
|
||||
systemctl stop display-manager.service
|
||||
modprobe -r -a nvidia_uvm nvidia_drm nvidia nvidia_modeset
|
||||
virsh nodedev-detach pci_0000_01_00_0
|
||||
virsh nodedev-detach pci_0000_01_00_1
|
||||
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 -- init.scope AllowedCPUs=8-15,24-31
|
||||
ln -fs /etc/Xorg/1_mon.conf /etc/Xorg/active.conf
|
||||
touch /etc/Xorg/ONE_MONITOR
|
||||
systemctl set-property --runtime -- user.slice AllowedCPUs=0-31
|
||||
systemctl set-property --runtime -- system.slice AllowedCPUs=0-31
|
||||
systemctl set-property --runtime -- init.scope AllowedCPUs=0-31
|
||||
virsh nodedev-reattach pci_0000_01_00_0
|
||||
virsh nodedev-reattach pci_0000_01_00_1
|
||||
modprobe -a nvidia_uvm nvidia_drm nvidia nvidia_modeset
|
||||
ln -fs /etc/Xorg/2_mon.conf /etc/Xorg/active.conf
|
||||
rm /etc/Xorg/ONE_MONITOR
|
||||
systemctl start display-manager.service
|
||||
fi
|
||||
fi
|
||||
if [ "$OPERATION" == "release" ]; then
|
||||
systemctl stop display-manager.service
|
||||
systemctl set-property --runtime -- user.slice AllowedCPUs=0-31
|
||||
systemctl set-property --runtime -- system.slice AllowedCPUs=0-31
|
||||
systemctl set-property --runtime -- init.scope AllowedCPUs=0-31
|
||||
virsh nodedev-reattach pci_0000_01_00_0
|
||||
virsh nodedev-reattach pci_0000_01_00_1
|
||||
modprobe -a nvidia_uvm nvidia_drm nvidia nvidia_modeset
|
||||
ln -fs /etc/Xorg/2_mon.conf /etc/Xorg/active.conf
|
||||
rm /etc/Xorg/ONE_MONITOR
|
||||
systemctl start display-manager.service
|
||||
fi
|
||||
fi
|
||||
'';
|
||||
};
|
||||
in [
|
||||
"L /etc/Xorg/active.conf - - - - /etc/Xorg/2_mon.conf"
|
||||
"C /var/lib/libvirt/hooks/qemu - - - - ${lib.getExe qemuHook}"
|
||||
"C /var/lib/libvirt/qemu/Windows.xml - - - - ${./Windows.xml}"
|
||||
];
|
||||
'';
|
||||
};
|
||||
in
|
||||
[
|
||||
"L /etc/Xorg/active.conf - - - - /etc/Xorg/2_mon.conf"
|
||||
"C /var/lib/libvirt/hooks/qemu - - - - ${lib.getExe qemuHook}"
|
||||
"C /var/lib/libvirt/qemu/Windows.xml - - - - ${./Windows.xml}"
|
||||
];
|
||||
_file = ./vfio.nix;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue