chore: refactor user modules

This commit is contained in:
2025-07-27 22:50:25 +02:00
parent 15a39660eb
commit f396b3a8fb
94 changed files with 832 additions and 665 deletions

View File

@@ -0,0 +1,32 @@
{
lib,
config,
...
}:
with lib; let
cfg = config.home.desktop;
in {
imports = [
./emoji.nix
./eww.nix
./hyprland.nix
./kdeconnect.nix
./kitty.nix
./obs.nix
./qt.nix
./swaync.nix
./waybar.nix
./wlsunset.nix
./wofi.nix
];
options.home.desktop.fullDesktop = mkEnableOption "Enable options for graphical environments";
config.home.desktop = {
eww.enable = mkDefault cfg.fullDesktop;
hyprland.enable = mkDefault cfg.fullDesktop;
kdeconnect.enable = mkDefault cfg.fullDesktop;
kitty.enable = mkDefault cfg.fullDesktop;
obs.enable = mkDefault cfg.fullDesktop;
qt.enable = mkDefault cfg.fullDesktop;
};
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,12 @@
(defwindow example
:monitor 0
:geometry (geometry :x "0%"
:y "20%"
:width "90%"
:height "30px"
:anchor "top center")
:stacking "fg"
:reserve (struts :distance "40px" :side "top")
:windowtype "dock"
:wm-ignore false
"example content")

View File

View File

@@ -0,0 +1,14 @@
{
lib,
config,
...
}:
with lib; let
cfg = config.home.desktop.eww;
in {
options.home.desktop.eww.enable = mkEnableOption "Enable eww support";
config.programs.eww = mkIf cfg.enable {
inherit (cfg) enable;
configDir = ./eww-config;
};
}

View File

@@ -0,0 +1,292 @@
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.home.desktop.hyprland;
rofi-emoji = import ../cli/scripts/rofi-emoji.nix {inherit pkgs;};
laptops = ["gampo"];
in {
imports = [
./swaync.nix
./waybar.nix
./wlsunset.nix
];
options.home.desktop.hyprland = {
enable = mkEnableOption "Enables Hyprland";
emacsPkg = mkOption {
type = types.package;
default = config.home.dev.editors.emacs.package or pkgs.emacs;
# default = pkgs.emacs;
example = pkgs.emacs;
};
host = mkOption {
type = types.enum ["gampo" "marpa"];
description = ''
Which host is Hyprland running on.
This helps determine the monitors layout and enable battery support in waybar.
'';
};
};
config = mkIf cfg.enable {
home.desktop = {
swaync.enable = mkDefault true;
waybar = {
enable = mkDefault true;
battery = mkDefault (builtins.elem cfg.host laptops);
};
wlsunset.enable = mkDefault true;
wofi.enable = mkDefault true;
};
wayland.windowManager.hyprland = {
enable = true;
xwayland.enable = true;
systemd.enable = false;
importantPrefixes = ["$left" "$right" "$up" "$down" "$menu"];
settings = {
input = {
kb_layout = "fr";
kb_variant = "bepo_afnor";
# kb_options = "caps:ctrl_modifier";
numlock_by_default = true;
follow_mouse = 1;
touchpad.natural_scroll = false;
sensitivity = "0";
};
monitor =
{
"marpa" = [
"DP-1, 3440x1440@144, 1080x550, 1"
"DP-2, 2560x1080@60, 0x0, 1, transform, 1"
];
"gampo" = [];
}."${cfg.host}";
general = {
gaps_in = 5;
gaps_out = 20;
border_size = 2;
"col.active_border" = "rgb(81a1c1) rgb(a3be8c) 45deg";
"col.inactive_border" = "rgb(4c566a)";
layout = "master";
};
master = {
orientation = "center";
new_status = "inherit";
};
workspace = [
"4, layoutopt:orientation:bottom"
"1, layoutopt:orientation:bottom"
];
decoration = {
rounding = 5;
};
animations = {
enabled = true;
animation = [
# "windows, 1, 7, myBezier"
"windowsOut, 1, 7, default, popin 80%"
"border, 1, 10, default"
"borderangle, 1, 8, default"
"fade, 1, 7, default"
"workspaces, 1, 6, default"
];
};
dwindle = {
pseudotile = true;
preserve_split = true;
};
exec-once = [
"pactl load-module module-switch-on-connect"
"${pkgs.mpc}/bin/mpc stop"
"${pkgs.networkmanagerapplet}/bin/nm-applet"
];
};
extraConfig = ''
$left = c
$right = r
$up = s
$down = t
$menu = ${pkgs.wofi}/bin/wofi --show drun
bind = SUPER, Return, exec, ${pkgs.kitty}/bin/kitty ${pkgs.tmux}/bin/tmux
bind = SUPER, Space, submap, leader
bind = , Print, submap, screenshot
submap = leader
bind = , l, exec, plock
bind = , l, submap, reset
bind = , a, submap, apps
bind = , b, submap, buffers
bind = , w, submap, windows
bind = , escape, submap, reset
bind = CTRL, g, submap, reset
submap = apps
bind = , b, exec, zen
bind = , b, submap, reset
bind = SHIFT, b, exec, qutebrowser
bind = SHIFT, b, submap, reset
bind = , d, exec, vesktop
bind = , d, submap, reset
bind = , e, exec, ${cfg.emacsPkg}/bin/emacsclient -c -n
bind = , e, submap, reset
bind = , g, exec, ${pkgs.gimp}/bin/gimp
bind = , g, submap, reset
bind = , n, exec, ${pkgs.nemo}/bin/nemo
bind = , n, submap, reset
bind = , r, submap, rofi
bind = , u, exec, $menu
bind = , u, submap, reset
bind = , escape, submap, reset
bind = CTRL, g, submap, reset
submap = buffers
bind = , d, killactive,
bind = , d, submap, reset
bind = , escape, submap, reset
bind = CTRL, g, submap, reset
submap = resize
binde = , $left, resizeactive, -10 0
binde = , $right, resizeactive, 10 0
binde = , $up, resizeactive, 0 -10
binde = , $down, resizeactive, 0 10
bind = , q, submap, reset
bind = , escape, submap, reset
bind = CTRL, g, submap, reset
submap = rofi
bind = , e, exec, ${rofi-emoji}/bin/rofi-emoji
bind = , e, submap, reset
bind = , r, exec, $menu
bind = , r, submap, reset
bind = , y, exec, ytplay
bind = , y, submap, reset
bind = , escape, submap, reset
bind = CTRL, g, submap, reset
submap = screenshot
bind = , Print, exec, screenshot
bind = , Print, submap, reset
bind = , d, exec, screenshot -d 3
bind = , d, submap, reset
bind = Shift, d, exec, screenshot -sced 3
bind = Shift, d, submap, reset
bind = , e, exec, screenshot -sec
bind = , e, submap, reset
bind = , s, exec, screenshot -s
bind = , s, submap, reset
bind = Shift, s, exec, screenshot -sc
bind = Shift, s, submap, reset
bind = , escape, submap, reset
bind = CTRL, g, submap, reset
submap = windows
bind = , period, submap, resize
bind = , $left, movefocus, l
bind = , $left, submap, reset
bind = , $right, movefocus, r
bind = , $right, submap, reset
bind = , $up, movefocus, u
bind = , $up, submap, reset
bind = , $down, movefocus, d
bind = , $down, submap, reset
bind = SHIFT, $left, movewindow, l
bind = SHIFT, $left, submap, reset
bind = SHIFT, $right, movewindow, r
bind = SHIFT, $right, submap, reset
bind = SHIFT, $up, movewindow, u
bind = SHIFT, $up, submap, reset
bind = SHIFT, $down, movewindow, d
bind = SHIFT, $down, submap, reset
bind = CTRL_SHIFT, $left, moveworkspacetomonitor, e+0 +1
bind = CTRL_SHIFT, $left, submap, reset
bind = CTRL_SHIFT, $right, moveworkspacetomonitor, e+0 -1
bind = CTRL_SHIFT, $right, submap, reset
bind = , d, killactive,
bind = , d, submap, reset
bind = , f, fullscreen,
bind = , f, submap, reset
bind = SHIFT, f, togglefloating,
bind = SHIFT, f, submap, reset
bind = , escape, submap, reset
bind = CTRL, g, submap, reset
submap = reset
bindl = , XF86AudioPlay, exec, playerctl play-pause
bindl = , XF86AudioPause, exec, playerctl pause
bindl = , XF86AudioStop, exec, playerctl stop
bindl = , XF86AudioPrev, exec, playerctl previous
bindl = , XF86AudioNext, exec, playerctl next
bindl = , XF86AudioForward, exec, playerctl position +1
bindl = , XF86AudioRewind, exec, playerctl position -1
bindl = , XF86AudioRaiseVolume, exec, pamixer -i 2
bindl = , XF86AudioLowerVolume, exec, pamixer -d 2
bindl = , XF86MonBrightnessUp, exec, xbacklight -perceived -inc 2
bindl = , XF86MonBrightnessDown, exec, xbacklight -perceived -dec 2
bindl = , XF86KbdBrightnessUp, exec, xbacklight -perceived -inc 2
bindl = , XF86KbdBrightnessDown, exec, xbacklight -perceived -dec 2
bind = SUPER, $left, movefocus, l
bind = SUPER, $right, movefocus, r
bind = SUPER, $up, movefocus, u
bind = SUPER, $down, movefocus, d
bind = SUPER_SHIFT, $left, movewindow, l
bind = SUPER_SHIFT, $left, submap, reset
bind = SUPER_SHIFT, $right, movewindow, r
bind = SUPER_SHIFT, $right, submap, reset
bind = SUPER_SHIFT, $up, movewindow, u
bind = SUPER_SHIFT, $up, submap, reset
bind = SUPER_SHIFT, $down, movewindow, d
bind = SUPER_SHIFT, $down, submap, reset
bind = SUPER_CTRL_SHIFT, $left, moveworkspacetomonitor, e+0 +1
bind = SUPER_CTRL_SHIFT, $left, submap, reset
bind = SUPER_CTRL_SHIFT, $right, moveworkspacetomonitor, e+0 -1
bind = SUPER_CTRL_SHIFT, $right, submap, reset
bind = SUPER, Tab, cyclenext,
bind = SUPER_SHIFT, Tab, cyclenext, prev
bindm = SUPER, mouse:272, movewindow
bindm = SUPER, mouse:273, resizewindow
bind = SUPER, quotedbl, workspace, 1
bind = SUPER, guillemotleft, workspace, 2
bind = SUPER, guillemotright, workspace, 3
bind = SUPER, parenleft, workspace, 4
bind = SUPER, parenright, workspace, 5
bind = SUPER, at, workspace, 6
bind = SUPER, plus, workspace, 7
bind = SUPER, minus, workspace, 8
bind = SUPER, slash, workspace, 9
bind = SUPER, asterisk, workspace, 10
bind = SUPER, mouse_down, workspace, e+1
bind = SUPER, mouse_up, workspace, e-1
bind = SUPER_SHIFT, quotedbl, movetoworkspace, 1
bind = SUPER_SHIFT, guillemotleft, movetoworkspace, 2
bind = SUPER_SHIFT, guillemotright, movetoworkspace, 3
bind = SUPER_SHIFT, parenleft, movetoworkspace, 4
bind = SUPER_SHIFT, parenright, movetoworkspace, 5
bind = SUPER_SHIFT, at, movetoworkspace, 6
bind = SUPER_SHIFT, plus, movetoworkspace, 7
bind = SUPER_SHIFT, minus, movetoworkspace, 8
bind = SUPER_SHIFT, slash, movetoworkspace, 9
bind = SUPER_SHIFT, asterisk, movetoworkspace, 10
'';
};
services = {
blueman-applet.enable = true;
wpaperd = {
enable = true;
settings = {
default = {
path = "/home/phundrak/Pictures/Wallpapers/nord";
duration = "5m";
sorting = "random";
mode = "center";
recursive = true;
};
DP-3 = {
mode = "fit-border-color";
};
};
};
};
};
}

View File

@@ -0,0 +1,14 @@
{
lib,
config,
...
}:
with lib; let
cfg = config.home.desktop.kdeconnect;
in {
options.home.desktop.kdeconnect.enable = mkEnableOption "Enable KDE Connect";
config.services.kdeconnect = mkIf cfg.enable {
enable = true;
indicator = true;
};
}

View File

@@ -0,0 +1,112 @@
{
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.home.desktop.kitty;
in {
options.home.desktop.kitty.enable = mkEnableOption "Enable kitty terminal";
config.programs.kitty = mkIf cfg.enable {
inherit (cfg) enable;
themeFile = "Nord";
font = {
package = pkgs.cascadia-code;
name = "Cascadia Code";
size = 10;
};
settings = {
enable_audio_bell = true;
visual_bell_duration = 0.1;
enabled_layouts = "fat,fat:mirrored=true,tall,tall:mirrored=true";
kitty_mod = "ctrl+shift";
disable_ligatures = "never";
font_features = "Cascadia-Mono +onum +zero";
cursor_shape = "block";
scrollback_lines = "10000";
mouse_hide_wait = 3.0;
detect_urls = true;
background_opacity = 0.7;
};
keybindings = {
"alt+c" = "copy_to_clipboard";
"kitty_mod+c" = "copy_to_clipboard";
"alt+v" = "paste_from_clipboard";
"kitty_mod+v" = "paste_from_clipboard";
"kitty_mod+s>c" = "show_scrollback";
"kitty_mod+s>down" = "scroll_line_down";
"kitty_mod+s>t" = "scroll_line_down";
"kitty_mod+s>up" = "scroll_line_up";
"kitty_mod+s>s" = "scroll_line_up";
"kitty_mod+s>end" = "scroll_end";
"kitty_mod+s>home" = "scroll_home";
"kitty_mod+s>page_down" = "scroll_page_down";
"kitty_mod+s>page_up" = "scroll_page_up";
"kitty_mod+enter" = "new_window";
"kitty_mod+w>q" = "close_window";
"kitty_mod+w>p" = "next_window";
"kitty_mod+w>n" = "previous_window";
"kitty_mod+w>f" = "move_window_forward";
"kitty_mod+w>b" = "move_window_backward";
"kitty_mod+w>t" = "move_window_to_top";
"kitty_mod+w>r" = "start_resizing_window";
"kitty_mod+w>1" = "first_window";
"kitty_mod+w>2" = "second_window";
"kitty_mod+w>3" = "third_window";
"kitty_mod+w>4" = "fourth_window";
"kitty_mod+w>5" = "fifth_window";
"kitty_mod+w>6" = "sixth_window";
"kitty_mod+w>7" = "seventh_window";
"kitty_mod+w>8" = "eighth_window";
"kitty_mod+w>9" = "ninth_window";
"kitty_mod+w>0" = "tenth_window";
"kitty_mod+tab>n" = "next_tab";
"kitty_mod+tab>p" = "previous_tab";
"kitty_mod+tab>c" = "new_tab";
"kitty_mod+tab>q" = "close_tab";
"kitty_mod+tab>shift+n" = "move_tab_backward";
"kitty_mod+tab>shift+p" = "move_tab_forward";
"kitty_mod+tab>t" = "set_tab_title";
"kitty_mod+l" = "next_layout";
"kitty_mod+f>equal" = "change_font_size all 0";
"kitty_mod+f>kp_add" = "change_font_size all +2.0";
"kitty_mod+f>plus" = "change_font_size all +2.0";
"kitty_mod+f>kp_subtract" = "change_font_size all -2.0";
"kitty_mod+f>minus" = "change_font_size all -2.0";
"kitty_mod+shift+h" = "kitten hints";
"kitty_mod+h>p" = "kitten hints --type path --program -";
"kitty_mod+h>shift+p" = "kitten hints --type path";
"kitty_mod+h>l" = "kitten hints --type line --program -";
"kitty_mod+h>w" = "kitten hints --type word --program -";
"kitty_mod+h>h" = "kitten hints --type hash --program -";
"kitty_mod+h>n" = "kitten hints --type linenum";
"kitty_mod+h>y" = "kitten hints --type hyperlink";
"kitty_mod+f10" = "toggle_maximized";
"kitty_mod+f11" = "toggle_fullscreen";
"kitty_mod+a>equal" = "set_background_opacity 1";
"kitty_mod+a>d" = "set_background_opacity default";
"kitty_mod+a>plus" = "set_background_opacity +0.1";
"kitty_mod+a>up" = "set_background_opacity +0.1";
"kitty_mod+a>kp_add" = "set_background_opacity +0.1";
"kitty_mod+a>minus" = "set_background_opacity -0.1";
"kitty_mod+a>down" = "set_background_opacity -0.1";
"kitty_mod+a>kp_substract" = "set_background_opacity -0.1";
"kitty_mod+delete" = "clear_terminal reset active";
"kitty_mod+escape" = "kitty_shell window";
"kitty_mod+f2" = "edit_config_file";
"kitty_mod+n" = "new_os_window";
"kitty_mod+o" = "pass_selection_to_program";
"kitty_mod+u" = "kitten unicode_input";
};
};
}

View File

@@ -0,0 +1,23 @@
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.home.desktop.obs;
in {
options.home.desktop.obs.enable = mkEnableOption "Enables OBS Studio";
config.programs.obs-studio = mkIf cfg.enable {
inherit (cfg) enable;
plugins = with pkgs.obs-studio-plugins; [
input-overlay
obs-backgroundremoval
obs-mute-filter
obs-pipewire-audio-capture
obs-source-clone
obs-source-record
obs-tuna
];
};
}

View File

@@ -0,0 +1,11 @@
{
lib,
config,
...
}:
with lib; let
cfg = config.home.desktop.qt;
in {
options.home.desktop.qt.enable = mkEnableOption "Enable Qt support";
config.qt.enable = cfg.enable;
}

View File

@@ -0,0 +1,15 @@
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.home.desktop.swaync;
in {
options.home.desktop.swaync.enable = mkEnableOption "Enables swaync";
config = mkIf cfg.enable {
services.swaync.enable = true;
home.packages = [pkgs.swaynotificationcenter];
};
}

View File

@@ -0,0 +1,154 @@
{
config,
lib,
...
}:
with lib; let
cfg = config.home.desktop.waybar;
in {
options.home.desktop.waybar = {
enable = mkEnableOption "Enables waybar.";
battery = mkEnableOption "Enables battery support.";
style = mkOption {
type = types.path;
example = ./style.css;
};
};
config.programs.waybar = mkIf cfg.enable {
inherit (cfg) enable;
systemd.enable = true;
settings = {
topBar = {
height = 24;
spacing = 2;
modules-left = ["hyprland/workspaces" "hyprland/submap" "hyprland/window"];
modules-center = [];
modules-right = [
"idle_inhibitor"
"group/audio"
"group/hardware"
"network"
"privacy"
"clock"
"tray"
];
idle_inhibitor = {
format = "{icon}";
format-icons = {
activated = "";
deactivated = "";
};
};
mpris = {
dynamic-order = ["title" "artist" "album"];
dynamic-importance-order = ["title" "artist" "album"];
format = "DEFAULT: {player_icon} {dynamic}";
format-paused = "DEFAULT: {status_icon} <i>{dynamic}</i>";
player-icons = {
default = "";
mpv = "🎵";
};
status-icons.paused = "";
ignored-players = [];
};
pulseaudio = {
format = "{volume}% {icon} {format_source}";
format-bluetooth = "{volume}% {icon} {format_source}";
format-bluetooth-muted = " {icon} {format_source}";
format-muted = " {format_source}";
format-source = "{volume}% ";
format-source-muted = "";
format-icons = {
headphone = "";
hands-free = "";
headset = "";
phone = "";
portable = "";
car = "";
default = ["" "" ""];
};
on-click = "pavucontrol";
};
network = {
format-wifi = "{essid} ({signalStrength}%) ";
format-ethernet = "{ipaddr}/{cidr} ";
tooltip-format = "{ifname} via {gwaddr} ";
format-linked = "{ifname} (No IP) ";
format-disconnected = "Disconnected ";
format-alt = "{ifname}: {ipaddr}/{cidr}";
};
"group/audio" = {
modules = ["pulseaudio" "pulseaudio/slider" "mpris"];
orientation = "inherit";
drawer.transition-duration = 300;
};
"group/hardware" = {
modules = lists.optional cfg.battery "battery" ++ ["cpu" "memory" "disk"];
orientation = "inherit";
drawer.transition-duration = 300;
};
cpu = {
format = "{usage}% ";
tooltip = false;
};
memory.format = "{}% ";
disk = {
format = "{path}: {used}/{total} ({percentage_used}%)";
unit = "GB";
};
battery = {
states = {
good = 90;
warning = 30;
critical = 15;
};
format = "{capacity}% {icon}";
format-charging = "{capacity}% ";
format-plugged = "{capacity}% ";
format-alt = "{time} {icon}";
# An empty format will hide the module
format-good = "";
format-full = "";
format-icons = ["" "" "" "" ""];
};
clock = {
timezones = ["Europe/Paris" "Asia/Tokyo" "America/New_York" "America/Los_Angeles" "Asia/Kathmandu"];
tooltip-format = "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>";
format-alt = "{:%Y-%m-%d}";
actions = {
on-click-right = "mode";
on-scroll-up = "tz_up";
on-scroll-down = "tz_down";
};
calendar = {
mode = "year";
mode-mon-col = 3;
weeks-pos = "right";
on-scroll = 1;
format = {
months = "<span color='#eceff4'><b>{}</b></span>";
days = "<span color='#5e81ac'><b>{}</b></span>";
weeks = "<span color='#8fbcbb'><b>W{:%W}</b></span>";
weekdays = "<span color='#d8dee9'><b>{}</b></span>";
today = "<span color='#a3be8c'><b><u>{}</u></b></span>";
};
};
};
tray.spacing = 10;
};
};
style = builtins.readFile cfg.style;
};
}

View File

@@ -0,0 +1,24 @@
{
config,
lib,
...
}:
with lib; let
cfg = config.home.desktop.wlsunset;
in {
options.home.desktop.wlsunset = {
enable = mkEnableOption "Enables wlsunset";
latitude = mkOption {
type = with types; nullOr (oneOf [str ints.unsigned float]);
default = 48.5;
};
longitude = mkOption {
type = with types; nullOr (oneOf [str ints.unsigned float]);
default = 2.2;
};
};
config.services.wlsunset = mkIf cfg.enable {
inherit (cfg) enable latitude longitude;
};
}

View File

@@ -0,0 +1,76 @@
{
lib,
config,
...
}:
with lib; let
cfg = config.home.desktop.wofi;
in {
options.home.desktop.wofi.enable = mkEnableOption "Enable wofi support";
config.programs.wofi = mkIf cfg.enable {
inherit (cfg) enable;
settings = {
modi = "ssh,drun,combi";
sidebar-mode = false;
width = 50;
line-margin = 10;
lines = 6;
columns = 2;
display-ssh = "";
display-run = "";
display-drun = "";
display-window = "";
display-combi = "";
show-icons = true;
};
# from https://github.com/alxndr13/wofi-nord-theme
style = ''
* {
font-family: "Hack", monospace;
}
window {
background-color: #3B4252;
}
#input {
margin: 5px;
border-radius: 0px;
border: none;
background-color: #3B4252;
color: white;
}
#inner-box {
background-color: #383C4A;
}
#outer-box {
margin: 2px;
padding: 10px;
background-color: #383C4A;
}
#scroll {
margin: 5px;
}
#text {
padding: 4px;
color: white;
}
#entry:nth-child(even){
background-color: #404552;
}
#entry:selected {
background-color: #4C566A;
}
#text:selected {
background: transparent;
}
'';
};
}