From df06e092d6359839c7098942af3ce71e74e649b5 Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Mon, 7 Jul 2025 22:19:38 +0800 Subject: [PATCH] feat(nix): add graphical module, pass option to nixosSystem --- nix/configurations.nix | 5 ++- nix/homes/rafiq/desktop/default.nix | 68 ++++++++++++++++++++--------- nix/manifest.nix | 3 +- nix/modules/desktop/default.nix | 7 --- nix/modules/graphical/default.nix | 19 ++++++++ 5 files changed, 73 insertions(+), 29 deletions(-) delete mode 100644 nix/modules/desktop/default.nix create mode 100644 nix/modules/graphical/default.nix diff --git a/nix/configurations.nix b/nix/configurations.nix index 9375b15..aeb2592 100644 --- a/nix/configurations.nix +++ b/nix/configurations.nix @@ -22,7 +22,10 @@ let name: value: if class == "nixos" then nixosSystem { - specialArgs.hostName = name; + specialArgs = { + inherit (value) graphical; + hostName = name; + }; modules = [ cfg.modules.nixos.default inputs.home-manager.nixosModules.home-manager diff --git a/nix/homes/rafiq/desktop/default.nix b/nix/homes/rafiq/desktop/default.nix index f28357e..0e4bf07 100644 --- a/nix/homes/rafiq/desktop/default.nix +++ b/nix/homes/rafiq/desktop/default.nix @@ -5,7 +5,7 @@ "stremio-server" ]; flake.homes.rafiq = - { osConfig, pkgs, ... }: + { pkgs, config, ... }: let inherit (lib.modules) mkMerge mkIf; inherit (builtins) map listToAttrs; @@ -25,7 +25,6 @@ profileCfg = id: { inherit id; settings."extensions.autoDisableScopes" = 0; # Auto enable extensions - #TODO: add default seach unduck and add rest of extensions extensions = { force = true; packages = with firefox-addons; [ @@ -37,7 +36,7 @@ }; }; in - mkIf osConfig.desktop.enable { + mkIf config.graphical { persistDirs = [ "docs" "repos" @@ -46,9 +45,15 @@ ".cache/Smart Code ltd/Stremio" ".local/share/Smart Code ltd/Stremio" ".mozilla/firefox" + ".tor project" ]; home = { - packages = with pkgs; [ stremio ]; + packages = with pkgs; [ + stremio + tor-browser + vlc + wl-clipboard-rs + ]; sessionVariables = { BROWSER = "firefox"; LAUNCHER = "fuzzel"; @@ -58,8 +63,8 @@ STATUS_BAR = "waybar"; }; }; - # TODO: add gamescope here or in nixos desktop module programs = { + fuzzel.enable = true; obs-studio.enable = true; vesktop.enable = true; thunderbird.enable = true; @@ -105,7 +110,6 @@ enable = true; settings = [ { - #TODO: review the rest of the modules to see what else can be added layer = "top"; modules-left = [ "pulseaudio" @@ -149,24 +153,48 @@ } ''; }; + }; services = { mako.enable = true; mako.settings.default-timeout = 10000; }; - wayland.windowManager.hyprland.settings = mkMerge [ - (import ./_hyprland/decoration.nix) - (import ./_hyprland/keybinds.nix { inherit pkgs; }) - { - ecosystem.no_update_news = true; - xwayland.force_zero_scaling = true; - monitor = [ ", preferred, auto, 1" ]; - exec-once = [ - "uwsm app -- $LOCKSCREEN" - "uwsm app -- $NOTIFICATION_DAEMON" - "uwsm app -- $STATUS_BAR" - ]; - } - ]; + wayland.windowManager.hyprland = { + enable = true; + # This is needed for UWSM + systemd.enable = false; + # Null the packages since we use them system wide + package = null; + portalPackage = null; + # settings.monitor = [ + # "${mainMonitor.id}, ${mainMonitor.resolution}@${mainMonitor.refresh-rate}, auto, ${mainMonitor.scale}" + # ]; + + settings = mkMerge [ + (import ./_hyprland/decoration.nix) + (import ./_hyprland/keybinds.nix { inherit pkgs; }) + { + ecosystem.no_update_news = true; + xwayland.force_zero_scaling = true; + monitor = [ ", preferred, auto, 1" ]; + exec-once = [ + "uwsm app -- $LOCKSCREEN" + "uwsm app -- $NOTIFICATION_DAEMON" + "uwsm app -- $STATUS_BAR" + ]; + } + ]; + }; + # xdg.configFile."uwsm/env".text = # sh + # '' + # # Force apps to scale right with Wayland + # export GDK_SCALE=${mainMonitor.scale} + # export STEAM_FORCE_DESKTOPUI_SCALING=${mainMonitor.scale} + # ''; + # xdg.configFile."uwsm/env-hyprland".text = # sh + # '' + # export GDK_SCALE=${mainMonitor.scale} + # export STEAM_FORCE_DESKTOPUI_SCALING=${mainMonitor.scale} + # ''; }; } diff --git a/nix/manifest.nix b/nix/manifest.nix index cf8f48e..3f4af3e 100644 --- a/nix/manifest.nix +++ b/nix/manifest.nix @@ -9,6 +9,7 @@ }; hosts.nixos = { nemesis = { + graphical = true; machine = { platform = "amd"; gpu = "nvidia"; @@ -22,9 +23,9 @@ } ]; }; - extraCfg.desktop.enable = true; }; apollo = { + graphical = false; machine = { platform = "intel"; root.drive = "/dev/disk/by-id/nvme-eui.002538d221b47b01"; diff --git a/nix/modules/desktop/default.nix b/nix/modules/desktop/default.nix deleted file mode 100644 index 3e2c64b..0000000 --- a/nix/modules/desktop/default.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ lib, ... }: -let - inherit (lib.options) mkEnableOption; -in -{ - flake.modules.nixos.default.options.desktop.enable = mkEnableOption ""; -} diff --git a/nix/modules/graphical/default.nix b/nix/modules/graphical/default.nix new file mode 100644 index 0000000..78874bf --- /dev/null +++ b/nix/modules/graphical/default.nix @@ -0,0 +1,19 @@ +{ lib, ... }: +let + inherit (lib.modules) mkIf; + inherit (lib.options) mkEnableOption; +in +{ + flake.modules.nixos.default = + { graphical, ... }: + { + config = mkIf graphical { + home-manager.sharedModules = [ { graphical = true; } ]; + services.pipewire = { + enable = true; + pulse.enable = true; + }; + }; + }; + flake.modules.homeManager.default.options.graphical = mkEnableOption ""; +}