dotfiles

My PC Dotfiles & Website
commit 3d908333fdfda9d8b41a79ac9059148bfe63b7dd
parent 5aaed1529152526e9889f7cb4d56860d116ea72b
Author: maydayv7 <maydayv7@gmail.com>
Date:   Sat,  9 Nov 2024 01:44:32 +0530

feat: QOL Improvements

+ Fix `valkyrie` Problems
+ Improve VFIO Setup
+ GNOME Improvements

Diffstat:

Mdevices/valkyrie/default.nix | 8++++++--
Mdevices/valkyrie/drivers.nix | 94+++++++++++++++++++++++++++++++++++++++++++++++++------------------------------
Mfiles/gnome/menu.json | 29++++++++++++++++++++++++++---
Mfiles/gnome/settings/default.nix | 28+++++-----------------------
Mfiles/gnome/settings/extensions.nix | 55++++++++++++++++++++++++++++++++++++++++++++++++-------
Mfiles/repl.nix | 2+-
Mflake.lock | 6+++---
Mmodules/gui/desktop/gnome/default.nix | 3++-
Mmodules/hardware/README.md | 4++--
Mmodules/hardware/virtualisation/vfio.nix | 26++++++++++++++++++--------
Mmodules/nix/default.nix | 4++--
11 files changed, 171 insertions(+), 88 deletions(-)

