feat(desktop): move window-manager config to homes and use home-manager modules

This commit is contained in:
Mohammad Rafiq 2025-06-14 16:02:58 +08:00
parent a04688d17b
commit 9167a54ace
No known key found for this signature in database
12 changed files with 99 additions and 86 deletions

View file

@ -11,15 +11,7 @@ let
inherit (lib) mkMerge mkIf mkEnableOption;
in
{
options.desktop = {
wayland.enableUtils = mkEnableOption "common Wayland utilities";
};
config = mkIf upstreamCfg.enable (mkMerge [
(mkIf cfg.wayland.enableUtils {
home.packages = with pkgs; [
wl-clipboard-rs
];
})
(lib.mkIf (osConfig.hardware.gpu == "nvidia") {
home.packages = [ pkgs.stable-diffusion-webui.forge.cuda ];
home.persistence."/persist/home/${config.snowfallorg.user.name}".directories = [

View file

@ -1,14 +0,0 @@
{
animation = [ "workspaces, 1, 1, default" ];
general = {
border_size = 2;
gaps_in = 0;
gaps_out = 0;
resize_on_border = true;
};
decoration = {
rounding = 10;
rounding_power = 2;
inactive_opacity = 0.9;
};
}

View file

@ -1,48 +0,0 @@
{
pkgs,
lib,
osConfig,
...
}:
let
inherit (osConfig.desktop) mainMonitor;
in
{
config = lib.mkIf (osConfig.desktop.windowManager == "hyprland") {
desktop.wayland.enableUtils = true;
wayland.windowManager.hyprland = {
enable = true;
systemd.enable = false;
settings = lib.mkMerge [
{
ecosystem.no_update_news = true;
monitor = [
"${mainMonitor.id}, ${mainMonitor.resolution}@${mainMonitor.refresh-rate}, auto, ${mainMonitor.scale}"
", preferred, auto, 1"
];
exec-once = [
"uwsm app -- $LOCKSCREEN"
"uwsm app -- $NOTIFICATION_DAEMON"
"uwsm app -- $STATUS_BAR"
];
xwayland.force_zero_scaling = true;
}
(import ./decoration.nix)
(import ./keybinds.nix { inherit pkgs; })
];
};
xdg.configFile."uwsm/env".text = # sh
''
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

@ -1,47 +0,0 @@
{ pkgs, ... }:
{
"$hypr" = "CTRL_SUPER_ALT_SHIFT";
"$meh" = "CONTROL_SHIFT_ALT";
bind = [
"$hypr, Q, exec, uwsm stop"
"SUPER, W, killactive"
"SUPER, return, exec, uwsm app -- $TERMINAL $MULTIPLEXER"
"SUPER, O, exec, uwsm app -- $BROWSER"
"SUPER, Escape, exec, uwsm app -- $LOCKSCREEN"
"SUPER, space, exec, uwsm app -- $($LAUNCHER --launch-prefix=\"uwsm app -- \")"
"SUPER, H, cyclenext, visible"
"SUPER, L, cyclenext, visible prev"
"SUPER_ALT, H, movewindow, l"
"SUPER_ALT, J, movewindow, d"
"SUPER_ALT, K, movewindow, u"
"SUPER_ALT, L, movewindow, r"
"ALT_SHIFT, H, resizeactive, -10% 0"
"ALT_SHIFT, J, resizeactive, 0 -10%"
"ALT_SHIFT, K, resizeactive, 0 10%"
"ALT_SHIFT, L, resizeactive, 10% 0"
"SUPER_CTRL, H, workspace, r-1"
"SUPER_CTRL, L, workspace, r+1"
"$hypr, H, movetoworkspace, r-1"
"$hypr, L, movetoworkspace, r+1"
];
bindle = [
"SUPER, 6, exec, wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%-"
"SUPER, 7, exec, ${pkgs.playerctl}/bin/playerctl previous"
"SUPER, 8, exec, ${pkgs.playerctl}/bin/playerctl play-pause"
"SUPER, 9, exec, ${pkgs.playerctl}/bin/playerctl next"
"SUPER, 0, exec, wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+"
"$meh, mouse_up, resizeactive, 10% 10%"
"$meh, mouse_down, resizeactive, -10% -10%"
];
bindm = [
"ALT, mouse:272, movewindow"
"ALT, mouse:273, resizeactive"
];
bindc = [
"ALT, mouse:272, togglefloating"
];
}

View file

@ -5,23 +5,21 @@
...
}:
let
inherit (lib) mkEnableOption;
inherit (lib) mkEnableOption mkIf singleton;
inherit (lib.pantheon) mkStrOption;
inherit (pkgs) wl-clipboard-rs;
cfg = config.desktop;
in
{
imports = [
./windowManager.nix
];
options.desktop = {
enable = mkEnableOption "";
enableWaylandUtilities = mkEnableOption "";
mainMonitor = {
id = mkStrOption;
scale = lib.pantheon.mkStrOption;
resolution = lib.pantheon.mkStrOption;
refresh-rate = lib.pantheon.mkStrOption;
};
windowManager = lib.pantheon.mkStrOption;
enableSpotifyd = lib.mkEnableOption "";
enableSteam = lib.mkEnableOption "";
enableVR = lib.mkEnableOption "";
@ -34,6 +32,9 @@ in
font-awesome
];
}
(mkIf cfg.enableWaylandUtilities {
home-manager.sharedModules = singleton { home.packages = [ wl-clipboard-rs ]; };
})
(lib.mkIf config.desktop.enableSteam {
programs.steam = {
enable = true;

View file

@ -0,0 +1,47 @@
{ config, lib, ... }:
let
inherit (lib) mkEnableOption mkIf singleton;
inherit (config.desktop) mainMonitor;
cfg = config.desktop.window-manager.hyprland;
in
{
options.desktop.window-manager.hyprland = {
enable = mkEnableOption "";
};
config = mkIf cfg.enable {
desktop.enableWaylandUtilities = true;
environment.loginShellInit = # sh
''
if [[ -z "$SSH_CLIENT" && -z "$SSH_CONNECTION" ]]; then
if uwsm check may-start; then
exec uwsm start hyprland-uwsm.desktop
fi
fi
'';
environment.variables = {
ELECTRON_OZONE_PLATFORM_HINT = "auto";
NIXOS_OZONE_WL = "1";
};
programs.hyprland = {
enable = true;
withUWSM = true;
};
home-manager.sharedModules = singleton {
wayland.windowManager.hyprland = {
enable = true;
systemd.enable = false;
};
xdg.configFile."uwsm/env".text = # sh
''
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

@ -1,23 +0,0 @@
{ config, lib, ... }:
{
config = lib.mkMerge [
(lib.mkIf (config.desktop.windowManager == "hyprland") {
environment.loginShellInit = # sh
''
if [[ -z "$SSH_CLIENT" && -z "$SSH_CONNECTION" ]]; then
if uwsm check may-start; then
exec uwsm start hyprland-uwsm.desktop
fi
fi
'';
environment.variables = {
ELECTRON_OZONE_PLATFORM_HINT = "auto";
NIXOS_OZONE_WL = "1";
};
programs.hyprland = {
enable = true;
withUWSM = true;
};
})
];
}