dotfiles

My PC Dotfiles & Website
commit 9063f6905078bfb46e71af0cf6a72a602713c317
parent ad214cb678555fe9e93b8bc51dd5a3636370f182
Author: maydayv7 <maydayv7@gmail.com>
Date:   Wed,  2 Oct 2024 14:52:32 +0530

refactor: Separate out VFIO settings

Also use NVIDIA Reverse Sync instead of Sync on `valkyrie`

Diffstat:

Mdevices/valkyrie/drivers.nix | 17++++-------------
Mfiles/gnome/settings/default.nix | 2+-
Mfiles/gnome/settings/extensions.nix | 1+
Mfiles/gnome/shortcuts.json | 6+++++-
Mmodules/hardware/mobile.nix | 2++
Mmodules/hardware/virtualisation/android.nix | 4++--
Mmodules/hardware/virtualisation/default.nix | 115++++++++++++++++++++++++-------------------------------------------------------
Amodules/hardware/virtualisation/vfio.nix | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8 files changed, 107 insertions(+), 98 deletions(-)

diff --git a/devices/valkyrie/drivers.nix b/devices/valkyrie/drivers.nix @@ -1,7 +1,6 @@ { config, lib, - pkgs, ... }: let inherit (lib) mkForce; @@ -13,6 +12,8 @@ in { xserver.videoDrivers = mkForce ["nvidia"]; }; + #!# Run 'amixer -c 2 sset "Internal Mic Boost" 0' if microphone is garbled + hardware = { vm.passthrough = ["10de:28e0" "10de:22be"]; nvidia = { @@ -20,7 +21,8 @@ in { prime = { nvidiaBusId = mkForce "PCI:1:0:0"; amdgpuBusId = mkForce "PCI:101:0:0"; - sync.enable = mkForce mode; + sync.enable = false; + reverseSync.enable = mkForce mode; offload = { enable = mkForce (!mode); enableOffloadCmd = mkForce (!mode); @@ -28,15 +30,4 @@ in { }; }; }; - - user.homeConfig.home.file.".config/autostart/mic-boost.desktop".text = '' - [Desktop Entry] - Type=Application - Name=mic-boost - Exec=${pkgs.writeShellApplication { - name = "mic"; - text = "amixer -c 2 sset 'Internal Mic Boost' 0"; - runtimeInputs = with pkgs; [alsa-utils]; - }}/bin/mic - ''; } diff --git a/files/gnome/settings/default.nix b/files/gnome/settings/default.nix @@ -71,7 +71,7 @@ in { "org/gnome/settings-daemon/plugins/media-keys" = { area-screenshot = ["Print"]; area-screenshot-clip = []; - control-center = ["<Super>i"]; + control-center = ["<Super>s"]; email = ["<Super>e"]; home = ["<Super>f"]; magnifier = ["<Super>x"]; diff --git a/files/gnome/settings/extensions.nix b/files/gnome/settings/extensions.nix @@ -16,6 +16,7 @@ {package = gsconnect;} {package = guillotine;} {package = hide-minimized;} + {package = invert-window-color;} {package = media-progress;} {package = overview-hover;} {package = removable-drive-menu;} diff --git a/files/gnome/shortcuts.json b/files/gnome/shortcuts.json @@ -179,7 +179,7 @@ "description": "Shows Open apps" }, { - "key": "Super + I", + "key": "Super + S", "description": "Open Settings" }, { @@ -216,6 +216,10 @@ "name": "Application Shortcuts", "shortcuts": [ { + "key": "Super + I", + "description": "Invert window colors" + }, + { "key": "Ctrl + W", "description": "Close tab in tab enabled apps" }, diff --git a/modules/hardware/mobile.nix b/modules/hardware/mobile.nix @@ -17,5 +17,7 @@ in { # File Transfer services.usbmuxd.enable = true; environment.systemPackages = [pkgs.libimobiledevice]; + + #!# Run 'systemctl restart usbmuxd.service' if it doesn't work }; } diff --git a/modules/hardware/virtualisation/android.nix b/modules/hardware/virtualisation/android.nix @@ -27,11 +27,11 @@ in { - Use the mainline/LTS kernel for assured support ''; - #!# Run the following command to install the image: - #!# waydroid init -s GAPPS -f virtualisation.waydroid.enable = true; environment.systemPackages = [pkgs.wl-clipboard]; + #!# Run 'waydroid init -s GAPPS -f' to install the image + # Environment Setup users.groups.android = { name = "android"; diff --git a/modules/hardware/virtualisation/default.nix b/modules/hardware/virtualisation/default.nix @@ -1,97 +1,50 @@ { config, lib, + util, pkgs, ... }: let - inherit (builtins) concatStringsSep elem; - inherit (lib) mkEnableOption mkForce mkIf mkMerge mkOption types; - enable = elem "virtualisation" config.hardware.support; - cfg = config.hardware.vm; + enable = builtins.elem "virtualisation" config.hardware.support; in { - imports = [./android.nix]; + imports = util.map.modules.list ./.; - options.hardware.vm = { - vfio = mkEnableOption "Configure the device for VFIO"; - passthrough = mkOption { - description = "PCI Device IDs for VFIO"; - type = types.listOf types.str; - default = []; - example = [ - "10de:28e0" # Graphics - "10de:22be" # Audio - ]; + ## Virtualisation Settings ## + config = lib.mkIf enable { + # Environment Setup + user.groups = ["kvm" "libvirtd"]; + user.persist.directories = [".config/libvirt" ".local/share/libvirt"]; + environment.persist.directories = ["/var/lib/libvirt"]; + security.virtualisation.flushL1DataCache = "cond"; + boot = { + kernelModules = ["kvm-amd" "kvm-intel"]; + extraModprobeConfig = "options kvm_intel nested=1"; }; - }; - ## Virtualisation Settings ## - config = mkIf enable (mkMerge [ - { - # Environment Setup - user.groups = ["kvm" "libvirtd"]; - user.persist.directories = [".config/libvirt" ".local/share/libvirt"]; - environment.persist.directories = ["/var/lib/libvirt"]; - security.virtualisation.flushL1DataCache = "cond"; - boot = { - kernelModules = ["kvm-amd" "kvm-intel"]; - extraModprobeConfig = "options kvm_intel nested=1"; - }; + # VM Packages + environment.systemPackages = with pkgs; [libguestfs virtiofsd]; + programs.virt-manager.enable = true; - # VM Packages - environment.systemPackages = with pkgs; [libguestfs virtiofsd]; - programs.virt-manager.enable = true; + #!# Run 'virsh net-start default' to start network service - # VM Utilities - virtualisation = { - kvmgt.enable = true; - spiceUSBRedirection.enable = true; - libvirtd = { - enable = true; - onBoot = "ignore"; - onShutdown = "shutdown"; - qemu = { - package = pkgs.qemu_kvm; - runAsRoot = false; - swtpm.enable = true; - ovmf = { - enable = true; - packages = [pkgs.OVMFFull.fd]; - }; + # VM Utilities + virtualisation = { + kvmgt.enable = true; + spiceUSBRedirection.enable = true; + libvirtd = { + enable = true; + onBoot = "ignore"; + onShutdown = "shutdown"; + qemu = { + package = pkgs.qemu_kvm; + runAsRoot = false; + swtpm.enable = true; + ovmf = { + enable = true; + packages = [pkgs.OVMFFull.fd]; }; }; }; - - # VFIO Configuration - specialisation.vfio.configuration.hardware = { - vm.vfio = true; - cpu.mode = mkForce "performance"; - }; - } - (mkIf cfg.vfio { - system.nixos.tags = ["vfio"]; - boot = { - kernelParams = [ - "amd_iommu=pt" - "intel_iommu=pt" - "i915.enable_gvt=1" - "iommu=pt" - "kvm.ignore_msrs=1" - "kvm.report_ignored_msrs=0" - ("vfio-pci.ids=" + concatStringsSep "," cfg.passthrough) - ]; - - kernelModules = [ - "vfio" - "vfio_pci" - "vfio_iommu_type1" - "vfio_virqfd" - - "nvidia" - "nvidia_modeset" - "nvidia_uvm" - "nvidia_drm" - ]; - }; - }) - ]); + }; + }; } diff --git a/modules/hardware/virtualisation/vfio.nix b/modules/hardware/virtualisation/vfio.nix @@ -0,0 +1,58 @@ +{ + config, + lib, + ... +}: let + inherit (builtins) concatStringsSep elem; + inherit (lib) mkEnableOption mkForce mkIf mkOption optionals types; + enable = elem "virtualisation" config.hardware.support; + cfg = config.hardware.vm; +in { + options.hardware.vm = { + vfio = mkEnableOption "Configure the device for VFIO"; + passthrough = mkOption { + description = "PCI Device IDs for VFIO"; + type = types.listOf types.str; + default = []; + example = [ + "10de:28e0" # Graphics + "10de:22be" # Audio + ]; + }; + }; + + ## VFIO Configuration ## + config = mkIf (enable && cfg.vfio) { + specialisation.vfio.configuration.hardware = { + vm.vfio = true; + cpu.mode = mkForce "performance"; + }; + + system.nixos.tags = ["vfio"]; + boot = { + kernelParams = [ + "amd_iommu=pt" + "intel_iommu=pt" + "i915.enable_gvt=1" + "iommu=pt" + "kvm.ignore_msrs=1" + "kvm.report_ignored_msrs=0" + ("vfio-pci.ids=" + concatStringsSep "," cfg.passthrough) + ]; + + kernelModules = + [ + "vfio" + "vfio_pci" + "vfio_iommu_type1" + "vfio_virqfd" + ] + ++ optionals (elem "nvidia" config.services.xserver.videoDrivers) [ + "nvidia" + "nvidia_modeset" + "nvidia_uvm" + "nvidia_drm" + ]; + }; + }; +}