From d463f4d1afecd29d08e5c90e2ec5574f4d5c0339 Mon Sep 17 00:00:00 2001 From: Nickolaj Jepsen Date: Fri, 12 Dec 2025 04:02:55 +0100 Subject: [PATCH] refactor: desktop legacy module --- hosts/default.nix | 1 + hosts/desktop/configuration.nix | 3 + hosts/laptop/configuration copy.nix | 3 + hosts/work/configuration.nix | 3 + justfile | 2 +- legacy_modules/desktop/dms/default.nix | 70 ---- legacy_modules/desktop/dms/theme.nix | 43 --- legacy_modules/desktop/fonts.nix | 6 - legacy_modules/desktop/greetd.nix | 10 - legacy_modules/desktop/gtk/default.nix | 47 --- legacy_modules/desktop/niri.nix | 326 ----------------- legacy_modules/desktop/qt.nix | 7 - legacy_modules/dev/aider.nix | 25 -- legacy_modules/devenv.nix | 1 - legacy_modules/graphical.nix | 9 - .../hardware => modules/desktop}/audio.nix | 4 +- modules/desktop/default.nix | 26 ++ .../desktop/dms/background.nix | 35 +- .../desktop/dms/backgrounds/geometry.svg | 0 .../desktop/dms/backgrounds/unknown.svg | 0 .../desktop/dms/bar.nix | 26 +- modules/desktop/dms/default.nix | 74 ++++ modules/desktop/dms/theme.nix | 50 +++ modules/desktop/fonts.nix | 13 + modules/desktop/greetd.nix | 17 + modules/desktop/gtk/default.nix | 54 +++ .../desktop/gtk/theme.css | 0 .../hardware => modules/desktop}/monitors.nix | 0 modules/desktop/niri.nix | 328 ++++++++++++++++++ modules/desktop/qt.nix | 13 + .../desktop/screenshot.nix | 11 +- 31 files changed, 630 insertions(+), 577 deletions(-) create mode 100644 hosts/desktop/configuration.nix create mode 100644 hosts/laptop/configuration copy.nix create mode 100644 hosts/work/configuration.nix delete mode 100644 legacy_modules/desktop/dms/default.nix delete mode 100644 legacy_modules/desktop/dms/theme.nix delete mode 100644 legacy_modules/desktop/fonts.nix delete mode 100644 legacy_modules/desktop/greetd.nix delete mode 100644 legacy_modules/desktop/gtk/default.nix delete mode 100644 legacy_modules/desktop/niri.nix delete mode 100644 legacy_modules/desktop/qt.nix delete mode 100644 legacy_modules/dev/aider.nix rename {legacy_modules/hardware => modules/desktop}/audio.nix (69%) create mode 100644 modules/desktop/default.nix rename {legacy_modules => modules}/desktop/dms/background.nix (55%) rename {legacy_modules => modules}/desktop/dms/backgrounds/geometry.svg (100%) rename {legacy_modules => modules}/desktop/dms/backgrounds/unknown.svg (100%) rename {legacy_modules => modules}/desktop/dms/bar.nix (79%) create mode 100644 modules/desktop/dms/default.nix create mode 100644 modules/desktop/dms/theme.nix create mode 100644 modules/desktop/fonts.nix create mode 100644 modules/desktop/greetd.nix create mode 100644 modules/desktop/gtk/default.nix rename {legacy_modules => modules}/desktop/gtk/theme.css (100%) rename {legacy_modules/hardware => modules/desktop}/monitors.nix (100%) create mode 100644 modules/desktop/niri.nix create mode 100644 modules/desktop/qt.nix rename {legacy_modules => modules}/desktop/screenshot.nix (73%) diff --git a/hosts/default.nix b/hosts/default.nix index c5ea993..37cebd8 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -42,6 +42,7 @@ with lib; let inputs.niri.nixosModules.niri ../modules/base ../modules/programs + ../modules/desktop (mkSystemImports hostname) {nixpkgs.config.allowUnfree = true;} ] diff --git a/hosts/desktop/configuration.nix b/hosts/desktop/configuration.nix new file mode 100644 index 0000000..f12460b --- /dev/null +++ b/hosts/desktop/configuration.nix @@ -0,0 +1,3 @@ +{ + fireproof.desktop.enable = true; +} \ No newline at end of file diff --git a/hosts/laptop/configuration copy.nix b/hosts/laptop/configuration copy.nix new file mode 100644 index 0000000..f12460b --- /dev/null +++ b/hosts/laptop/configuration copy.nix @@ -0,0 +1,3 @@ +{ + fireproof.desktop.enable = true; +} \ No newline at end of file diff --git a/hosts/work/configuration.nix b/hosts/work/configuration.nix new file mode 100644 index 0000000..f12460b --- /dev/null +++ b/hosts/work/configuration.nix @@ -0,0 +1,3 @@ +{ + fireproof.desktop.enable = true; +} \ No newline at end of file diff --git a/justfile b/justfile index 34f3399..7d677c0 100644 --- a/justfile +++ b/justfile @@ -36,7 +36,7 @@ switch hostname=`hostname -s` target='': #!/usr/bin/env -S bash -e target="{{ target }}" if [ -z "$target" ]; then - sudo {{ nixcmd }} run nixpkgs#nixos-rebuild -- switch --fast --flake .#{{ hostname }} {{ nix_output_monitor }} + sudo {{ nixcmd }} run nixpkgs#nixos-rebuild -- switch --show-trace --fast --flake .#{{ hostname }} else {{ nixcmd }} run nixpkgs#nixos-rebuild -- switch \ --flake .#{{ hostname }} \ diff --git a/legacy_modules/desktop/dms/default.nix b/legacy_modules/desktop/dms/default.nix deleted file mode 100644 index 328e03f..0000000 --- a/legacy_modules/desktop/dms/default.nix +++ /dev/null @@ -1,70 +0,0 @@ -{ - inputs, - pkgs, - ... -}: { - imports = [ - ./theme.nix - ./background.nix - ./bar.nix - ]; - - systemd.user.services.niri-flake-polkit.enable = false; - - fireproof.home-manager = { - imports = [ - inputs.dankMaterialShell.homeModules.dankMaterialShell.default - ]; - - programs.dankMaterialShell = { - enable = true; - - enableDynamicTheming = false; - enableClipboard = false; - enableVPN = false; - enableCalendarEvents = false; - - default.settings = { - # General Settings - weatherCoordinates = "56.1496278,10.2134046"; - - # Lock Screen - loginctlLockIntegration = true; - fadeToLockEnabled = true; - fadeToLockGracePeriod = 5; - - acMonitorTimeout = 1800; - acLockTimeout = 600; - acSuspendTimeout = 0; - batteryMonitorTimeout = 600; - batteryLockTimeout = 300; - batterySuspendTimeout = 1800; - - # Power Menu - powerMenuActions = [ - "reboot" - "logout" - "poweroff" - "lock" - "suspend" - ]; - powerMenuDefaultAction = "lock"; - }; - }; - - systemd.user.services = { - # A hack to always serve fresh settings from default-settings.json - dms-clean-settings = { - Unit = { - Description = "Delete DankMaterialShell settings before dms starts"; - Before = ["dms.service"]; - }; - Service = { - Type = "oneshot"; - ExecStart = "${pkgs.coreutils}/bin/rm -f %h/.config/DankMaterialShell/settings.json"; - }; - Install.WantedBy = ["dms.service"]; - }; - }; - }; -} diff --git a/legacy_modules/desktop/dms/theme.nix b/legacy_modules/desktop/dms/theme.nix deleted file mode 100644 index a5d9c34..0000000 --- a/legacy_modules/desktop/dms/theme.nix +++ /dev/null @@ -1,43 +0,0 @@ -{username, ...}: { - fireproof.home-manager = { - home.file.".config/DankMaterialShell/colors.json".text = builtins.toJSON { - name = "custom"; - primary = "#CF6A4C"; - primaryText = "#F2F0E5"; - primaryContainer = "#403E3C"; - secondary = "#CE5D97"; - surface = "#343331"; - surfaceText = "#DAD8CE"; - surfaceVariant = "#1C1B1A"; - surfaceVariantText = "#B7B5AC"; - surfaceTint = "#CF6A4C"; - background = "#100F0F"; - backgroundText = "#F2F0E5"; - outline = "#878580"; - surfaceContainer = "#1C1B1A"; - surfaceContainerHigh = "#282726"; - surfaceContainerHighest = "#403E3C"; - error = "#D14D41"; - warning = "#D0A215"; - info = "#4385BE"; - matugen_type = "scheme-expressive"; - }; - - programs.dankMaterialShell.default.settings = { - # Color theme - currentThemeName = "custom"; - customThemeFile = "/home/${username}/.config/DankMaterialShell/colors.json"; - widgetBackgroundColor = "sth"; - widgetColorMode = "default"; - - # General - cornerRadius = 8; - - # Font - fontFamily = "Inter Variable"; - monoFontFamily = "Hack Nerd Font Mono"; - fontWeight = 400; - fontScale = 1; - }; - }; -} diff --git a/legacy_modules/desktop/fonts.nix b/legacy_modules/desktop/fonts.nix deleted file mode 100644 index a22d280..0000000 --- a/legacy_modules/desktop/fonts.nix +++ /dev/null @@ -1,6 +0,0 @@ -{pkgs, ...}: { - fonts.enableDefaultPackages = true; - fonts.packages = with pkgs; [ - nerd-fonts.hack - ]; -} diff --git a/legacy_modules/desktop/greetd.nix b/legacy_modules/desktop/greetd.nix deleted file mode 100644 index 7b8f2bc..0000000 --- a/legacy_modules/desktop/greetd.nix +++ /dev/null @@ -1,10 +0,0 @@ -{pkgs, ...}: { - services.greetd = { - enable = true; - settings = { - default_session = { - command = "${pkgs.tuigreet}/bin/tuigreet --user-menu"; - }; - }; - }; -} diff --git a/legacy_modules/desktop/gtk/default.nix b/legacy_modules/desktop/gtk/default.nix deleted file mode 100644 index 4bdf971..0000000 --- a/legacy_modules/desktop/gtk/default.nix +++ /dev/null @@ -1,47 +0,0 @@ -{pkgs, ...}: { - environment.systemPackages = with pkgs; [ - nautilus - gnome-photos - ]; - - services.gvfs.enable = true; - programs = { - dconf.enable = true; - nautilus-open-any-terminal.enable = true; - seahorse.enable = true; - evince.enable = true; - }; - - services.gnome.sushi.enable = true; - - fireproof.home-manager = { - home.pointerCursor = { - gtk.enable = true; - name = "Adwaita"; - package = pkgs.adwaita-icon-theme; - size = 24; - }; - - gtk = { - enable = true; - theme = { - name = "adw-gtk3-dark"; - package = pkgs.adw-gtk3; - }; - iconTheme = { - name = "Qogir-dark"; - package = pkgs.qogir-icon-theme; - }; - - gtk3.extraConfig = {gtk-application-prefer-dark-theme = true;}; - gtk3.extraCss = builtins.readFile ./theme.css; - - gtk4.extraConfig = {gtk-application-prefer-dark-theme = true;}; - gtk4.extraCss = builtins.readFile ./theme.css; - }; - dconf = { - enable = true; - settings."org/gnome/desktop/interface".color-scheme = "prefer-dark"; - }; - }; -} diff --git a/legacy_modules/desktop/niri.nix b/legacy_modules/desktop/niri.nix deleted file mode 100644 index 0e64e23..0000000 --- a/legacy_modules/desktop/niri.nix +++ /dev/null @@ -1,326 +0,0 @@ -{ - pkgs, - inputs, - config, - lib, - ... -}: let - primaryMonitorName = (builtins.head config.monitors).name or ""; -in { - # TODO: Move these to a separate module - programs.xwayland.enable = true; - - fireproof.home-manager.programs.waybar = { - enable = true; - systemd.enable = true; - systemd.target = "niri.target"; - settings = { - bar = { - layer = "top"; - position = "top"; - modules-left = ["clock" "niri/workspaces"]; - modules-center = ["niri/window"]; - modules-right = ["backlight" "battery" "pulseaudio" "tray"]; - - pulseaudio = { - format = "{volume}% {icon}"; - format-muted = "󰝟 "; - format-icons = { - default = ["󰕿 " "󰖀 " "󰕾 "]; - headphone = "󰋋 "; - }; - on-click = "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; - }; - }; - }; - style = '' - * { - font-family: Hack Nerd Font Mono; - font-size: 14px; - } - window#waybar, #clock, #pulseaudio, #battery, #backlight, #tray { - background: #1C1B1A; - color: #DAD8CE; - border-bottom: 2px solid #CF6A4C; - } - - #workspaces button.focused { - background: #CF6A4C; - color: #1C1B1A; - box-shadow: 0 0 0 #CF6A4C; - } - - /* Default */ - button { - /* Use box-shadow instead of border so the text isn't offset */ - box-shadow: inset 0 -3px transparent; - /* Avoid rounded borders under each button name */ - border: none; - border-radius: 0; - } - - /* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */ - button:hover { - background: inherit; - box-shadow: inset 0 -3px #ffffff; - } - - /* you can set a style on hover for any module like this */ - #pulseaudio:hover { - background-color: #a37800; - } - - #workspaces button { - padding: 0 5px; - background-color: transparent; - color: #ffffff; - } - - #workspaces button:hover { - background: rgba(0, 0, 0, 0.2); - } - - #workspaces button.urgent { - background-color: #eb4d4b; - } - - #window, - #workspaces { - margin: 0 4px; - } - - - #tray > .passive { - -gtk-icon-effect: dim; - } - - #tray > .needs-attention { - -gtk-icon-effect: highlight; - background-color: #eb4d4b; - }''; - }; - - xdg.portal = { - enable = true; - extraPortals = [pkgs.xdg-desktop-portal-gtk]; - config.common.default = "gnome"; - xdgOpenUsePortal = true; - }; - programs.niri = { - enable = true; - package = inputs.niri.packages."${pkgs.system}".niri-unstable; - }; - fireproof.home-manager.programs.niri.settings = { - prefer-no-csd = true; - clipboard.disable-primary = true; - spawn-at-startup = [ - {command = ["systemctl" "--user" "start" "hypridle"];} - {command = ["systemctl" "--user" "start" "hyprpaper"];} - {command = ["systemctl" "--user" "start" "mako"];} - {command = ["systemctl" "--user" "start" "waybar"];} - ]; - xwayland-satellite = { - enable = true; - path = lib.getExe inputs.niri.packages."${pkgs.system}".xwayland-satellite-unstable; - }; - environment = { - NIXOS_OZONE_WL = "1"; - GDK_BACKEND = "wayland"; # Attempt to fix screen recording issue - }; - layout = { - gaps = 10; - focus-ring.enable = false; - insert-hint.display.color = "#CF6A4C"; - border = { - enable = true; - width = 2; - active.color = "#CF6A4C"; - inactive.color = "#343331"; - }; - tab-indicator = { - hide-when-single-tab = true; - place-within-column = true; - gap = 2; - position = "top"; - corner-radius = 8; - }; - }; - input = { - focus-follows-mouse = { - enable = true; - max-scroll-amount = "0%"; - }; - mouse.accel-profile = "flat"; - keyboard.xkb.layout = "eu"; - }; - window-rules = [ - { - clip-to-geometry = true; - geometry-corner-radius = { - top-left = 8.0; - top-right = 8.0; - bottom-left = 8.0; - bottom-right = 8.0; - }; - } - ]; - - workspaces = lib.mkIf (primaryMonitorName != "") { - "01" = { - open-on-output = primaryMonitorName; - }; - "02" = { - open-on-output = primaryMonitorName; - }; - "03" = { - open-on-output = primaryMonitorName; - }; - "04" = { - open-on-output = primaryMonitorName; - }; - "05" = { - open-on-output = primaryMonitorName; - }; - }; - - binds = { - "XF86AudioRaiseVolume" = { - allow-when-locked = true; - action.spawn = ["dms" "ipc" "audio" "increment" "3"]; - }; - "XF86AudioLowerVolume" = { - allow-when-locked = true; - action.spawn = ["dms" "ipc" "audio" "decrement" "3"]; - }; - "XF86AudioMute" = { - allow-when-locked = true; - action.spawn = ["dms" "ipc" "audio" "mute"]; - }; - "XF86AudioMicMute" = { - allow-when-locked = true; - action.spawn = ["dms" "ipc" "audio" "micmute"]; - }; - "XF86MonBrightnessUp" = { - allow-when-locked = true; - action.spawn = ["dms" "ipc" "brightness" "increment" "5"]; - }; - "XF86MonBrightnessDown" = { - allow-when-locked = true; - action.spawn = ["dms" "ipc" "brightness" "decrement" "5"]; - }; - "Mod+N" = { - action.spawn = ["dms" "ipc" "notifications" "toggle"]; - hotkey-overlay.title = "Toggle Notification Center"; - }; - "Mod+V" = { - action.spawn = ["dms" "ipc" "clipboard" "toggle"]; - hotkey-overlay.title = "Toggle Clipboard Manager"; - }; - "Mod+Space" = { - action.spawn = ["dms" "ipc" "spotlight" "toggle"]; - hotkey-overlay.title = "Toggle Application Launcher"; - }; - "Mod+P" = { - action.spawn = ["dms" "ipc" "powermenu" "toggle"]; - hotkey-overlay.title = "Toggle Power Menu"; - }; - - "Mod+Left".action.focus-column-or-monitor-left = {}; - "Mod+Down".action.focus-window-or-monitor-down = {}; - "Mod+Up".action.focus-window-or-monitor-up = {}; - "Mod+Right".action.focus-column-or-monitor-right = {}; - "Mod+H".action.focus-column-or-monitor-left = {}; - "Mod+J".action.focus-window-or-monitor-down = {}; - "Mod+K".action.focus-window-or-monitor-up = {}; - "Mod+L".action.focus-column-or-monitor-right = {}; - - "Mod+Shift+Left".action.move-column-left-or-to-monitor-left = {}; - "Mod+Shift+Down".action.move-window-down = {}; - "Mod+Shift+Up".action.move-window-up = {}; - "Mod+Shift+Right".action.move-column-right-or-to-monitor-right = {}; - "Mod+Shift+H".action.move-column-left-or-to-monitor-left = {}; - "Mod+Shift+J".action.move-window-down = {}; - "Mod+Shift+K".action.move-window-up = {}; - "Mod+Shift+L".action.move-column-right-or-to-monitor-right = {}; - - "Mod+Home".action.focus-column-first = {}; - "Mod+End".action.focus-column-last = {}; - "Mod+Shift+Home".action.move-column-to-first = {}; - "Mod+Shift+End".action.move-column-to-last = {}; - - "Mod+Ctrl+Left".action.focus-monitor-left = {}; - "Mod+Ctrl+Down".action.focus-monitor-down = {}; - "Mod+Ctrl+Up".action.focus-monitor-up = {}; - "Mod+Ctrl+Right".action.focus-monitor-right = {}; - "Mod+Ctrl+H".action.focus-monitor-left = {}; - "Mod+Ctrl+J".action.focus-monitor-down = {}; - "Mod+Ctrl+K".action.focus-monitor-up = {}; - "Mod+Ctrl+L".action.focus-monitor-right = {}; - - "Mod+F".action.maximize-column = {}; - "Mod+Shift+F".action.fullscreen-window = {}; - "Mod+M".action.toggle-column-tabbed-display = {}; - "Mod+A".action.toggle-overview = {}; - "Mod+S".action.toggle-window-floating = {}; - "Mod+C".action.switch-preset-column-width = {}; - - "Mod+Z".action.set-column-width = "-5%"; - "Mod+X".action.set-column-width = "+5%"; - "Mod+Ctrl+X".action.expand-column-to-available-width = {}; - "Mod+Shift+Z".action.set-window-height = "-5%"; - "Mod+Shift+X".action.set-window-height = "+5%"; - - "Mod+Shift+WheelScrollDown".action.focus-workspace-down = {}; - "Mod+Shift+WheelScrollUp".action.focus-workspace-up = {}; - "Mod+WheelScrollDown".action.focus-column-right = {}; - "Mod+WheelScrollUp".action.focus-column-left = {}; - - "Mod+WheelScrollRight".action.focus-column-right = {}; - "Mod+WheelScrollLeft".action.focus-column-left = {}; - "Mod+Shift+WheelScrollRight".action.move-column-right = {}; - "Mod+Shift+WheelScrollLeft".action.move-column-left = {}; - - "Mod+q".action.focus-workspace = "01"; - "Mod+w".action.focus-workspace = "02"; - "Mod+e".action.focus-workspace = "03"; - "Mod+r".action.focus-workspace = "04"; - "Mod+t".action.focus-workspace = "05"; - "Mod+Shift+q".action.move-column-to-workspace = "01"; - "Mod+Shift+w".action.move-column-to-workspace = "02"; - "Mod+Shift+e".action.move-column-to-workspace = "03"; - "Mod+Shift+r".action.move-column-to-workspace = "04"; - "Mod+Shift+t".action.move-column-to-workspace = "05"; - - "Mod+Comma".action.consume-or-expel-window-left = {}; - "Mod+Period".action.consume-or-expel-window-right = {}; - - "Print".action.screenshot = {}; - "Ctrl+Print".action.screenshot-screen = {}; - "Alt+Print".action.screenshot-window = {}; - - "Mod+Slash".action.show-hotkey-overlay = {}; - - "Mod+Return".action.spawn = ["ghostty"]; - "Mod+Backspace".action.close-window = {}; - }; - - outputs = lib.mkIf (config.monitors != []) ( - lib.listToAttrs (map (monitor: { - inherit (monitor) name; - value = { - inherit (monitor) position; - mode = { - inherit (monitor.resolution) width height; - refresh = monitor.refreshRateNiri or null; - }; - focus-at-startup = monitor.name == primaryMonitorName; - transform.rotation = - if (monitor.transform != null) - then monitor.transform * 90 - else 0; - }; - }) - config.monitors) - ); - }; -} diff --git a/legacy_modules/desktop/qt.nix b/legacy_modules/desktop/qt.nix deleted file mode 100644 index 7f5f4a3..0000000 --- a/legacy_modules/desktop/qt.nix +++ /dev/null @@ -1,7 +0,0 @@ -_: { - qt = { - enable = true; - platformTheme = "gnome"; - style = "adwaita-dark"; - }; -} diff --git a/legacy_modules/dev/aider.nix b/legacy_modules/dev/aider.nix deleted file mode 100644 index 8603e6e..0000000 --- a/legacy_modules/dev/aider.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ - pkgsUnstable, - username, - config, - ... -}: { - age.secrets.llm-api-key = { - rekeyFile = ../../secrets/llm-api-key.env.age; - mode = "0600"; - owner = username; - }; - - environment.systemPackages = with pkgsUnstable; [ - aider-chat - ]; - fireproof.home-manager = { - home.file.".aider.conf.yml".text = '' - # Aider configuration file - # This file is used to configure the Aider chat client - # It is a YAML file - sonnet: true - env-file: ${config.age.secrets.llm-api-key.path} - ''; - }; -} diff --git a/legacy_modules/devenv.nix b/legacy_modules/devenv.nix index 636e9b9..1b355b5 100644 --- a/legacy_modules/devenv.nix +++ b/legacy_modules/devenv.nix @@ -9,7 +9,6 @@ ./dev/docker.nix ./dev/tilt.nix ./dev/postgres.nix - ./dev/aider.nix ./dev/clickhouse.nix ./dev/playwright.nix ./dev/nats.nix diff --git a/legacy_modules/graphical.nix b/legacy_modules/graphical.nix index af540dc..16035d3 100644 --- a/legacy_modules/graphical.nix +++ b/legacy_modules/graphical.nix @@ -1,14 +1,5 @@ { imports = [ - ./hardware/monitors.nix - ./hardware/audio.nix - ./desktop/fonts.nix - ./desktop/greetd.nix - ./desktop/niri.nix - ./desktop/gtk/default.nix - ./desktop/qt.nix - ./desktop/dms/default.nix - ./desktop/screenshot.nix ./apps/spotify.nix ./apps/firefox.nix ./apps/chromium.nix diff --git a/legacy_modules/hardware/audio.nix b/modules/desktop/audio.nix similarity index 69% rename from legacy_modules/hardware/audio.nix rename to modules/desktop/audio.nix index bb5ae33..c4b7ac5 100644 --- a/legacy_modules/hardware/audio.nix +++ b/modules/desktop/audio.nix @@ -1,5 +1,5 @@ -_: { - config = { +{ lib, config, ... }: { + config = lib.mkIf config.fireproof.desktop.enable { security.rtkit.enable = true; services.pipewire = { enable = true; diff --git a/modules/desktop/default.nix b/modules/desktop/default.nix new file mode 100644 index 0000000..c10dff1 --- /dev/null +++ b/modules/desktop/default.nix @@ -0,0 +1,26 @@ +{ + config, + lib, + ... +}: { + options.fireproof.desktop = { + enable = lib.mkEnableOption "Enable desktop environment with niri, greetd, and all desktop features"; + }; + + imports = [ + ./monitors.nix + ./audio.nix + ./fonts.nix + ./greetd.nix + ./niri.nix + ./qt.nix + ./screenshot.nix + ./gtk/default.nix + ./dms/default.nix + ]; + + config = lib.mkIf config.fireproof.desktop.enable { + # All desktop-related configuration is handled by the individual modules + # which check for fireproof.desktop.enable + }; +} diff --git a/legacy_modules/desktop/dms/background.nix b/modules/desktop/dms/background.nix similarity index 55% rename from legacy_modules/desktop/dms/background.nix rename to modules/desktop/dms/background.nix index ef7afe6..cc113af 100644 --- a/legacy_modules/desktop/dms/background.nix +++ b/modules/desktop/dms/background.nix @@ -1,6 +1,7 @@ { - pkgs, + config, lib, + pkgs, ... }: let background = pkgs.stdenvNoCC.mkDerivation { @@ -34,24 +35,26 @@ geometryPng ]; in { - fireproof.home-manager = { - # Use hyprpaper as we can't currently set wallpapers through DMS - services.hyprpaper = { - enable = true; - settings = { - preload = pngs; - wallpaper = [",${builtins.head pngs}"]; + config = lib.mkIf config.fireproof.desktop.enable { + fireproof.home-manager = { + # Use hyprpaper as we can't currently set wallpapers through DMS + services.hyprpaper = { + enable = true; + settings = { + preload = pngs; + wallpaper = [",${builtins.head pngs}"]; + }; }; - }; - programs.dankMaterialShell.default.settings = { - # Disables wallpaper management in DMS to avoid conflicts with Hyprpaper - screenPreferences.wallpaper = []; - }; + programs.dankMaterialShell.default.settings = { + # Disables wallpaper management in DMS to avoid conflicts with Hyprpaper + screenPreferences.wallpaper = []; + }; - programs.dankMaterialShell.default.session = { - # Attempt to set a default wallpaper on first run - wallpaperPath = unknownPng; + programs.dankMaterialShell.default.session = { + # Attempt to set a default wallpaper on first run + wallpaperPath = unknownPng; + }; }; }; } diff --git a/legacy_modules/desktop/dms/backgrounds/geometry.svg b/modules/desktop/dms/backgrounds/geometry.svg similarity index 100% rename from legacy_modules/desktop/dms/backgrounds/geometry.svg rename to modules/desktop/dms/backgrounds/geometry.svg diff --git a/legacy_modules/desktop/dms/backgrounds/unknown.svg b/modules/desktop/dms/backgrounds/unknown.svg similarity index 100% rename from legacy_modules/desktop/dms/backgrounds/unknown.svg rename to modules/desktop/dms/backgrounds/unknown.svg diff --git a/legacy_modules/desktop/dms/bar.nix b/modules/desktop/dms/bar.nix similarity index 79% rename from legacy_modules/desktop/dms/bar.nix rename to modules/desktop/dms/bar.nix index 5032b9d..4c72bd8 100644 --- a/legacy_modules/desktop/dms/bar.nix +++ b/modules/desktop/dms/bar.nix @@ -1,4 +1,8 @@ -{config, ...}: let +{ + config, + lib, + ... +}: let commonBarSettings = { enabled = true; position = 0; @@ -74,18 +78,20 @@ } // commonBarSettings; in { - fireproof.home-manager = { - programs.dankMaterialShell.default.settings = { - launcherLogoMode = "os"; - launcherLogoContrast = 1; - launcherLogoSizeOffset = 3; + config = lib.mkIf config.fireproof.desktop.enable { + fireproof.home-manager = { + programs.dankMaterialShell.default.settings = { + launcherLogoMode = "os"; + launcherLogoContrast = 1; + launcherLogoSizeOffset = 3; - centeringMode = "geometric"; + centeringMode = "geometric"; - runningAppsCurrentWorkspace = true; - runningAppsGroupByApp = true; + runningAppsCurrentWorkspace = true; + runningAppsGroupByApp = true; - barConfigs = [primaryBar secondaryBar]; + barConfigs = [primaryBar secondaryBar]; + }; }; }; } diff --git a/modules/desktop/dms/default.nix b/modules/desktop/dms/default.nix new file mode 100644 index 0000000..bb72843 --- /dev/null +++ b/modules/desktop/dms/default.nix @@ -0,0 +1,74 @@ +{ + config, + lib, + inputs, + pkgs, + ... +}: { + imports = [ + ./theme.nix + ./background.nix + ./bar.nix + ]; + + config = lib.mkIf config.fireproof.desktop.enable { + systemd.user.services.niri-flake-polkit.enable = false; + + fireproof.home-manager = { + imports = [ + inputs.dankMaterialShell.homeModules.dankMaterialShell.default + ]; + + programs.dankMaterialShell = { + enable = true; + + enableDynamicTheming = false; + enableClipboard = false; + enableVPN = false; + enableCalendarEvents = false; + + default.settings = { + # General Settings + weatherCoordinates = "56.1496278,10.2134046"; + + # Lock Screen + loginctlLockIntegration = true; + fadeToLockEnabled = true; + fadeToLockGracePeriod = 5; + + acMonitorTimeout = 1800; + acLockTimeout = 600; + acSuspendTimeout = 0; + batteryMonitorTimeout = 600; + batteryLockTimeout = 300; + batterySuspendTimeout = 1800; + + # Power Menu + powerMenuActions = [ + "reboot" + "logout" + "poweroff" + "lock" + "suspend" + ]; + powerMenuDefaultAction = "lock"; + }; + }; + + systemd.user.services = { + # A hack to always serve fresh settings from default-settings.json + dms-clean-settings = { + Unit = { + Description = "Delete DankMaterialShell settings before dms starts"; + Before = ["dms.service"]; + }; + Service = { + Type = "oneshot"; + ExecStart = "${pkgs.coreutils}/bin/rm -f %h/.config/DankMaterialShell/settings.json"; + }; + Install.WantedBy = ["dms.service"]; + }; + }; + }; + }; +} diff --git a/modules/desktop/dms/theme.nix b/modules/desktop/dms/theme.nix new file mode 100644 index 0000000..e4805ef --- /dev/null +++ b/modules/desktop/dms/theme.nix @@ -0,0 +1,50 @@ +{ + config, + lib, + username, + ... +}: { + config = lib.mkIf config.fireproof.desktop.enable { + fireproof.home-manager = { + home.file.".config/DankMaterialShell/colors.json".text = builtins.toJSON { + name = "custom"; + primary = "#CF6A4C"; + primaryText = "#F2F0E5"; + primaryContainer = "#403E3C"; + secondary = "#CE5D97"; + surface = "#343331"; + surfaceText = "#DAD8CE"; + surfaceVariant = "#1C1B1A"; + surfaceVariantText = "#B7B5AC"; + surfaceTint = "#CF6A4C"; + background = "#100F0F"; + backgroundText = "#F2F0E5"; + outline = "#878580"; + surfaceContainer = "#1C1B1A"; + surfaceContainerHigh = "#282726"; + surfaceContainerHighest = "#403E3C"; + error = "#D14D41"; + warning = "#D0A215"; + info = "#4385BE"; + matugen_type = "scheme-expressive"; + }; + + programs.dankMaterialShell.default.settings = { + # Color theme + currentThemeName = "custom"; + customThemeFile = "/home/${username}/.config/DankMaterialShell/colors.json"; + widgetBackgroundColor = "sth"; + widgetColorMode = "default"; + + # General + cornerRadius = 8; + + # Font + fontFamily = "Inter Variable"; + monoFontFamily = "Hack Nerd Font Mono"; + fontWeight = 400; + fontScale = 1; + }; + }; + }; +} diff --git a/modules/desktop/fonts.nix b/modules/desktop/fonts.nix new file mode 100644 index 0000000..e944eb0 --- /dev/null +++ b/modules/desktop/fonts.nix @@ -0,0 +1,13 @@ +{ + config, + lib, + pkgs, + ... +}: { + config = lib.mkIf config.fireproof.desktop.enable { + fonts.enableDefaultPackages = true; + fonts.packages = with pkgs; [ + nerd-fonts.hack + ]; + }; +} diff --git a/modules/desktop/greetd.nix b/modules/desktop/greetd.nix new file mode 100644 index 0000000..bb77715 --- /dev/null +++ b/modules/desktop/greetd.nix @@ -0,0 +1,17 @@ +{ + config, + lib, + pkgs, + ... +}: { + config = lib.mkIf config.fireproof.desktop.enable { + services.greetd = { + enable = true; + settings = { + default_session = { + command = "${pkgs.tuigreet}/bin/tuigreet --user-menu"; + }; + }; + }; + }; +} diff --git a/modules/desktop/gtk/default.nix b/modules/desktop/gtk/default.nix new file mode 100644 index 0000000..50efd7c --- /dev/null +++ b/modules/desktop/gtk/default.nix @@ -0,0 +1,54 @@ +{ + config, + lib, + pkgs, + ... +}: { + config = lib.mkIf config.fireproof.desktop.enable { + environment.systemPackages = with pkgs; [ + nautilus + gnome-photos + ]; + + services.gvfs.enable = true; + programs = { + dconf.enable = true; + nautilus-open-any-terminal.enable = true; + seahorse.enable = true; + evince.enable = true; + }; + + services.gnome.sushi.enable = true; + + fireproof.home-manager = { + home.pointerCursor = { + gtk.enable = true; + name = "Adwaita"; + package = pkgs.adwaita-icon-theme; + size = 24; + }; + + gtk = { + enable = true; + theme = { + name = "adw-gtk3-dark"; + package = pkgs.adw-gtk3; + }; + iconTheme = { + name = "Qogir-dark"; + package = pkgs.qogir-icon-theme; + }; + + gtk3.extraConfig = {gtk-application-prefer-dark-theme = true;}; + gtk3.extraCss = builtins.readFile ./theme.css; + + gtk4.extraConfig = {gtk-application-prefer-dark-theme = true;}; + gtk4.extraCss = builtins.readFile ./theme.css; + }; + dconf = { + enable = true; + settings."org/gnome/desktop/interface".color-scheme = "prefer-dark"; + }; + }; + }; +} diff --git a/legacy_modules/desktop/gtk/theme.css b/modules/desktop/gtk/theme.css similarity index 100% rename from legacy_modules/desktop/gtk/theme.css rename to modules/desktop/gtk/theme.css diff --git a/legacy_modules/hardware/monitors.nix b/modules/desktop/monitors.nix similarity index 100% rename from legacy_modules/hardware/monitors.nix rename to modules/desktop/monitors.nix diff --git a/modules/desktop/niri.nix b/modules/desktop/niri.nix new file mode 100644 index 0000000..eae2735 --- /dev/null +++ b/modules/desktop/niri.nix @@ -0,0 +1,328 @@ +{ + config, + lib, + pkgs, + inputs, + ... +}: let + primaryMonitorName = (builtins.head config.monitors).name or ""; +in { + config = lib.mkIf config.fireproof.desktop.enable { + # TODO: Move these to a separate module + programs.xwayland.enable = true; + + fireproof.home-manager.programs.waybar = { + enable = true; + systemd.enable = true; + systemd.target = "niri.target"; + settings = { + bar = { + layer = "top"; + position = "top"; + modules-left = ["clock" "niri/workspaces"]; + modules-center = ["niri/window"]; + modules-right = ["backlight" "battery" "pulseaudio" "tray"]; + + pulseaudio = { + format = "{volume}% {icon}"; + format-muted = "󰝟 "; + format-icons = { + default = ["󰕿 " "󰖀 " "󰕾 "]; + headphone = "󰋋 "; + }; + on-click = "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; + }; + }; + }; + style = '' + * { + font-family: Hack Nerd Font Mono; + font-size: 14px; + } + window#waybar, #clock, #pulseaudio, #battery, #backlight, #tray { + background: #1C1B1A; + color: #DAD8CE; + border-bottom: 2px solid #CF6A4C; + } + + #workspaces button.focused { + background: #CF6A4C; + color: #1C1B1A; + box-shadow: 0 0 0 #CF6A4C; + } + + /* Default */ + button { + /* Use box-shadow instead of border so the text isn't offset */ + box-shadow: inset 0 -3px transparent; + /* Avoid rounded borders under each button name */ + border: none; + border-radius: 0; + } + + /* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */ + button:hover { + background: inherit; + box-shadow: inset 0 -3px #ffffff; + } + + /* you can set a style on hover for any module like this */ + #pulseaudio:hover { + background-color: #a37800; + } + + #workspaces button { + padding: 0 5px; + background-color: transparent; + color: #ffffff; + } + + #workspaces button:hover { + background: rgba(0, 0, 0, 0.2); + } + + #workspaces button.urgent { + background-color: #eb4d4b; + } + + #window, + #workspaces { + margin: 0 4px; + } + + + #tray > .passive { + -gtk-icon-effect: dim; + } + + #tray > .needs-attention { + -gtk-icon-effect: highlight; + background-color: #eb4d4b; + }''; + }; + + xdg.portal = { + enable = true; + extraPortals = [pkgs.xdg-desktop-portal-gtk]; + config.common.default = "gnome"; + xdgOpenUsePortal = true; + }; + programs.niri = { + enable = true; + package = inputs.niri.packages."${pkgs.system}".niri-unstable; + }; + fireproof.home-manager.programs.niri.settings = { + prefer-no-csd = true; + clipboard.disable-primary = true; + spawn-at-startup = [ + {command = ["systemctl" "--user" "start" "hypridle"];} + {command = ["systemctl" "--user" "start" "hyprpaper"];} + {command = ["systemctl" "--user" "start" "mako"];} + {command = ["systemctl" "--user" "start" "waybar"];} + ]; + xwayland-satellite = { + enable = true; + path = lib.getExe inputs.niri.packages."${pkgs.system}".xwayland-satellite-unstable; + }; + environment = { + NIXOS_OZONE_WL = "1"; + GDK_BACKEND = "wayland"; # Attempt to fix screen recording issue + }; + layout = { + gaps = 10; + focus-ring.enable = false; + insert-hint.display.color = "#CF6A4C"; + border = { + enable = true; + width = 2; + active.color = "#CF6A4C"; + inactive.color = "#343331"; + }; + tab-indicator = { + hide-when-single-tab = true; + place-within-column = true; + gap = 2; + position = "top"; + corner-radius = 8; + }; + }; + input = { + focus-follows-mouse = { + enable = true; + max-scroll-amount = "0%"; + }; + mouse.accel-profile = "flat"; + keyboard.xkb.layout = "eu"; + }; + window-rules = [ + { + clip-to-geometry = true; + geometry-corner-radius = { + top-left = 8.0; + top-right = 8.0; + bottom-left = 8.0; + bottom-right = 8.0; + }; + } + ]; + + workspaces = lib.mkIf (primaryMonitorName != "") { + "01" = { + open-on-output = primaryMonitorName; + }; + "02" = { + open-on-output = primaryMonitorName; + }; + "03" = { + open-on-output = primaryMonitorName; + }; + "04" = { + open-on-output = primaryMonitorName; + }; + "05" = { + open-on-output = primaryMonitorName; + }; + }; + + binds = { + "XF86AudioRaiseVolume" = { + allow-when-locked = true; + action.spawn = ["dms" "ipc" "audio" "increment" "3"]; + }; + "XF86AudioLowerVolume" = { + allow-when-locked = true; + action.spawn = ["dms" "ipc" "audio" "decrement" "3"]; + }; + "XF86AudioMute" = { + allow-when-locked = true; + action.spawn = ["dms" "ipc" "audio" "mute"]; + }; + "XF86AudioMicMute" = { + allow-when-locked = true; + action.spawn = ["dms" "ipc" "audio" "micmute"]; + }; + "XF86MonBrightnessUp" = { + allow-when-locked = true; + action.spawn = ["dms" "ipc" "brightness" "increment" "5"]; + }; + "XF86MonBrightnessDown" = { + allow-when-locked = true; + action.spawn = ["dms" "ipc" "brightness" "decrement" "5"]; + }; + "Mod+N" = { + action.spawn = ["dms" "ipc" "notifications" "toggle"]; + hotkey-overlay.title = "Toggle Notification Center"; + }; + "Mod+V" = { + action.spawn = ["dms" "ipc" "clipboard" "toggle"]; + hotkey-overlay.title = "Toggle Clipboard Manager"; + }; + "Mod+Space" = { + action.spawn = ["dms" "ipc" "spotlight" "toggle"]; + hotkey-overlay.title = "Toggle Application Launcher"; + }; + "Mod+P" = { + action.spawn = ["dms" "ipc" "powermenu" "toggle"]; + hotkey-overlay.title = "Toggle Power Menu"; + }; + + "Mod+Left".action.focus-column-or-monitor-left = {}; + "Mod+Down".action.focus-window-or-monitor-down = {}; + "Mod+Up".action.focus-window-or-monitor-up = {}; + "Mod+Right".action.focus-column-or-monitor-right = {}; + "Mod+H".action.focus-column-or-monitor-left = {}; + "Mod+J".action.focus-window-or-monitor-down = {}; + "Mod+K".action.focus-window-or-monitor-up = {}; + "Mod+L".action.focus-column-or-monitor-right = {}; + + "Mod+Shift+Left".action.move-column-left-or-to-monitor-left = {}; + "Mod+Shift+Down".action.move-window-down = {}; + "Mod+Shift+Up".action.move-window-up = {}; + "Mod+Shift+Right".action.move-column-right-or-to-monitor-right = {}; + "Mod+Shift+H".action.move-column-left-or-to-monitor-left = {}; + "Mod+Shift+J".action.move-window-down = {}; + "Mod+Shift+K".action.move-window-up = {}; + "Mod+Shift+L".action.move-column-right-or-to-monitor-right = {}; + + "Mod+Home".action.focus-column-first = {}; + "Mod+End".action.focus-column-last = {}; + "Mod+Shift+Home".action.move-column-to-first = {}; + "Mod+Shift+End".action.move-column-to-last = {}; + + "Mod+Ctrl+Left".action.focus-monitor-left = {}; + "Mod+Ctrl+Down".action.focus-monitor-down = {}; + "Mod+Ctrl+Up".action.focus-monitor-up = {}; + "Mod+Ctrl+Right".action.focus-monitor-right = {}; + "Mod+Ctrl+H".action.focus-monitor-left = {}; + "Mod+Ctrl+J".action.focus-monitor-down = {}; + "Mod+Ctrl+K".action.focus-monitor-up = {}; + "Mod+Ctrl+L".action.focus-monitor-right = {}; + + "Mod+F".action.maximize-column = {}; + "Mod+Shift+F".action.fullscreen-window = {}; + "Mod+M".action.toggle-column-tabbed-display = {}; + "Mod+A".action.toggle-overview = {}; + "Mod+S".action.toggle-window-floating = {}; + "Mod+C".action.switch-preset-column-width = {}; + + "Mod+Z".action.set-column-width = "-5%"; + "Mod+X".action.set-column-width = "+5%"; + "Mod+Ctrl+X".action.expand-column-to-available-width = {}; + "Mod+Shift+Z".action.set-window-height = "-5%"; + "Mod+Shift+X".action.set-window-height = "+5%"; + + "Mod+Shift+WheelScrollDown".action.focus-workspace-down = {}; + "Mod+Shift+WheelScrollUp".action.focus-workspace-up = {}; + "Mod+WheelScrollDown".action.focus-column-right = {}; + "Mod+WheelScrollUp".action.focus-column-left = {}; + + "Mod+WheelScrollRight".action.focus-column-right = {}; + "Mod+WheelScrollLeft".action.focus-column-left = {}; + "Mod+Shift+WheelScrollRight".action.move-column-right = {}; + "Mod+Shift+WheelScrollLeft".action.move-column-left = {}; + + "Mod+q".action.focus-workspace = "01"; + "Mod+w".action.focus-workspace = "02"; + "Mod+e".action.focus-workspace = "03"; + "Mod+r".action.focus-workspace = "04"; + "Mod+t".action.focus-workspace = "05"; + "Mod+Shift+q".action.move-column-to-workspace = "01"; + "Mod+Shift+w".action.move-column-to-workspace = "02"; + "Mod+Shift+e".action.move-column-to-workspace = "03"; + "Mod+Shift+r".action.move-column-to-workspace = "04"; + "Mod+Shift+t".action.move-column-to-workspace = "05"; + + "Mod+Comma".action.consume-or-expel-window-left = {}; + "Mod+Period".action.consume-or-expel-window-right = {}; + + "Print".action.screenshot = {}; + "Ctrl+Print".action.screenshot-screen = {}; + "Alt+Print".action.screenshot-window = {}; + + "Mod+Slash".action.show-hotkey-overlay = {}; + + "Mod+Return".action.spawn = ["ghostty"]; + "Mod+Backspace".action.close-window = {}; + }; + + outputs = lib.mkIf (config.monitors != []) ( + lib.listToAttrs (map (monitor: { + inherit (monitor) name; + value = { + inherit (monitor) position; + mode = { + inherit (monitor.resolution) width height; + refresh = monitor.refreshRateNiri or null; + }; + focus-at-startup = monitor.name == primaryMonitorName; + transform.rotation = + if (monitor.transform != null) + then monitor.transform * 90 + else 0; + }; + }) + config.monitors) + ); + }; + }; +} diff --git a/modules/desktop/qt.nix b/modules/desktop/qt.nix new file mode 100644 index 0000000..0e18f59 --- /dev/null +++ b/modules/desktop/qt.nix @@ -0,0 +1,13 @@ +{ + config, + lib, + ... +}: { + config = lib.mkIf config.fireproof.desktop.enable { + qt = { + enable = true; + platformTheme = "gnome"; + style = "adwaita-dark"; + }; + }; +} diff --git a/legacy_modules/desktop/screenshot.nix b/modules/desktop/screenshot.nix similarity index 73% rename from legacy_modules/desktop/screenshot.nix rename to modules/desktop/screenshot.nix index 3871059..1b1a5b4 100644 --- a/legacy_modules/desktop/screenshot.nix +++ b/modules/desktop/screenshot.nix @@ -1,6 +1,7 @@ { - pkgs, + config, lib, + pkgs, ... }: let screenshotPkg = pkgs.writeShellScriptBin "screenshot" '' @@ -8,7 +9,9 @@ ${lib.getExe pkgs.grim} -t ppm -g "$AREA" - | ${lib.getExe pkgs.satty} -f - --initial-tool=arrow --early-exit --copy-command=${pkgs.wl-clipboard}/bin/wl-copy --action-on-enter="save-to-clipboard" --disable-notifications ''; in { - environment.systemPackages = [ - screenshotPkg - ]; + config = lib.mkIf config.fireproof.desktop.enable { + environment.systemPackages = [ + screenshotPkg + ]; + }; }