From f1b45216e9c3dbfd33fc03d5c0ca8a3cbb433cba Mon Sep 17 00:00:00 2001 From: Nydragon Date: Mon, 30 Dec 2024 12:19:44 +0100 Subject: [PATCH] feat: add uwsm config, runner setting and clean up some systemd services --- home/desktop/default.nix | 5 +++++ home/graphical/swww.nix | 3 +-- home/sway/default.nix | 18 ++++++++--------- home/themes/catppuccin.nix | 7 +------ home/themes/vanilla.nix | 31 ++++++++++++++++++++++++++++++ modules/programs/default.nix | 1 + modules/programs/uwsm.nix | 26 +++++++++++++++++++++++++ options/services/cliphist.nix | 2 +- options/services/nysh.nix | 3 +-- options/services/tailscale.nix | 3 +-- options/system/networking/wifi.nix | 13 +++++++++++++ options/system/roles/desktop.nix | 21 +++++++++++++++++++- 12 files changed, 110 insertions(+), 23 deletions(-) create mode 100644 home/themes/vanilla.nix create mode 100644 modules/programs/uwsm.nix diff --git a/home/desktop/default.nix b/home/desktop/default.nix index cf0955e..441b2bf 100644 --- a/home/desktop/default.nix +++ b/home/desktop/default.nix @@ -2,6 +2,7 @@ self, pkgs, lib, + osConfig, ... }: let @@ -24,5 +25,9 @@ in (mkURLEntry "KitchenOwl" "https://kitchenowl.ccnlc.eu" "${self}/assets/favicon-kitchenowl.png") (mkURLEntry "Discord" "https://discord.com/app" "${self}/assets/favicon-discord.png") ]; + mimeApps = { + enable = true; + defaultApplications = osConfig.xdg.mime.defaultApplications; + }; }; } diff --git a/home/graphical/swww.nix b/home/graphical/swww.nix index 86a7218..8aeea25 100644 --- a/home/graphical/swww.nix +++ b/home/graphical/swww.nix @@ -10,8 +10,7 @@ Install.WantedBy = [ "graphical-session.target" ]; Unit = { - After = [ "graphical-session-pre.target" ]; - PartOf = [ "graphical-session.target" ]; + After = [ "graphical-session.target" ]; }; Service = { Type = "simple"; diff --git a/home/sway/default.nix b/home/sway/default.nix index 00d6485..26af166 100644 --- a/home/sway/default.nix +++ b/home/sway/default.nix @@ -11,8 +11,8 @@ let inherit (lib.my) getExe getExe'; desktop = osConfig.modules.system.roles.desktop; - term = lib.my.getExe desktop.terminal; - filemanager = lib.my.getExe desktop.filemanager; + term = getExe desktop.terminal; + filemanager = getExe desktop.filemanager; cliphistEnabled = osConfig.modules.services.cliphist.enable; colors = { @@ -50,7 +50,6 @@ lib.mkIf osConfig.programs.sway.enable { swipe:up focus up swipe:down focus down } - workspace 1 font pango:monospace 0.001 ''; config = { @@ -62,9 +61,9 @@ lib.mkIf osConfig.programs.sway.enable { mod = config.wayland.windowManager.sway.config.modifier; in lib.mkOptionDefault { - "${mod}+p" = "exec ${pkgs.hyprlock}/bin/hyprlock"; + "${mod}+p" = "exec ${getExe pkgs.hyprlock}"; - "${mod}+Shift+p" = "exec rofi -show p -modi p:${pkgs.rofi-power-menu}/bin/rofi-power-menu"; + "${mod}+Shift+p" = "exec ${getExe pkgs.rofi} -show p -modi p:${getExe pkgs.rofi-power-menu}"; # Reload the config file "${mod}+Shift+c" = "reload"; # Kill the focused window @@ -72,14 +71,13 @@ lib.mkIf osConfig.programs.sway.enable { # Make focused window fullscreen "${mod}+f" = "fullscreen"; # Start launcher - "${mod}+d" = "exec ${pkgs.fuzzel}/bin/fuzzel"; + "${mod}+d" = "exec ${getExe desktop.runner.package}"; "${mod}+s" = let cliphist = getExe pkgs.cliphist; - fuzzel = getExe pkgs.fuzzel; copy = getExe' pkgs.wl-clipboard "wl-copy"; in - mkIf cliphistEnabled "exec ${cliphist} list | ${fuzzel} --dmenu | ${cliphist} decode | ${copy}"; + mkIf cliphistEnabled "exec ${cliphist} list | ${desktop.runner.dmenu} | ${cliphist} decode | ${copy}"; # Toggle the current focus between tiling and floating mode "${mod}+Shift+space" = "floating toggle"; "${mod}+Return" = "exec ${term}"; @@ -144,7 +142,9 @@ lib.mkIf osConfig.programs.sway.enable { }; seat = { "*" = { - xcursor_theme = "${config.home.pointerCursor.name} ${toString config.home.pointerCursor.size}"; + #xcursor_theme = mkIf ( + #config ? home.pointerCursor.name + #) "${config.home.pointerCursor.name} ${toString config.home.pointerCursor.size}"; keyboard_grouping = "none"; }; }; diff --git a/home/themes/catppuccin.nix b/home/themes/catppuccin.nix index 8cc6b6b..a4a4cf4 100644 --- a/home/themes/catppuccin.nix +++ b/home/themes/catppuccin.nix @@ -1,9 +1,4 @@ -{ - pkgs, - config, - lib, - ... -}: +{ pkgs, lib, ... }: let inherit (lib.my) validatePath; in diff --git a/home/themes/vanilla.nix b/home/themes/vanilla.nix new file mode 100644 index 0000000..df8057e --- /dev/null +++ b/home/themes/vanilla.nix @@ -0,0 +1,31 @@ +{ pkgs, lib, ... }: +{ + dconf = { + enable = true; + settings."org/gnome/desktop/interface".color-scheme = "prefer-dark"; + }; + + gtk = { + enable = true; + theme = { + name = "Adwaita"; + package = pkgs.gnome-themes-extra; + }; + }; + + qt = { + enable = true; + style = { + package = pkgs.adwaita-qt; + name = "Adwaita-dark"; + }; + }; + + home.pointerCursor = lib.mkDefault { + gtk.enable = true; + x11.enable = true; + name = "Bibata-Modern-Classic"; + package = pkgs.bibata-cursors; + size = 32; + }; +} diff --git a/modules/programs/default.nix b/modules/programs/default.nix index dd8961e..38e2693 100644 --- a/modules/programs/default.nix +++ b/modules/programs/default.nix @@ -8,5 +8,6 @@ ./hyprland.nix ./ssh.nix ./fish.nix + ./uwsm.nix ]; } diff --git a/modules/programs/uwsm.nix b/modules/programs/uwsm.nix new file mode 100644 index 0000000..a2704bf --- /dev/null +++ b/modules/programs/uwsm.nix @@ -0,0 +1,26 @@ +{ config, lib, ... }: +let + inherit (lib) mkIf; + cfg = config.programs.uwsm; +in +{ + config = mkIf cfg.enable { + services.dbus.implementation = lib.mkForce "dbus"; + + programs.uwsm = { + enable = true; + waylandCompositors = { + hyprland = mkIf config.programs.hyprland.enable { + prettyName = "Hyprland"; + comment = "Hyprland compositor managed by UWSM"; + binPath = "/run/current-system/sw/bin/Hyprland"; + }; + sway = mkIf config.programs.sway.enable { + prettyName = "Sway"; + comment = "Sway compositor managed by UWSM"; + binPath = "/run/current-system/sw/bin/sway"; + }; + }; + }; + }; +} diff --git a/options/services/cliphist.nix b/options/services/cliphist.nix index 1794f91..8777937 100644 --- a/options/services/cliphist.nix +++ b/options/services/cliphist.nix @@ -29,7 +29,7 @@ in config = mkIf cfg.enable { systemd.user.services.cliphist = { description = "Clipboard management daemon"; - partOf = [ "graphical-session.target" ]; + after = [ "graphical-session.target" ]; wantedBy = [ "graphical-session.target" ]; serviceConfig = { diff --git a/options/services/nysh.nix b/options/services/nysh.nix index 061cc34..abafc33 100644 --- a/options/services/nysh.nix +++ b/options/services/nysh.nix @@ -27,8 +27,7 @@ in pkgs.networkmanager ]; wantedBy = [ "graphical-session.target" ]; - partOf = [ "graphical-session.target" ]; - after = [ "graphical-session-pre.target" ]; + after = [ "graphical-session.target" ]; serviceConfig = { Type = "simple"; diff --git a/options/services/tailscale.nix b/options/services/tailscale.nix index 7f54f6f..33eb999 100644 --- a/options/services/tailscale.nix +++ b/options/services/tailscale.nix @@ -85,8 +85,7 @@ in systemd.user.services.tailscale-system-tray = mkIf cfg.systemTray { description = "tailscale system tray"; wantedBy = [ "graphical-session.target" ]; - wants = [ "graphical-session.target" ]; - after = [ "graphical-session-pre.target" ]; + after = [ "graphical-session.target" ]; path = [ pkgs.polkit ]; serviceConfig = { Type = "simple"; diff --git a/options/system/networking/wifi.nix b/options/system/networking/wifi.nix index c34df0a..c3decd9 100644 --- a/options/system/networking/wifi.nix +++ b/options/system/networking/wifi.nix @@ -10,5 +10,18 @@ in config = mkIf cfg.enable { networking.networkmanager.enable = true; + networking.firewall = mkIf config.modules.system.roles.desktop.enable { + # if packets are still dropped, they will show up in dmesg + logReversePathDrops = true; + # wireguard trips rpfilter up + extraCommands = '' + ip46tables -t mangle -I nixos-fw-rpfilter -p udp -m udp --sport 51820 -j RETURN + ip46tables -t mangle -I nixos-fw-rpfilter -p udp -m udp --dport 51820 -j RETURN + ''; + extraStopCommands = '' + ip46tables -t mangle -D nixos-fw-rpfilter -p udp -m udp --sport 51820 -j RETURN || true + ip46tables -t mangle -D nixos-fw-rpfilter -p udp -m udp --dport 51820 -j RETURN || true + ''; + }; }; } diff --git a/options/system/roles/desktop.nix b/options/system/roles/desktop.nix index 5889239..d4b3c30 100644 --- a/options/system/roles/desktop.nix +++ b/options/system/roles/desktop.nix @@ -6,7 +6,8 @@ }: let inherit (lib) mkEnableOption mkOption mkIf; - inherit (lib.types) package; + inherit (lib.types) package str; + inherit (lib.my) getExe; cfg = config.modules.system.roles.desktop; in { @@ -26,6 +27,24 @@ in default = pkgs.nautilus; description = ''''; }; + runner = { + package = mkOption { + type = package; + default = pkgs.fuzzel; + description = '' + The runner to use. + ''; + }; + + dmenu = mkOption { + type = str; + default = "--dmenu"; + apply = val: "${getExe cfg.runner.package} ${val}"; + description = '' + Flags necessary to execute the runner in its dmenu compatibility mode. + ''; + }; + }; }; config = mkIf cfg.enable { environment.systemPackages = [