diff --git a/devices/valkyrie/default.nix b/devices/valkyrie/default.nix @@ -16,11 +16,15 @@ filesystem = "advanced"; support = ["laptop" "mobile" "printer" "virtualisation"]; modules = ["asus-zephyrus-ga402x-nvidia"]; - vm.android.enable = true; cpu = { cores = 8; mode = "performance"; }; + + vm = { + vfio = "on"; + android.enable = true; + }; }; shell.utilities = true; @@ -52,7 +56,7 @@ user = { name = "v7"; description = "V 7"; - groups = ["wheel" "keys"]; + groups = ["wheel" "keys" "systemd-journal"]; uid = 1000; shell = "zsh"; shells = ["bash"]; diff --git a/devices/valkyrie/drivers.nix b/devices/valkyrie/drivers.nix @@ -3,48 +3,20 @@ lib, ... }: let - inherit (lib) mkForce; + inherit (lib) hasPrefix mkForce mkIf; + enable = config.hardware.vm.vfio != "on"; mode = config.hardware.cpu.mode == "performance"; in { - user.persist.directories = [".config/rog"]; - boot.kernelParams = ["nvidia_drm.fbdev=1"]; - services = { - fwupd.enable = true; - xserver.videoDrivers = mkForce ["nvidia"]; - udev.extraHwdb = '' - evdev:name:Asus Keyboard:* - KEYBOARD_KEY_7003f=print - ''; - - asusd = { - enable = true; - enableUserService = true; - asusdConfig = '' - ( - boot_sound: false, - change_throttle_policy_on_ac: true, - change_throttle_policy_on_battery: true, - charge_control_end_threshold: 95, - disable_nvidia_powerd_on_battery: true, - mini_led_mode: false, - panel_od: false, - throttle_balanced_epp: BalancePower, - throttle_performance_epp: Performance, - throttle_policy_linked_epp: true, - throttle_policy_on_ac: Performance, - throttle_policy_on_battery: Quiet, - throttle_quiet_epp: Power, - )''; - }; - }; - - #!# Run 'amixer -c <device> sset "Internal Mic Boost" 0' if microphone is garbled + services.fwupd.enable = true; + # Discrete GPU + boot.kernelParams = ["nvidia_drm.fbdev=1"]; + services.xserver.videoDrivers = mkForce ["nvidia"]; hardware = { vm.passthrough = ["10de:28e0" "10de:22be"]; nvidia = { - dynamicBoost.enable = true; - powerManagement.enable = true; + dynamicBoost = {inherit enable;}; + powerManagement = {inherit enable;}; prime = { nvidiaBusId = mkForce "PCI:1:0:0"; amdgpuBusId = mkForce "PCI:101:0:0"; @@ -58,4 +30,54 @@ in { }; }; }; + + # Remap Keys + services.udev.extraHwdb = '' + evdev:name:Asus Keyboard:* + KEYBOARD_KEY_7003f=print # F6 -> PrtSc Key + ''; + + # ASUS Software + user.persist.directories = [".config/rog"]; + services.asusd = { + enable = true; + enableUserService = true; + asusdConfig = '' + ( + boot_sound: false, + change_throttle_policy_on_ac: true, + change_throttle_policy_on_battery: true, + charge_control_end_threshold: 95, + disable_nvidia_powerd_on_battery: true, + mini_led_mode: false, + panel_od: false, + throttle_balanced_epp: BalancePower, + throttle_performance_epp: Performance, + throttle_policy_linked_epp: true, + throttle_policy_on_ac: Performance, + throttle_policy_on_battery: Quiet, + throttle_quiet_epp: Power, + )''; + }; + + user.homeConfig.dconf.settings = mkIf (hasPrefix "gnome" config.gui.desktop) { + "org/gnome/settings-daemon/plugins/media-keys" = { + custom-keybindings = [ + "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3/" + "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom4/" + ]; + }; + + "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3" = { + binding = "Launch3"; + command = "asusctl led-mode -n"; + name = "Keyboard Mode"; + }; + + "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom4" = { + binding = "Launch4"; + command = "asusctl profile -n"; + name = "Fan Control"; + }; + }; } diff --git a/files/gnome/menu.json b/files/gnome/menu.json @@ -6,6 +6,29 @@ "menu": [ { "type": "submenu", + "title": "Audio", + "icon": "audio-headset-symbolic", + "items": [ + { + "type": "command", + "title": "Test Sound", + "command": "find /run/current-system/sw/share/sounds/alsa/ -name '*_*' -exec aplay {} \\;", + "instancing": "singleInstance", + "icon": "test-symbolic", + "killOnDisable": false + }, + { + "type": "command", + "title": "Microphone Boost", + "command": "sh -c 'VALUE=$(zenity --scale --text=\"Select Microphone Boost value\" --value=0 --min-value=0 --max-value=100 -–step=5); amixer -c 1 sset 'Mic Boost' $VALUE; amixer -c 1 sset 'Internal Mic Boost' $VALUE'", + "instancing": "singleInstance", + "icon": "microphone-symbolic", + "killOnDisable": false + } + ] + }, + { + "type": "submenu", "title": "File Management", "icon": "fileopen", "items": [ @@ -27,7 +50,7 @@ { "type": "switch", "title": "Android", - "icon": "application-x-addon-symbolic", + "icon": "goa-account-google-symbolic", "start": "sh -c 'nohup waydroid session start > /dev/null 2>&1&'", "stop": "waydroid session stop", "check": "sh -c 'waydroid status | grep RUNNING'", @@ -36,7 +59,7 @@ { "type": "switch", "title": "Windows", - "icon": "application-x-addon-symbolic", + "icon": "goa-account-msn-symbolic", "start": "virsh -c qemu:///system start Windows", "stop": "virsh -c qemu:///system shutdown Windows", "check": "sh -c 'virsh -c qemu:///system list | grep Windows'", @@ -55,7 +78,7 @@ "command": "xdg-open .config/guillotine.json", "instancing": "singleInstance", "icon": "preferences-other-symbolic", - "killOnDisable": false + "killOnDisable": true }, { "type": "command", diff --git a/files/gnome/settings/default.nix b/files/gnome/settings/default.nix @@ -6,7 +6,6 @@ }: with lib.hm.gvariant; let fonts = sys.fonts.fontconfig.defaultFonts; - asus = sys.services.asusd.enable; in { imports = util.map.modules.list ./.; @@ -93,16 +92,11 @@ in { window-screenshot = ["<Primary>Print"]; window-screenshot-clip = []; www = ["<Super>w"]; - custom-keybindings = - [ - "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/" - "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/" - "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2/" - ] - ++ lib.optionals asus [ - "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3/" - "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom4/" - ]; + custom-keybindings = [ + "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/" + "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/" + "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2/" + ]; }; "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0" = { @@ -123,18 +117,6 @@ in { name = "Text Editor"; }; - "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3" = lib.mkIf asus { - binding = "Launch3"; - command = "asusctl led-mode -n"; - name = "Keyboard Mode"; - }; - - "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom4" = lib.mkIf asus { - binding = "Launch4"; - command = "asusctl profile -n"; - name = "Fan Control"; - }; - "org/gnome/desktop/wm/preferences" = { button-layout = "appmenu:minimize,maximize,close"; focus-mode = "click"; diff --git a/files/gnome/settings/extensions.nix b/files/gnome/settings/extensions.nix @@ -17,6 +17,7 @@ extensions = with pkgs.gnomeExtensions // hm.gvariant; ([ {package = appindicator;} {package = control-monitor-brightness-and-volume-with-ddcutil;} + {package = latest.display-configuration-switcher;} {package = gamemode-indicator-in-system-settings;} {package = gsconnect;} {package = guillotine;} @@ -37,7 +38,7 @@ { package = top-bar-organizer; settings = { - center-box-order = ["dateMenu"]; + center-box-order = []; left-box-order = [ "WorkspaceMenu" "activities" @@ -62,6 +63,7 @@ "screenSharing" "screenRecording" "quickSettings" + "dateMenu" ]; }; } @@ -83,10 +85,19 @@ package = window-title-is-back; settings = { colored-icon = true; + show-icon = false; show-title = false; }; } { + package = latest.autohide-battery-percentage; + settings = { + hide-on-battery-level = 90; + hide-on-plugged-in = true; + hide-on-power-saving-disabled = false; + }; + } + { package = latest.emoji-copy; settings = { active-keybind = true; @@ -127,12 +138,13 @@ { package = shortcuts; settings = { - maxcolumns = 3; + maxcolumns = 4; shortcuts-file = files.gnome.shortcuts; shortcuts-toggle-overview = ["<Super>slash"]; + show-icon = false; use-custom-shortcuts = true; use-transparency = true; - visibility = 50; + visibility = 55; }; } { @@ -168,6 +180,35 @@ }; } { + package = rocketbar; + settings = { + appbutton-backlight-dominant-color = false; + appbutton-enable-drag-and-drop = true; + appbutton-enable-indicators = true; + appbutton-enable-minimize-action = true; + appbutton-enable-scroll = true; + appbutton-enable-sound-control = false; + appbutton-icon-size = 21; + appbutton-menu-require-click = true; + hotcorner-enable-in-fullscreen = false; + indicator-dominant-color-active = true; + indicator-dominant-color-inactive = false; + indicator-position = "top"; + notification-counter-center-clock = false; + notification-counter-enabled = true; + notification-counter-hide-empty = false; + notification-service-count-attention-sources = false; + notification-service-enable-unity-dbus = true; + overview-enable-empty-space-clicks = false; + panel-enable-middle-button = false; + panel-menu-require-click = false; + taskbar-enabled = true; + taskbar-position = "center"; + taskbar-preserve-position = true; + taskbar-show-favorites = false; + }; + } + { package = pkgs.custom.gnome-paperwm; settings = { @@ -295,7 +336,7 @@ dash-bg-opacity = 50; dash-bg-radius = 0; dash-icon-scroll = 1; - dash-isolate-workspaces = true; + dash-isolate-workspaces = false; dash-max-icon-size = 64; dash-module = true; dash-position = 2; @@ -314,8 +355,8 @@ message-tray-module = true; new-window-focus-fix = false; new-window-monitor-fix = false; - notification-position = 1; - osd-position = 6; + notification-position = 2; + osd-position = 3; osd-window-module = true; overlay-key-module = true; overlay-key-primary = 1; @@ -344,7 +385,7 @@ secondary-ws-preview-shift = false; secondary-ws-thumbnail-scale = 5; secondary-ws-thumbnails-position = 2; - show-app-icon-position = 1; + show-app-icon-position = 0; show-bg-in-overview = true; show-search-entry = false; show-ws-preview-bg = false; diff --git a/files/repl.nix b/files/repl.nix @@ -2,7 +2,7 @@ path ? /etc/nixos, host ? false, }: let - inherit (builtins) currentSystem getFlake head match pathExists readFile removeAttrs; + inherit (builtins) currentSystem getFlake head match pathExists readFile removeAttrs toString; flake = if pathExists "${path}/flake.nix" diff --git a/flake.lock b/flake.lock @@ -1082,11 +1082,11 @@ }, "unstable": { "locked": { - "lastModified": 1730200266, - "narHash": "sha256-l253w0XMT8nWHGXuXqyiIC/bMvh1VRszGXgdpQlfhvU=", + "lastModified": 1730531603, + "narHash": "sha256-Dqg6si5CqIzm87sp57j5nTaeBbWhHFaVyG7V6L8k3lY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "807e9154dcb16384b1b765ebe9cd2bba2ac287fd", + "rev": "7ffd9ae656aec493492b44d0ddfb28e79a1ea25d", "type": "github" }, "original": { diff --git a/modules/gui/desktop/gnome/default.nix b/modules/gui/desktop/gnome/default.nix @@ -7,8 +7,8 @@ ... } @ args: with files; let - inherit (config.gui) desktop; inherit (lib) gvariant hasPrefix mkIf mkForce mkMerge; + inherit (config.gui) desktop; exists = app: builtins.elem app config.apps.list; in { ## GNOME Configuration ## @@ -152,6 +152,7 @@ in { gnome-sound-recorder gnome-text-editor gnome-tweaks + zenity # GNOME Games gnome-chess diff --git a/modules/hardware/README.md b/modules/hardware/README.md @@ -31,9 +31,9 @@ Use [`scripts/pci.sh`](../../scripts/pci.sh) in order to determine the PCI Devic #### Windows Virtualisation -In order to create a highly performant Windows VM using the `virt-manager` GUI and [Virtio](https://wiki.libvirt.org/Virtio.html) drivers, follow the instructions given on [this](https://sysguides.com/install-a-windows-11-virtual-machine-on-kvm) page. To configure GPU passthrough, add the relevant GPU and audio IDs to `hardware.vm.passthrough` (See the [Arch Wiki](https://wiki.archlinux.org/title/PCI_passthrough_via_OVMF) for additional information), and enable `hardware.vm.vfio`. Confirm that the GPU is recognized within the Windows VM, and download the relevant drivers. In order to utilize full graphical bandwidth, one of the following must be done: +In order to create a highly performant Windows VM using the `virt-manager` GUI and [Virtio](https://wiki.libvirt.org/Virtio.html) drivers, follow the instructions given on [this](https://sysguides.com/install-a-windows-11-virtual-machine-on-kvm) page. To configure GPU passthrough, add the relevant GPU and audio IDs to `hardware.vm.passthrough` (See the [Arch Wiki](https://wiki.archlinux.org/title/PCI_passthrough_via_OVMF) for additional information), and set `hardware.vm.vfio` to `"on"`. Confirm that the GPU is recognized within the Windows VM, and download the relevant drivers. In order to utilize full graphical bandwidth, one of the following must be done: 1. Connecting an external monitor to the GPU 2. Using a dummy monitor plug or faking a display using [`Virtual Display Driver`](https://github.com/itsmikethetech/Virtual-Display-Driver), then using [Looking Glass](https://looking-glass.io/) to extract video output onto the main monitor. The configuration for Looking Glass on the Linux (client) side is already implemented, and only the Windows (host) needs to be configured by following instructions on [this](https://looking-glass.io/docs/stable/install/) page -The `vfio` Specialisation can be selected in the boot menu to enable GPU passthrough when required +The `vfio` Specialisation can be selected in the boot menu to enable GPU passthrough when required (when `hardware.vm.vfio` is set to `"setup"`) diff --git a/modules/hardware/virtualisation/vfio.nix b/modules/hardware/virtualisation/vfio.nix @@ -5,12 +5,17 @@ ... }: let inherit (builtins) concatStringsSep elem; - inherit (lib) generators mkEnableOption mkForce mkIf mkMerge mkOption optionals types; + inherit (lib) generators mkForce mkIf mkMerge mkOption optionals types; enable = elem "virtualisation" config.hardware.support; cfg = config.hardware.vm; in { options.hardware.vm = { - vfio = mkEnableOption "Configure VFIO PCI passthrough"; + vfio = mkOption { + description = "Configure VFIO PCI passthrough"; + type = types.enum ["on" "off" "setup"]; + default = "off"; + }; + passthrough = mkOption { description = "PCI Device IDs for VFIO"; type = types.listOf types.str; @@ -23,18 +28,23 @@ in { }; ## VFIO Configuration ## - config = mkMerge [ - (mkIf enable { + config = mkIf (enable && cfg.vfio != "") (mkMerge [ + { specialisation.vfio.configuration = { system.nixos.label = "special.vfio"; hardware = { - vm.vfio = true; + vm.vfio = mkForce "on"; cpu.mode = mkForce "performance"; }; }; - }) + } + + (mkIf (cfg.vfio == "on") { + specialisation.no-vfio.configuration = { + system.nixos.label = "special.no-vfio"; + hardware.vm.vfio = mkForce "setup"; + }; - (mkIf (enable && cfg.vfio) { boot = { kernelParams = [ "amd_iommu=pt" @@ -107,5 +117,5 @@ in { }; }; }) - ]; + ]); } diff --git a/modules/nix/default.nix b/modules/nix/default.nix @@ -32,8 +32,8 @@ accept-flake-config = true warn-dirty = false experimental-features = nix-command flakes recursive-nix - min-free = ${toString (1024 * 1024 * 1024)} - max-free = ${toString (10 * 1024 * 1024 * 1024)} + min-free = ${builtins.toString (1024 * 1024 * 1024)} + max-free = ${builtins.toString (10 * 1024 * 1024 * 1024)} ''; }; };