feat(nix): add graphical module, pass option to nixosSystem

This commit is contained in:
Mohammad Rafiq 2025-07-07 22:19:38 +08:00
parent c2bae8cd85
commit df06e092d6
No known key found for this signature in database
5 changed files with 73 additions and 29 deletions

View file

@ -22,7 +22,10 @@ let
name: value: name: value:
if class == "nixos" then if class == "nixos" then
nixosSystem { nixosSystem {
specialArgs.hostName = name; specialArgs = {
inherit (value) graphical;
hostName = name;
};
modules = [ modules = [
cfg.modules.nixos.default cfg.modules.nixos.default
inputs.home-manager.nixosModules.home-manager inputs.home-manager.nixosModules.home-manager

View file

@ -5,7 +5,7 @@
"stremio-server" "stremio-server"
]; ];
flake.homes.rafiq = flake.homes.rafiq =
{ osConfig, pkgs, ... }: { pkgs, config, ... }:
let let
inherit (lib.modules) mkMerge mkIf; inherit (lib.modules) mkMerge mkIf;
inherit (builtins) map listToAttrs; inherit (builtins) map listToAttrs;
@ -25,7 +25,6 @@
profileCfg = id: { profileCfg = id: {
inherit id; inherit id;
settings."extensions.autoDisableScopes" = 0; # Auto enable extensions settings."extensions.autoDisableScopes" = 0; # Auto enable extensions
#TODO: add default seach unduck and add rest of extensions
extensions = { extensions = {
force = true; force = true;
packages = with firefox-addons; [ packages = with firefox-addons; [
@ -37,7 +36,7 @@
}; };
}; };
in in
mkIf osConfig.desktop.enable { mkIf config.graphical {
persistDirs = [ persistDirs = [
"docs" "docs"
"repos" "repos"
@ -46,9 +45,15 @@
".cache/Smart Code ltd/Stremio" ".cache/Smart Code ltd/Stremio"
".local/share/Smart Code ltd/Stremio" ".local/share/Smart Code ltd/Stremio"
".mozilla/firefox" ".mozilla/firefox"
".tor project"
]; ];
home = { home = {
packages = with pkgs; [ stremio ]; packages = with pkgs; [
stremio
tor-browser
vlc
wl-clipboard-rs
];
sessionVariables = { sessionVariables = {
BROWSER = "firefox"; BROWSER = "firefox";
LAUNCHER = "fuzzel"; LAUNCHER = "fuzzel";
@ -58,8 +63,8 @@
STATUS_BAR = "waybar"; STATUS_BAR = "waybar";
}; };
}; };
# TODO: add gamescope here or in nixos desktop module
programs = { programs = {
fuzzel.enable = true;
obs-studio.enable = true; obs-studio.enable = true;
vesktop.enable = true; vesktop.enable = true;
thunderbird.enable = true; thunderbird.enable = true;
@ -105,7 +110,6 @@
enable = true; enable = true;
settings = [ settings = [
{ {
#TODO: review the rest of the modules to see what else can be added
layer = "top"; layer = "top";
modules-left = [ modules-left = [
"pulseaudio" "pulseaudio"
@ -149,24 +153,48 @@
} }
''; '';
}; };
}; };
services = { services = {
mako.enable = true; mako.enable = true;
mako.settings.default-timeout = 10000; mako.settings.default-timeout = 10000;
}; };
wayland.windowManager.hyprland.settings = mkMerge [ wayland.windowManager.hyprland = {
(import ./_hyprland/decoration.nix) enable = true;
(import ./_hyprland/keybinds.nix { inherit pkgs; }) # This is needed for UWSM
{ systemd.enable = false;
ecosystem.no_update_news = true; # Null the packages since we use them system wide
xwayland.force_zero_scaling = true; package = null;
monitor = [ ", preferred, auto, 1" ]; portalPackage = null;
exec-once = [ # settings.monitor = [
"uwsm app -- $LOCKSCREEN" # "${mainMonitor.id}, ${mainMonitor.resolution}@${mainMonitor.refresh-rate}, auto, ${mainMonitor.scale}"
"uwsm app -- $NOTIFICATION_DAEMON" # ];
"uwsm app -- $STATUS_BAR"
]; 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}
# '';
}; };
} }

View file

@ -9,6 +9,7 @@
}; };
hosts.nixos = { hosts.nixos = {
nemesis = { nemesis = {
graphical = true;
machine = { machine = {
platform = "amd"; platform = "amd";
gpu = "nvidia"; gpu = "nvidia";
@ -22,9 +23,9 @@
} }
]; ];
}; };
extraCfg.desktop.enable = true;
}; };
apollo = { apollo = {
graphical = false;
machine = { machine = {
platform = "intel"; platform = "intel";
root.drive = "/dev/disk/by-id/nvme-eui.002538d221b47b01"; root.drive = "/dev/disk/by-id/nvme-eui.002538d221b47b01";

View file

@ -1,7 +0,0 @@
{ lib, ... }:
let
inherit (lib.options) mkEnableOption;
in
{
flake.modules.nixos.default.options.desktop.enable = mkEnableOption "";
}

View file

@ -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 "";
}