From 325f16a9d5d0b6094ab7ecb2373696b05fa26d15 Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Mon, 20 May 2024 23:55:11 +0200 Subject: [PATCH] BIG refactoring --- hosts/vali/mars/configuration.nix | 7 +- modules/wms/wayland/default.nix | 6 + modules/wms/wayland/hypr/default.nix | 0 modules/wms/wayland/hypr/idle.nix | 0 .../wms/wayland/hypr/land.nix | 19 -- modules/wms/wayland/hypr/lock.nix | 0 modules/wms/wayland/hypr/paper.nix | 0 modules/wms/wayland/niri/config.nix | 170 ++++++++++++++++++ modules/wms/wayland/niri/default.nix | 52 ++++++ modules/wms/wayland/services.nix | 28 +++ modules/wms/wayland/variables.nix | 53 ++++++ options/desktop/fonts.nix | 36 +++- 12 files changed, 343 insertions(+), 28 deletions(-) create mode 100644 modules/wms/wayland/default.nix create mode 100644 modules/wms/wayland/hypr/default.nix create mode 100644 modules/wms/wayland/hypr/idle.nix rename hosts/vali/mars/hyprland/hyprland.nix => modules/wms/wayland/hypr/land.nix (94%) create mode 100644 modules/wms/wayland/hypr/lock.nix create mode 100644 modules/wms/wayland/hypr/paper.nix create mode 100644 modules/wms/wayland/niri/config.nix create mode 100644 modules/wms/wayland/niri/default.nix create mode 100644 modules/wms/wayland/services.nix create mode 100644 modules/wms/wayland/variables.nix diff --git a/hosts/vali/mars/configuration.nix b/hosts/vali/mars/configuration.nix index 414bf01..d5672bd 100644 --- a/hosts/vali/mars/configuration.nix +++ b/hosts/vali/mars/configuration.nix @@ -39,13 +39,18 @@ enableDirenv = true; }; }; + wms = { + wayland = { + enable = true; + hyprland.enable = true; + }; + }; programs = { vesktop.enable = true; ssh.enable = true; btop.enable = true; mpv.enable = true; kitty.enable = true; - hyprland.enable = true; newsboat.enable = true; foot.enable = true; fish.enable = true; diff --git a/modules/wms/wayland/default.nix b/modules/wms/wayland/default.nix new file mode 100644 index 0000000..bbaf081 --- /dev/null +++ b/modules/wms/wayland/default.nix @@ -0,0 +1,6 @@ +{ config, pkgs, inputs, ... }: { + imports = + [ inputs.niri.nixosModules.niri ]; + ; + programs.niri.enable = true; +} diff --git a/modules/wms/wayland/hypr/default.nix b/modules/wms/wayland/hypr/default.nix new file mode 100644 index 0000000..e69de29 diff --git a/modules/wms/wayland/hypr/idle.nix b/modules/wms/wayland/hypr/idle.nix new file mode 100644 index 0000000..e69de29 diff --git a/hosts/vali/mars/hyprland/hyprland.nix b/modules/wms/wayland/hypr/land.nix similarity index 94% rename from hosts/vali/mars/hyprland/hyprland.nix rename to modules/wms/wayland/hypr/land.nix index dcc3c86..902b450 100644 --- a/hosts/vali/mars/hyprland/hyprland.nix +++ b/modules/wms/wayland/hypr/land.nix @@ -14,25 +14,6 @@ in { options.modules.programs.hyprland.enable = mkEnableOption "hyprland"; config = mkIf cfg.enable { - # Session variables for Hyprland - environment.sessionVariables = { - LIBVA_DRIVER_NAME = "nvidia"; - GTK_USE_PORTAL = "1"; - NIXOS_XDG_OPEN_USE_PORTAL = "1"; - XDG_CURRENT_DESKTOP = "Hyprland"; - XDG_SESSION_TYPE = "wayland"; - XDG_SESSION_DESKTOP = "Hyprland"; - SDL_VIDEODRIVER = "wayland"; - CLUTTER_BACKEND = "wayland"; - GDK_BACKEND = "wayland"; - WLR_RENDERER_ALLOW_SOFTWARE = "1"; - QT_QPA_PLATFORM = "wayland"; - # Needed anymore? - LIBSEAT_BACKEND = "logind"; - # WLR_NO_HARDWARE_CURSORS = "1"; - NIXOS_OZONE_WL = "1"; - }; - # xdg Portal xdg.portal = { enable = true; diff --git a/modules/wms/wayland/hypr/lock.nix b/modules/wms/wayland/hypr/lock.nix new file mode 100644 index 0000000..e69de29 diff --git a/modules/wms/wayland/hypr/paper.nix b/modules/wms/wayland/hypr/paper.nix new file mode 100644 index 0000000..e69de29 diff --git a/modules/wms/wayland/niri/config.nix b/modules/wms/wayland/niri/config.nix new file mode 100644 index 0000000..813ac45 --- /dev/null +++ b/modules/wms/wayland/niri/config.nix @@ -0,0 +1,170 @@ +{ + pkgs, + theme, + config, + ... +}: +with theme.colors; { + programs.niri.settings = { + outputs."eDP-1".position = { + x = 0; + y = 0; + }; + outputs."DP-2" = { + mode = { + width = 1920; + height = 1080; + refresh = 144.001; + }; + position = { + x = 0; + y = -1080; + }; + }; + + input = { + keyboard.xkb = { + layout = "pl"; + options = "caps:escape"; + }; + touchpad = { + # disable when typing /trackpointing + dwt = true; + dwtp = true; + natural-scroll = true; + click-method = "clickfinger"; + }; + focus-follows-mouse = true; + warp-mouse-to-focus = true; + trackpoint.accel-speed = 0.001; + }; + + layout = { + gaps = 16; + center-focused-column = "never"; + preset-column-widths = [ + {proportion = 0.333;} + {proportion = 0.5;} + {proportion = 0.666;} + ]; + default-column-width = {proportion = 0.5;}; + + focus-ring = { + enable = true; + width = 2; + active.color = "#${accent}"; + inactive.color = "#${overlay0}"; + }; + }; + + animations = let + butter = { + spring = { + damping-ratio = 0.75; + epsilon = 0.00010; + stiffness = 400; + }; + }; + smooth = { + spring = { + damping-ratio = 0.58; + epsilon = 0.00010; + stiffness = 735; + }; + }; + in { + slowdown = 1.3; + horizontal-view-movement = butter; + window-movement = butter; + workspace-switch = butter; + window-open = smooth; + window-close = smooth; + }; + + window-rules = [ + { + geometry-corner-radius = let radius =8.0; in{ + bottom-left = radius; + bottom-right = radius; + top-left = radius; + top-right = radius; + }; + clip-to-geometry= true; + } + ]; + + binds = with config.lib.niri.actions; let + sh = spawn "sh" "-c"; + in { + "Mod+Return" = { + action = spawn "${pkgs.foot}/bin/foot"; + cooldown-ms = 500; + }; + "Mod+Space".action = spawn "${pkgs.fuzzel}/bin/fuzzel"; + "Mod+V".action = sh "${pkgs.cliphist}/bin/cliphist list | fuzzel --dmenu | cliphist decode | wl-copy"; + "Mod+Shift+Period".action = spawn "emoji"; + + "XF86AudioRaiseVolume".action = spawn "pamixer" "-i" "5"; + "XF86AudioLowerVolume".action = spawn "pamixer" "-d" "5"; + "XF86AudioMute".action = spawn "pamixer" "-t"; + "XF86AudioMicMute".action = spawn "micmute"; + + "XF86MonBrightnessUp".action = spawn "brightnessctl" "set" "+5%"; + "XF86MonBrightnessDown".action = spawn "brightnessctl" "set" "5%-"; + + "Super+WheelScrollDown".action = focus-workspace-down; + "Super+WheelScrollDown".cooldown-ms = 500; + "Super+WheelScrollUp".action = focus-workspace-up; + "Super+WheelScrollUp".cooldown-ms = 500; + "Super+WheelScrollRight".action = focus-column-right; + "Super+WheelScrollLeft".action = focus-column-left; + + "Super+H".action = focus-column-left; + "Super+L".action = focus-column-right; + "Super+J".action = focus-workspace-down; + "Super+K".action = focus-workspace-up; + "Super+Left".action = focus-column-left; + "Super+Right".action = focus-column-right; + "Super+Down".action = focus-window-down; + "Super+Up".action = focus-window-up; + + "Super+Print".action = screenshot-window; + "Super+Shift+Print".action = screenshot-screen; + "Super+Shift+S".action = screenshot; + + "Super+Ctrl+H".action = move-column-left; + "Super+Ctrl+J".action = move-window-down; + "Super+Ctrl+K".action = move-window-up; + "Super+Ctrl+L".action = move-column-right; + + "Super+U".action = move-workspace-down; + "Super+I".action = move-workspace-up; + + "Super+Minus".action = set-column-width "-10%"; + "Super+Equal".action = set-column-width "+10%"; + "Super+Shift+Minus".action = set-window-height "-10%"; + "Super+Shift+Equal".action = set-window-height "+10%"; + + "Super+Shift+H".action = focus-monitor-left; + "Super+Shift+J".action = focus-monitor-down; + "Super+Shift+K".action = focus-monitor-up; + "Super+Shift+L".action = focus-monitor-right; + + "Super+Shift+Ctrl+H".action = move-column-to-monitor-left; + "Super+Shift+Ctrl+J".action = move-column-to-monitor-down; + "Super+Shift+Ctrl+K".action = move-column-to-monitor-up; + "Super+Shift+Ctrl+L".action = move-column-to-monitor-right; + + "Super+R".action = switch-preset-column-width; + "Super+F".action = maximize-column; + "Super+Shift+F".action = fullscreen-window; + "Super+C".action = center-column; + + "Mod+Q".action = close-window; + }; + + prefer-no-csd = true; + hotkey-overlay.skip-at-startup = true; + screenshot-path = "~/pics/ss/ss%Y-%m-%d %H-%M-%S.png"; + }; +} diff --git a/modules/wms/wayland/niri/default.nix b/modules/wms/wayland/niri/default.nix new file mode 100644 index 0000000..36730a5 --- /dev/null +++ b/modules/wms/wayland/niri/default.nix @@ -0,0 +1,52 @@ +{ + pkgs, + lib, + theme, + ... +}: let + mkService = lib.recursiveUpdate { + Unit.PartOf = ["graphical-session.target"]; + Unit.After = ["graphical-session.target"]; + Install.WantedBy = ["graphical-session.target"]; + }; +in { +imports = [./config.nix]; + home.packages = with pkgs; [pamixer]; + services = { + wlsunset = { + # TODO: fix opaque red screen issue + enable = true; + latitude = "52.0"; + longitude = "21.0"; + temperature = { + day = 6200; + night = 3750; + }; + systemdTarget = "niri.service"; + }; + cliphist.enable = true; + }; + systemd.user.targets = { + # fake a tray to let apps start + # https://github.com/nix-community/home-manager/issues/2064 + tray = { + Unit = { + Description = "Home Manager System Tray"; + Requires = ["graphical-session-pre.target"]; + }; + }; + }; + + systemd.user.services = { + swaybg = mkService { + Unit = { + Description = "Wallpaper chooser"; + After = "niri.service"; + }; + Service = { + ExecStart = "${lib.getExe pkgs.swaybg} -i ${theme.wallpaper}"; + Restart = "always"; + }; + }; + }; +} diff --git a/modules/wms/wayland/services.nix b/modules/wms/wayland/services.nix new file mode 100644 index 0000000..c882d5d --- /dev/null +++ b/modules/wms/wayland/services.nix @@ -0,0 +1,28 @@ +{ pkgs, inputs, config, ... }: { + + programs.niri = { + enable = true; + package = inputs.niri.packages.${pkgs.system}.niri-unstable; + }; + services = { + greetd = { + enable = true; + settings = rec { + initial_session = { + command = "${config.programs.niri.package}/bin/niri-session"; + user = "vali"; + }; + default_session = initial_session; + }; + }; + + gnome = { + # glib-networking.enable = true; + }; + + # lorri.enable = true; + # udisks2.enable = true; + # printing.enable = true; + # fstrim.enable = true; + }; +} diff --git a/modules/wms/wayland/variables.nix b/modules/wms/wayland/variables.nix new file mode 100644 index 0000000..4da5d03 --- /dev/null +++ b/modules/wms/wayland/variables.nix @@ -0,0 +1,53 @@ +{config, lib, ... }: +with lib; +let + cfg = config.modules.wms.wayland; + hyprland = config.modules.wms.wayland.hyprland; +in { +options.modules.wms.wayland.enable = mkEnableOption "wayland"; +options.modules.wms.wayland.hyprland.enable = mkEnableOption "hyprland"; +config = mkIf cfg.enable { + environment = { + variables = { + NIXOS_OZONE_WL = "1"; + __GL_GSYNC_ALLOWED = "0"; + __GL_VRR_ALLOWED = "0"; + _JAVA_AWT_WM_NONEREPARENTING = "1"; + SSH_AUTH_SOCK = "/run/user/1000/keyring/ssh"; + DISABLE_QT5_COMPAT = "0"; + GDK_BACKEND = "wayland,x11"; + ANKI_WAYLAND = "1"; + DIRENV_LOG_FORMAT = ""; + WLR_DRM_NO_ATOMIC = "1"; + QT_AUTO_SCREEN_SCALE_FACTOR = "1"; + QT_QPA_PLATFORM = "wayland;xcb"; + DISABLE_QT_COMPAT = "0"; + QT_WAYLAND_DISABLE_WINDOWDECORATION = "1"; + MOZ_ENABLE_WAYLAND = "1"; + WLR_BACKEND = "vulkan"; + WLR_RENDERER = "vulkan"; + XDG_SESSION_TYPE = "wayland"; + SDL_VIDEODRIVER = "wayland"; + CLUTTER_BACKEND = "wayland"; + WLR_DRM_DEVICES = "/dev/dri/card1:/dev/dri/card0"; + + # Session variables for Hyprland + (mkIf hyprland.enable LIBVA_DRIVER_NAME = "nvidia"); + GTK_USE_PORTAL = "1"; + NIXOS_XDG_OPEN_USE_PORTAL = "1"; + XDG_CURRENT_DESKTOP = "Hyprland"; + XDG_SESSION_TYPE = "wayland"; + XDG_SESSION_DESKTOP = "Hyprland"; + SDL_VIDEODRIVER = "wayland"; + CLUTTER_BACKEND = "wayland"; + GDK_BACKEND = "wayland"; + WLR_RENDERER_ALLOW_SOFTWARE = "1"; + QT_QPA_PLATFORM = "wayland"; + # Needed anymore? + LIBSEAT_BACKEND = "logind"; + # WLR_NO_HARDWARE_CURSORS = "1"; + NIXOS_OZONE_WL = "1"; + }; + } + +} diff --git a/options/desktop/fonts.nix b/options/desktop/fonts.nix index c22be04..1e94f84 100644 --- a/options/desktop/fonts.nix +++ b/options/desktop/fonts.nix @@ -1,10 +1,30 @@ { pkgs, ... }: { - fonts.packages = with pkgs; [ - material-design-icons - (nerdfonts.override { fonts = [ "JetBrainsMono" ]; }) - noto-fonts - noto-fonts-cjk-sans - noto-fonts-cjk-serif - noto-fonts-emoji - ]; + fonts = { + packages = with pkgs; [ + material-icons + material-design-icons + (nerdfonts.override { fonts = [ "Iosevka" "JetBrainsMono" ]; }) + noto-fonts + noto-fonts-cjk + noto-fonts-cjk + noto-fonts-emoji + jetbrains-mono + lexend + ]; + # What does this do? + enableDefaultPackages = false; + + # this fixes emoji stuff + fontconfig = { + defaultFonts = { + monospace = [ + "JetBrainsMono Nerd Font" + "Noto Color Emoji" + ]; + sansSerif = ["Lexend" "Noto Color Emoji"]; + serif = ["Noto Serif" "Noto Color Emoji"]; + emoji = ["Noto Color Emoji"]; + }; + }; + } }