From 1ac8bc985c7c6c93eb352f149147f60706517904 Mon Sep 17 00:00:00 2001 From: Tibo De Peuter Date: Mon, 4 Mar 2024 16:46:30 +0100 Subject: [PATCH 1/4] [hyprland] Add module --- nixos/modules/desktop/default.nix | 1 + nixos/modules/desktop/hyprland/default.nix | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 nixos/modules/desktop/hyprland/default.nix diff --git a/nixos/modules/desktop/default.nix b/nixos/modules/desktop/default.nix index f67e134..465f8ca 100644 --- a/nixos/modules/desktop/default.nix +++ b/nixos/modules/desktop/default.nix @@ -1,6 +1,7 @@ { imports = [ ./gnome + ./hyprland ./plasma ./sway ]; diff --git a/nixos/modules/desktop/hyprland/default.nix b/nixos/modules/desktop/hyprland/default.nix new file mode 100644 index 0000000..5209653 --- /dev/null +++ b/nixos/modules/desktop/hyprland/default.nix @@ -0,0 +1,15 @@ +{ config, lib, ... }: + +let + cfg = config.sisyphus.desktop.hyprland; +in { + options.sisyphus.desktop.hyprland.enable = lib.mkEnableOption "Hyprland"; + + config = lib.mkIf cfg.enable { + programs.hyprland = { + enable = true; + xwayland.enable = true; + }; + }; +} + From 4004a048f6a106fcbb79aca265179314851d4dd7 Mon Sep 17 00:00:00 2001 From: Tibo De Peuter Date: Mon, 4 Mar 2024 16:49:09 +0100 Subject: [PATCH 2/4] [sway] Add history log to dmenu --- stow/sway/.config/sway/config | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stow/sway/.config/sway/config b/stow/sway/.config/sway/config index 77bfaa9..1b9ee29 100644 --- a/stow/sway/.config/sway/config +++ b/stow/sway/.config/sway/config @@ -15,8 +15,9 @@ set { $scrollUp button4 $scrollDown button5 - $term kitty || alacritty || foot - $menu j4-dmenu-desktop --dmenu "rofi -dmenu -i" + # $term kitty || alacritty || foot + $term kitty + $menu j4-dmenu-desktop --dmenu "rofi -dmenu -i" --usage-log="/home/tdpeuter/.local/state/dmenu.log" # TODO Find better location and better way to reference this. $window_switcher /home/tdpeuter/projects/fzf-jump/new.sh $lock swaylock -f From e81082733131320d4194a9b1a4ff245cb56cc1e1 Mon Sep 17 00:00:00 2001 From: Tibo De Peuter Date: Mon, 4 Mar 2024 16:52:53 +0100 Subject: [PATCH 3/4] Fix rename --- nixos/modules/desktop/sway/default.nix | 2 +- nixos/users/tdpeuter/default.nix | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/nixos/modules/desktop/sway/default.nix b/nixos/modules/desktop/sway/default.nix index b5de914..3b29094 100644 --- a/nixos/modules/desktop/sway/default.nix +++ b/nixos/modules/desktop/sway/default.nix @@ -74,7 +74,7 @@ in { SCRIPT_DIR = ../../../../scripts; }; - fonts.fonts = with pkgs; [ + fonts.packages = with pkgs; [ dejavu_fonts font-awesome noto-fonts diff --git a/nixos/users/tdpeuter/default.nix b/nixos/users/tdpeuter/default.nix index f406f49..cc5a5a5 100644 --- a/nixos/users/tdpeuter/default.nix +++ b/nixos/users/tdpeuter/default.nix @@ -61,9 +61,6 @@ in { icosystem # Personal icon theme spotify-adblock ]) ++ (with pkgs-unstable; [ - # logseq - # obsidian - brave chafa # Terminal image viewer duf # Df alternative @@ -72,6 +69,7 @@ in { jellyfin-media-player kitty libreoffice-fresh + logseq mpv nextcloud-client nsxiv # Lightweight image viewer @@ -96,9 +94,7 @@ in { ]); pointerCursor = { - package = cursor.package; - name = cursor.name; - size = cursor.size; + inherit (cursor) package name size; gtk.enable = true; x11.enable = true; }; From 15e00efe3e5d9ea77075ebd11267306af9b9d6c0 Mon Sep 17 00:00:00 2001 From: Tibo De Peuter Date: Mon, 4 Mar 2024 16:54:28 +0100 Subject: [PATCH 4/4] [nvidia] Attempts to fix flicker Switch to nouveau --- nixos/flake.nix | 1 + nixos/hosts/Tibo-NixFat/default.nix | 2 ++ nixos/modules/desktop/sway/default.nix | 39 ++++++++++++++++++----- nixos/modules/hardware/nvidia/default.nix | 19 +++++++++-- 4 files changed, 50 insertions(+), 11 deletions(-) diff --git a/nixos/flake.nix b/nixos/flake.nix index e5a93b8..54d6be8 100644 --- a/nixos/flake.nix +++ b/nixos/flake.nix @@ -45,6 +45,7 @@ "spotify" "steam" "steam-original" "steam-run" "vista-fonts" + "nvidia-persistenced" # Docker ]; in utils.lib.mkFlake { diff --git a/nixos/hosts/Tibo-NixFat/default.nix b/nixos/hosts/Tibo-NixFat/default.nix index bb4ab0d..fd0af25 100644 --- a/nixos/hosts/Tibo-NixFat/default.nix +++ b/nixos/hosts/Tibo-NixFat/default.nix @@ -6,6 +6,8 @@ ]; sisyphus = { + desktop.sway.enable = true; + hardware.nvidia = { enable = true; model = "Quadro T2000"; diff --git a/nixos/modules/desktop/sway/default.nix b/nixos/modules/desktop/sway/default.nix index 3b29094..267fe03 100644 --- a/nixos/modules/desktop/sway/default.nix +++ b/nixos/modules/desktop/sway/default.nix @@ -38,6 +38,26 @@ let export XDG_DATA_DIRS=${datadir}:$XDG_DATA_DIRS gnome_schema=org.gnome.desktop.interface # gsettings set $gnome_schema gtk-theme 'Dracula' + + # https://github.com/crispyricepc/sway-nvidia/blob/2101a18698151a61266740f1297158119bf660ac/wlroots-env-nvidia.sh + # Hardware cursors not yet working on wlroots + export WLR_NO_HARDWARE_CURSORS=1 + # Set wlroots renderer to Vulkan to avoid flickering + export WLR_RENDERER=vulkan + # General wayland environment variables + export XDG_SESSION_TYPE=wayland + export QT_QPA_PLATFORM=wayland + export QT_WAYLAND_DISABLE_WINDOWDECORATION=1 + # Firefox wayland environment variable + export MOZ_ENABLE_WAYLAND=1 + export MOZ_USE_XINPUT2=1 + # OpenGL Variables + export GBM_BACKEND=nvidia-drm + export __GL_GSYNC_ALLOWED=0 + export __GL_VRR_ALLOWED=0 + export __GLX_VENDOR_LIBRARY_NAME=nvidia + # Xwayland compatibility + export XWAYLAND_NO_GLAMOR=1 ''; }; in { @@ -100,14 +120,17 @@ in { power-profiles-daemon.enable = true; - xserver.displayManager.session = [{ - manage = "window"; - name = "Sway"; - start = '' - ${pkgs.sway}/bin/sway --unsupported-gpu & - waitPID=$! - ''; - }]; + xserver = { + displayManager.session = [{ + manage = "window"; + name = "Sway"; + start = '' + ${pkgs.sway}/bin/sway --unsupported-gpu & + waitPID=$! + ''; + }]; + videoDrivers = [ "nouveau" ]; + }; }; xdg.portal = { diff --git a/nixos/modules/hardware/nvidia/default.nix b/nixos/modules/hardware/nvidia/default.nix index 077520d..036cf4c 100644 --- a/nixos/modules/hardware/nvidia/default.nix +++ b/nixos/modules/hardware/nvidia/default.nix @@ -3,6 +3,7 @@ let cfg = config.sisyphus.hardware.nvidia; + # The graphics cards for which to do offloading do-offloading = builtins.elem cfg.model [ "Quadro T2000" ]; nvidia-offload = pkgs.writeShellScriptBin "nvidia-offload" '' export __NV_PRIME_RENDER_OFFLOAD=1 @@ -24,8 +25,17 @@ in { }; config = lib.mkIf cfg.enable { - services.xserver.videoDrivers = [ "nvidia" ]; - +# boot = { +# extraModprobeConfig = "options nvidia-drm modeset=1"; +# +# initrd.kernelModules = [ +# "nvidia" +# "nvidia_modeset" +# "nvidia_uvm" +# "nvidia_drm" +# ]; +# }; + hardware = { opengl = { enable = true; @@ -33,7 +43,7 @@ in { driSupport32Bit = true; }; nvidia = { - open = true; + open = false; package = config.boot.kernelPackages.nvidiaPackages.stable; modesetting.enable = true; nvidiaSettings = cfg.gui-settings; @@ -42,6 +52,9 @@ in { finegrained = do-offloading; }; + # Avoid flickering + forceFullCompositionPipeline = true; + prime = lib.mkMerge [ (lib.mkIf do-offloading { offload = {