From 8062e1b8771f1b2d1970cb1b82a3547843e29336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Sat, 25 Nov 2023 05:30:50 +0100 Subject: [PATCH 1/3] nvidia: Improve nvidia-vaapi config --- .../config/graphical-applications/firefox.nix | 5 -- nixos-config/yui/default.nix | 2 +- .../yui/{nvidia.nix => nvidia/default.nix} | 59 ++++--------------- nixos-config/yui/nvidia/vaapi.nix | 59 +++++++++++++++++++ 4 files changed, 70 insertions(+), 55 deletions(-) rename nixos-config/yui/{nvidia.nix => nvidia/default.nix} (52%) create mode 100644 nixos-config/yui/nvidia/vaapi.nix diff --git a/home-config/config/graphical-applications/firefox.nix b/home-config/config/graphical-applications/firefox.nix index 3fcfd781..bc34c436 100644 --- a/home-config/config/graphical-applications/firefox.nix +++ b/home-config/config/graphical-applications/firefox.nix @@ -64,11 +64,6 @@ in { userContent = builtins.readFile "${firefox-ui-fix}/css/leptonContent.css"; settings = { - # Performance settings - "gfx.webrender.all" = true; # Force enable GPU acceleration - "media.ffmpeg.vaapi.enabled" = true; - "widget.dmabuf.force-enabled" = true; # Required in recent Firefoxes - # Re-bind ctrl to super (would interfere with tridactyl otherwise) "ui.key.accelKey" = 91; diff --git a/nixos-config/yui/default.nix b/nixos-config/yui/default.nix index 6d5e38d7..a49ad282 100644 --- a/nixos-config/yui/default.nix +++ b/nixos-config/yui/default.nix @@ -17,7 +17,7 @@ in { ./hardware-configuration.nix ../networks/personal.nix ./wireguard.nix - ./nvidia.nix + ./nvidia ./networking.nix ]; diff --git a/nixos-config/yui/nvidia.nix b/nixos-config/yui/nvidia/default.nix similarity index 52% rename from nixos-config/yui/nvidia.nix rename to nixos-config/yui/nvidia/default.nix index 7ef2f93a..7697ad73 100644 --- a/nixos-config/yui/nvidia.nix +++ b/nixos-config/yui/nvidia/default.nix @@ -1,16 +1,19 @@ -{ - config, - flake-inputs, - lib, - pkgs, - ... -}: { +{lib, ...}: { + imports = [ + ./vaapi.nix + ]; + hardware.nvidia = { modesetting.enable = true; # Power management is required to get nvidia GPUs to behave on # suspend, due to firmware bugs. Aren't nvidia great? powerManagement.enable = true; open = true; + + vaapi = { + enable = true; + firefox.enable = true; + }; }; boot.extraModprobeConfig = @@ -32,11 +35,6 @@ ]; environment.variables = { - # Necessary to correctly enable va-api (video codec hardware - # acceleration). If this isn't set, the libvdpau backend will be - # picked, and that one doesn't work with most things, including - # Firefox. - LIBVA_DRIVER_NAME = "nvidia"; # Required to run the correct GBM backend for nvidia GPUs on wayland GBM_BACKEND = "nvidia-drm"; # Apparently, without this nouveau may attempt to be used instead @@ -44,17 +42,6 @@ __GLX_VENDOR_LIBRARY_NAME = "nvidia"; # Hardware cursors are currently broken on nvidia WLR_NO_HARDWARE_CURSORS = "1"; - - # Required to use va-api it in Firefox. See - # https://github.com/elFarto/nvidia-vaapi-driver/issues/96 - MOZ_DISABLE_RDD_SANDBOX = "1"; - # It appears that the normal rendering mode is broken on recent - # nvidia drivers: - # https://github.com/elFarto/nvidia-vaapi-driver/issues/213#issuecomment-1585584038 - NVD_BACKEND = "direct"; - # Required for firefox 98+, see: - # https://github.com/elFarto/nvidia-vaapi-driver#firefox - EGL_PLATFORM = "wayland"; }; programs.hyprland.package = flake-inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.hyprland.override { @@ -74,30 +61,4 @@ }; })) ]; - - # Ugly hack to fix a bug in egl-wayland, see - # https://github.com/NixOS/nixpkgs/issues/202454 - environment.etc."egl/egl_external_platform.d".source = let - nvidia_wayland = pkgs.writeText "10_nvidia_wayland.json" '' - { - "file_format_version" : "1.0.0", - "ICD" : { - "library_path" : "${flake-inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.egl-wayland}/lib/libnvidia-egl-wayland.so" - } - } - ''; - nvidia_gbm = pkgs.writeText "15_nvidia_gbm.json" '' - { - "file_format_version" : "1.0.0", - "ICD" : { - "library_path" : "${config.hardware.nvidia.package}/lib/libnvidia-egl-gbm.so.1" - } - } - ''; - in - lib.mkForce (pkgs.runCommandLocal "nvidia-egl-hack" {} '' - mkdir -p $out - cp ${nvidia_wayland} $out/10_nvidia_wayland.json - cp ${nvidia_gbm} $out/15_nvidia_gbm.json - ''); } diff --git a/nixos-config/yui/nvidia/vaapi.nix b/nixos-config/yui/nvidia/vaapi.nix new file mode 100644 index 00000000..14c68846 --- /dev/null +++ b/nixos-config/yui/nvidia/vaapi.nix @@ -0,0 +1,59 @@ +{ + config, + lib, + ... +}: let + cfg = config.hardware.nvidia.vaapi; +in { + options.hardware.nvidia.vaapi = with lib.types; { + enable = lib.mkEnableOption "vaapi"; + + maxInstances = lib.mkOption { + type = nullOr int; + default = null; + description = '' + The maximum number of concurrent instances of the driver. + + Sometimes useful for graphics cards with little VRAM. + ''; + }; + + firefox = { + enable = lib.mkEnableOption "Firefox configuration"; + + av1Support = lib.mkOption { + type = bool; + default = false; + description = "Whether to enable av1 support. Should be disabled for GeForce 20 and earlier."; + }; + }; + }; + + # See https://github.com/elFarto/nvidia-vaapi-driver#configuration + config = lib.mkIf cfg.enable { + environment.variables = + { + NVD_BACKEND = "direct"; + } + // lib.optionalAttrs (cfg.maxInstances != null) { + NVD_MAX_INSTANCES = toString cfg.maxInstances; + } + // lib.optionalAttrs cfg.firefox.enable { + MOZ_DISABLE_RDD_SANDBOX = "1"; + }; + + # TODO(tlater): When 23.11 finally hits, the nvidia driver shipped + # with it will contain the correct version of egl-wayland. + boot.kernelPackages = lib.mkOverride 1 flake-inputs.nixpkgs-unfree.legacyPackages.${pkgs.system}.linuxKernel.packages.linux_xanmod_latest; + + # TODO(tlater): Find a way to properly integrate this so we can + # upstream it. + home-manager.users.tlater.programs.firefox.profiles.tlater.settings = lib.mkIf cfg.firefox.enable { + "media.ffmpeg.vaapi.enabled" = true; + "media.rdd-ffmpeg.enabled" = true; + "media.av1.enabled" = cfg.firefox.av1Support; + "gfx.x11-egl.force-enabled" = true; + "widget.dmabuf.force-enabled" = true; + }; + }; +} From 7e08e4571da0144761c9bdb9754fff12689e0dbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Sun, 26 Nov 2023 06:07:32 +0100 Subject: [PATCH 2/3] emacs: Switch to pgtk for pure wayland support --- home-config/dotfiles/emacs.d/config/features.el | 2 +- pkgs/applications/emacs/default.nix | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/home-config/dotfiles/emacs.d/config/features.el b/home-config/dotfiles/emacs.d/config/features.el index 8c55778d..8e9fe31e 100644 --- a/home-config/dotfiles/emacs.d/config/features.el +++ b/home-config/dotfiles/emacs.d/config/features.el @@ -203,7 +203,7 @@ "Alternate which-key based indicator. Hide the which-key indicator immediately when using the - 'completing-read' prompter. FN ARGS." + \\='completing-read\\=' prompter. FN ARGS." (which-key--hide-popup-ignore-command) (let ((embark-indicators (remq #'embark-which-key-indicator embark-indicators))) diff --git a/pkgs/applications/emacs/default.nix b/pkgs/applications/emacs/default.nix index 9c9451b4..2458c19a 100644 --- a/pkgs/applications/emacs/default.nix +++ b/pkgs/applications/emacs/default.nix @@ -5,13 +5,13 @@ hostPlatform, emacsPackagesFor, emacsMacport, - emacs, + emacs29-pgtk, runCommandLocal, }: let emacsPlatform = if hostPlatform.isDarwin then emacsMacport - else emacs; + else emacs29-pgtk; use-package-list = stdenv.mkDerivation { inherit (sources.bauer) src version; From 444a85b014ad86dc5a9fa9e5e38c585dcb7958f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Sat, 25 Nov 2023 05:29:04 +0100 Subject: [PATCH 3/3] desktop: Switch from Hyprland to sway Hyprland no longer works with the newest nvidia drivers, while nvidia have reportedly started testing their drivers against sway. Also: https://drewdevault.com/2023/09/17/Hyprland-toxicity.html --- README.md | 14 +-- home-config/config/desktop/default.nix | 2 +- .../config/desktop/{hyprland.nix => sway.nix} | 53 +++----- home-config/dotfiles/hyprland.conf | 116 ------------------ home-config/dotfiles/sway.conf | 70 +++++++++++ modules/cursor-theme.nix | 35 +++--- nixos-config/default.nix | 21 +--- nixos-config/greeter/default.nix | 52 +++----- nixos-config/sway.nix | 18 +++ nixos-config/yui/nvidia/default.nix | 18 --- nixos-config/yui/nvidia/vaapi.nix | 4 - 11 files changed, 149 insertions(+), 254 deletions(-) rename home-config/config/desktop/{hyprland.nix => sway.nix} (57%) delete mode 100644 home-config/dotfiles/hyprland.conf create mode 100644 home-config/dotfiles/sway.conf create mode 100644 nixos-config/sway.nix diff --git a/README.md b/README.md index c2406db4..4a918fec 100644 --- a/README.md +++ b/README.md @@ -50,21 +50,13 @@ Then set up: 1. Basic networking. Typically a bond config, see ren/yui for examples. -2. Hyprland will need some small tweaks, usually these settings need to be twiddled: - ```nix - programs.hyprland = { - enableNvidiaPatches = false; - }; - ``` - - If using nvidia, *lots* of things need to be twiddled, look at - the yui config. -3. Make sure to include one of the network modules so that wireless +2. Make sure to include one of the network modules so that wireless networking is set up on first boot. -4. Generate and include a new `hardware-configuration.nix`: +3. Generate and include a new `hardware-configuration.nix`: ```console nixos-generate-config --no-filesystems --show-hardware-config ``` -5. Set up a new sops target. +4. Set up a new sops target. 1. Firstly, create a new gpg dir according to [these instructions](https://github.com/Mic92/sops-nix#use-with-gpg-instead-of-ssh-keys). 2. Then, add the generated fingerprint to `.sops.yaml`, and diff --git a/home-config/config/desktop/default.nix b/home-config/config/desktop/default.nix index 155bb7f3..38712f2f 100644 --- a/home-config/config/desktop/default.nix +++ b/home-config/config/desktop/default.nix @@ -7,12 +7,12 @@ ./barrier.nix ./dunst.nix ./gtk.nix - ./hyprland.nix ./mime.nix ./ncmpcpp.nix ./pipewire.nix ./rofi.nix ./stumpwm.nix + ./sway.nix ]; config = lib.mkIf config.custom.desktop-environment { diff --git a/home-config/config/desktop/hyprland.nix b/home-config/config/desktop/sway.nix similarity index 57% rename from home-config/config/desktop/hyprland.nix rename to home-config/config/desktop/sway.nix index 3eea2ddf..e533234c 100644 --- a/home-config/config/desktop/hyprland.nix +++ b/home-config/config/desktop/sway.nix @@ -1,12 +1,13 @@ { config, - lib, + nixos-config ? {}, pkgs, - flake-inputs, + lib, ... }: let - hyprctl = "${flake-inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.hyprland}/bin/hyprctl"; loginctl = "${pkgs.systemd}/bin/loginctl"; + swaymsg = "${nixos-config.programs.sway.package or pkgs.sway}/bin/swaymsg"; + systemctl = "${pkgs.systemd}/bin/systemctl"; wpaperd-config = { default = { @@ -26,9 +27,8 @@ libsecret wl-clipboard ]; - text = '' - WINDOW_TITLE="$('${hyprctl}' -j activewindow | jq -r '.title')" + WINDOW_TITLE="$(${swaymsg} --type get_tree | jq -r 'recurse(.nodes[]) | select(.focused) | .app_id // .window_properties.title')" secret-tool lookup KP2A_URL "title://$WINDOW_TITLE" | wl-copy # Wait 45 seconds before clearing the clipboard sleep 45 @@ -37,36 +37,15 @@ }; in { config = lib.mkIf config.custom.desktop-environment { - home.packages = with pkgs; [ - slurp - grim + home.packages = [ keepassxc-copy - flake-inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.grimblast ]; - systemd.user.targets.hyprland-session = { - Unit = { - Description = "Hyprland compositor session"; - Documentation = ["man:systemd.special(7)"]; - BindsTo = ["graphical-session.target"]; - Wants = ["graphical-session-pre.target"]; - After = ["graphical-session-pre.target"]; - }; - }; - - xdg.configFile."hypr/hyprland.conf" = { - source = ../../dotfiles/hyprland.conf; - onChange = let - inherit (flake-inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}) hyprland; - in '' - ( # execute in subshell so that `shopt` won't affect other scripts - shopt -s nullglob # so that nothing is done if /tmp/hypr/ does not exist or is empty - for instance in /tmp/hypr/*; do - HYPRLAND_INSTANCE_SIGNATURE=''${instance##*/} ${hyprland}/bin/hyprctl reload config-only \ - || true # ignore dead instance(s) - done - ) - ''; + wayland.windowManager.sway = { + enable = true; + package = null; + config = null; + extraConfig = lib.fileContents ../../dotfiles/sway.conf; }; services.swayidle = { @@ -76,14 +55,15 @@ in { events = [ { event = "lock"; - command = "${config.programs.swaylock.package}/bin/swaylock"; + command = "${systemctl} --user start swaylock"; } ]; timeouts = [ { timeout = 5 * 60; - command = "${hyprctl} dispatch dpms off"; + command = "${swaymsg} 'output * power off'"; + resumeCommand = "${swaymsg} 'output * power on'"; } { timeout = 6 * 60; @@ -105,6 +85,11 @@ in { }; }; + systemd.user.services.swaylock = { + Unit.Description = "Lock screen"; + Service.ExecStart = "${config.programs.swaylock.package}/bin/swaylock"; + }; + systemd.user.services.wpaperd = { Unit = { Description = "Wallpaper daemon"; diff --git a/home-config/dotfiles/hyprland.conf b/home-config/dotfiles/hyprland.conf deleted file mode 100644 index 4c944b51..00000000 --- a/home-config/dotfiles/hyprland.conf +++ /dev/null @@ -1,116 +0,0 @@ -exec-once = /etc/hyprland-theme-init -exec-once = systemctl --user import-environment \{,WAYLAND_\}DISPLAY HYPRLAND_INSTANCE_SIGNATURE; systemctl --user start hm-graphical-session.target -exec-once = dbus-update-activation-environment --systemd DISPLAY HYPRLAND_INSTANCE_SIGNATURE WAYLAND_DISPLAY XDG_CURRENT_DESKTOP - -misc { - disable_hyprland_logo = yes - disable_splash_rendering = yes - vrr = 2 - key_press_enables_dpms = yes -} - -input { - follow_mouse = 2 - float_switch_override_focus = 1 -} - -general { - cursor_inactive_timeout = 5 - no_cursor_warps = yes - border_size = 2 - col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg - col.inactive_border = rgba(595959aa) -} - -decoration { - rounding = 10 - col.shadow = rgba(1a1a1aee) - - blur { - size = 3 - } -} - -animations { - bezier = myBezier, 0.05, 0.9, 0.1, 1.05 - - animation = windows, 1, 7, myBezier - animation = windowsOut, 1, 7, default, popin 80% - animation = border, 1, 10, default - animation = borderangle, 1, 8, default - animation = fade, 1, 7, default - animation = workspaces, 1, 6, default -} - -dwindle { - pseudotile = yes - preserve_split = yes -} - -$mainMod = SUPER - -# Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more -bind = $mainMod, Q, exec, alacritty -bind = $mainMod, C, killactive, -bind = $mainMod, M, exit, -bind = $mainMod, E, exec, emacsclient --create-frame --alternate-editor 'emacs' -bind = $mainMod, V, togglefloating, -bind = $mainMod, R, exec, rofi -show drun -bind = $mainMod, P, pseudo, # dwindle -bind = $mainMod, J, togglesplit, # dwindle - -# Move focus with mainMod + arrow keys -bind = $mainMod, left, movefocus, l -bind = $mainMod, right, movefocus, r -bind = $mainMod, up, movefocus, u -bind = $mainMod, down, movefocus, d - -# Switch workspaces with mainMod + [0-9] -bind = $mainMod, 1, workspace, 1 -bind = $mainMod, 2, workspace, 2 -bind = $mainMod, 3, workspace, 3 -bind = $mainMod, 4, workspace, 4 -bind = $mainMod, 5, workspace, 5 -bind = $mainMod, 6, workspace, 6 -bind = $mainMod, 7, workspace, 7 -bind = $mainMod, 8, workspace, 8 -bind = $mainMod, 9, workspace, 9 -bind = $mainMod, 0, workspace, 10 - -# Move active window to a workspace with mainMod + SHIFT + [0-9] -bind = $mainMod SHIFT, 1, movetoworkspace, 1 -bind = $mainMod SHIFT, 2, movetoworkspace, 2 -bind = $mainMod SHIFT, 3, movetoworkspace, 3 -bind = $mainMod SHIFT, 4, movetoworkspace, 4 -bind = $mainMod SHIFT, 5, movetoworkspace, 5 -bind = $mainMod SHIFT, 6, movetoworkspace, 6 -bind = $mainMod SHIFT, 7, movetoworkspace, 7 -bind = $mainMod SHIFT, 8, movetoworkspace, 8 -bind = $mainMod SHIFT, 9, movetoworkspace, 9 -bind = $mainMod SHIFT, 0, movetoworkspace, 10 - -# Scroll through existing workspaces with mainMod + scroll -bind = $mainMod, mouse_down, workspace, e+1 -bind = $mainMod, mouse_up, workspace, e-1 - -# Move/resize windows with mainMod + LMB/RMB and dragging -bindm = $mainMod, mouse:272, movewindow -bindm = $mainMod, mouse:273, resizewindow - -# Screenshot bindings -bind = $mainMod,s,submap,screenshot -submap = screenshot - -# Top-level bindings, just copysave everything -bind = , a, exec, grimblast copysave output -bind = , a, submap, reset -bind = , c, exec, grimblast copysave active -bind = , c, submap, reset -bind = , r, exec, grimblast copysave area -bind = , r, submap, reset -bind = , escape, submap, reset - -submap = reset - -# Copy the password for the current window from keepassxc -bind = $mainMod, l, exec, keepassxc-copy diff --git a/home-config/dotfiles/sway.conf b/home-config/dotfiles/sway.conf new file mode 100644 index 00000000..490e334e --- /dev/null +++ b/home-config/dotfiles/sway.conf @@ -0,0 +1,70 @@ +set $mod Mod4 + +# Monitors + +output "Dell Inc. DELL G2723HN 5B0C3H3" { + mode 1920x1080@164.997Hz + adaptive_sync on + max_render_time 3 +} + +# Window decorations + +corner_radius 10 +smart_corner_radius enable +default_border pixel +gaps { + outer 20 + inner 5 +} + +# Keybindings + +## Basic applications +bindsym { + $mod+Q exec alacritty + $mod+E exec emacsclient --create-frame --alternate-editor 'emacs' + $mod+R exec rofi -show drun + $mod+L exec keepassxc-copy +} + +## Window/desktop management +floating_modifier $mod + +bindsym { + $mod+Up focus up + $mod+Right focus right + $mod+Down focus down + $mod+Left focus left + + $mod+V floating toggle + $mod+S sticky toggle + + $mod+C kill + $mod+M exit +} + +## Workspaces +bindsym { + $mod+1 workspace 1 + $mod+2 workspace 2 + $mod+3 workspace 3 + $mod+4 workspace 4 + $mod+5 workspace 5 + $mod+6 workspace 6 + $mod+7 workspace 7 + $mod+8 workspace 8 + $mod+9 workspace 9 + $mod+0 workspace 10 + + $mod+Shift+1 move container to workspace 1; workspace 1 + $mod+Shift+2 move container to workspace 2; workspace 2 + $mod+Shift+3 move container to workspace 3; workspace 3 + $mod+Shift+4 move container to workspace 4; workspace 4 + $mod+Shift+5 move container to workspace 5; workspace 5 + $mod+Shift+6 move container to workspace 6; workspace 6 + $mod+Shift+7 move container to workspace 7; workspace 7 + $mod+Shift+8 move container to workspace 8; workspace 8 + $mod+Shift+9 move container to workspace 9; workspace 9 + $mod+Shift+0 move container to workspace 10; workspace 10 +} diff --git a/modules/cursor-theme.nix b/modules/cursor-theme.nix index b71b94f3..a660e763 100644 --- a/modules/cursor-theme.nix +++ b/modules/cursor-theme.nix @@ -2,7 +2,6 @@ config, lib, pkgs, - flake-inputs, ... }: let inherit (lib.types) string nullOr number; @@ -27,32 +26,30 @@ in { description = "How much to scale the cursor size by on xwayland applications"; }; }; + }; - _hyprland-theme-init = lib.mkOption { - default = pkgs.writeShellApplication { - name = "hyprland-theme-init"; - runtimeInputs = [ - pkgs.glib - pkgs.xorg.xsetroot - flake-inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.hyprland + config = lib.mkIf (config.theming.cursor.theme != null) { + programs.sway.extraSessionCommands = let + cursorThemeInit = pkgs.writeShellApplication { + name = "cursor-theme-init"; + runtimeInputs = with pkgs; [ + glib + xorg.xsetroot ]; text = '' xsetroot -cursor_name left_ptr - hyprctl setcursor '${config.theming.cursor.theme}' ${toString config.theming.cursor.size} export XDG_DATA_DIRS=${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/gsettings-desktop-schemas-44.0 gsettings set org.gnome.desktop.interface cursor-theme '${config.theming.cursor.theme}' gsettings set org.gnome.desktop.interface cursor-size '${toString config.theming.cursor.size}' ''; }; - }; - }; - - config = lib.mkIf (config.theming.cursor.theme != null) { - environment.etc."hyprland-theme-init".source = "${config.theming._hyprland-theme-init}/bin/hyprland-theme-init"; - - environment.extraInit = '' - export XCURSOR_THEME='${config.theming.cursor.theme}' - export XCURSOR_SIZE=${toString (builtins.floor (config.theming.cursor.size * config.theming.cursor.x-scaling))} - ''; + in + lib.concatStringsSep "\n" [ + '' + export XCURSOR_THEME='${config.theming.cursor.theme}' + export XCURSOR_SIZE=${toString (builtins.floor (config.theming.cursor.size * config.theming.cursor.x-scaling))} + '' + cursorThemeInit + ]; }; } diff --git a/nixos-config/default.nix b/nixos-config/default.nix index d22c34cb..b063f623 100644 --- a/nixos-config/default.nix +++ b/nixos-config/default.nix @@ -1,5 +1,5 @@ { - lib, + config, pkgs, flake-inputs, ... @@ -9,6 +9,7 @@ flake-inputs.sops-nix.nixosModules.sops ./greeter + ./sway.nix ./wireguard.nix ../modules ]; @@ -60,7 +61,10 @@ home-manager = { useGlobalPkgs = true; useUserPackages = true; - extraSpecialArgs.flake-inputs = flake-inputs; + extraSpecialArgs = { + inherit flake-inputs; + nixos-config = config; + }; }; boot = { @@ -119,13 +123,10 @@ home-manager # To manage the actual user configuration pavucontrol # In case the host doesn't have audio, this can't be in the user config wpa_supplicant_gui # For managing wireless networks - bibata-cursors firefox ]; - theming.cursor.theme = "Bibata-Original-Ice"; - environment.extraInit = '' # Do not want this in the environment. NixOS always sets it and does not # provide any option not to, so I must unset it myself via the @@ -140,18 +141,8 @@ programs = { dconf.enable = true; zsh.enable = true; - hyprland = { - enable = true; - package = lib.mkDefault flake-inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.hyprland; - }; }; - # Override the default xdg portal set by the hyprland module - # TODO(tlater): Starting with 23.11 there will be an option for this - xdg.portal.extraPortals = lib.mkForce [ - flake-inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.xdg-desktop-portal-hyprland - ]; - security.pam.services.swaylock = {}; fonts = { diff --git a/nixos-config/greeter/default.nix b/nixos-config/greeter/default.nix index 30321fa4..5325297b 100644 --- a/nixos-config/greeter/default.nix +++ b/nixos-config/greeter/default.nix @@ -5,46 +5,33 @@ flake-inputs, ... }: let - hyprland-gtkgreet = pkgs.writeText "hyprland-gtkgreet" '' - env = XDG_CACHE_HOME,/tmp + sway = config.programs.sway.package; + unsupported-gpu = lib.elem "nvidia" config.services.xserver.videoDrivers; - exec-once = ${config.theming._hyprland-theme-init}/bin/hyprland-theme-init - exec-once = eww -c ${./eww-config} open powermenu - exec-once = gtkgreet -l; hyprctl dispatch exit + sway-gtkgreet = pkgs.writeText "sway-gtkgreet" '' + output '*' background #fafafa solid_color - decoration { - drop_shadow = false - blur { - enabled = false - } - } - - animations { - enabled = false - } - - misc { - disable_hyprland_logo = yes - disable_splash_rendering = yes - } + exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK + exec ${pkgs.eww-wayland}/bin/eww -c ${./eww-config} open powermenu + exec "${pkgs.greetd.gtkgreet}/bin/gtkgreet -l; ${sway}/bin/swaymsg exit" ''; launch-gtkgreet = pkgs.writeShellApplication { name = "launch-gtkgreet"; runtimeInputs = [ - flake-inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.hyprland - pkgs.greetd.gtkgreet - pkgs.eww-wayland + sway ]; text = '' export XDG_SESSION_TYPE=wayland - Hyprland -c ${hyprland-gtkgreet} + export HOME=/var/run/gtkgreet + mkdir -p "$HOME/.cache" + sway ${lib.optionalString unsupported-gpu "--unsupported-gpu"} -c ${sway-gtkgreet} ''; }; - hyprland-run = pkgs.writeShellScriptBin "hyprland-run" '' + sway-run = pkgs.writeShellScriptBin "sway-run" '' export XDG_SESSION_TYPE=wayland - systemd-cat -t xsession Hyprland + systemd-cat -t xsession sway ${lib.optionalString unsupported-gpu "--unsupported-gpu"} ''; in { services.xserver.displayManager.lightdm.enable = false; @@ -58,7 +45,7 @@ in { environment.systemPackages = with pkgs; [ eww-wayland - hyprland-run + sway-run pciutils ]; @@ -67,21 +54,14 @@ in { ]; environment.etc."greetd/environments".text = '' - hyprland-run + sway-run ''; systemd.tmpfiles.rules = let inherit (config.services.greetd.settings.default_session) user; in [ + "d /run/gtkgreet 0755 greeter ${user} - -" "d /var/log/gtkgreet 0755 greeter ${user} - -" "d /var/cache/gtkgreet 0755 greeter ${user} - -" ]; - - services.xserver.displayManager.session = [ - { - manage = "desktop"; - name = "user-defined"; - start = config.services.xserver.displayManager.sessionData.wrapper; - } - ]; } diff --git a/nixos-config/sway.nix b/nixos-config/sway.nix new file mode 100644 index 00000000..c0a023e2 --- /dev/null +++ b/nixos-config/sway.nix @@ -0,0 +1,18 @@ +{pkgs, ...}: { + environment.systemPackages = with pkgs; [ + bibata-cursors + ]; + + theming.cursor.theme = "Bibata-Original-Ice"; + + programs.sway = { + enable = true; + package = pkgs.swayfx.overrideAttrs (_: {passthru.providedSessions = ["sway"];}); + wrapperFeatures.gtk = true; + }; + + xdg.portal = { + enable = true; + wlr.enable = true; + }; +} diff --git a/nixos-config/yui/nvidia/default.nix b/nixos-config/yui/nvidia/default.nix index 7697ad73..d2ddd90a 100644 --- a/nixos-config/yui/nvidia/default.nix +++ b/nixos-config/yui/nvidia/default.nix @@ -43,22 +43,4 @@ # Hardware cursors are currently broken on nvidia WLR_NO_HARDWARE_CURSORS = "1"; }; - - programs.hyprland.package = flake-inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.hyprland.override { - enableNvidiaPatches = true; - }; - - # Downgrade to 0.5.0 because 1.2.2 doesn't currently work on nvidia - # (for me) - xdg.portal.extraPortals = lib.mkOverride 49 [ - (pkgs.xdg-desktop-portal-hyprland.overrideAttrs (_old: { - version = "0.5.0"; - src = pkgs.fetchFromGitHub { - owner = "hyprwm"; - repo = "xdg-desktop-portal-hyprland"; - rev = "v0.5.0"; - hash = "sha256-C5AO0KnyAFJaCkOn+5nJfWm0kyiPn/Awh0lKTjhgr7Y="; - }; - })) - ]; } diff --git a/nixos-config/yui/nvidia/vaapi.nix b/nixos-config/yui/nvidia/vaapi.nix index 14c68846..db624016 100644 --- a/nixos-config/yui/nvidia/vaapi.nix +++ b/nixos-config/yui/nvidia/vaapi.nix @@ -42,10 +42,6 @@ in { MOZ_DISABLE_RDD_SANDBOX = "1"; }; - # TODO(tlater): When 23.11 finally hits, the nvidia driver shipped - # with it will contain the correct version of egl-wayland. - boot.kernelPackages = lib.mkOverride 1 flake-inputs.nixpkgs-unfree.legacyPackages.${pkgs.system}.linuxKernel.packages.linux_xanmod_latest; - # TODO(tlater): Find a way to properly integrate this so we can # upstream it. home-manager.users.tlater.programs.firefox.profiles.tlater.settings = lib.mkIf cfg.firefox.enable {