From 912c91d60e1a68610333a533ed5f1aee1dde2f76 Mon Sep 17 00:00:00 2001 From: DashieTM Date: Sun, 28 Sep 2025 16:31:03 +0200 Subject: [PATCH 01/29] wip --- modules/programs/default.nix | 1 + modules/programs/greetd.nix | 3 ++- modules/programs/niri.nix | 48 ++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 modules/programs/niri.nix diff --git a/modules/programs/default.nix b/modules/programs/default.nix index ebc1ff4..e0ed56c 100644 --- a/modules/programs/default.nix +++ b/modules/programs/default.nix @@ -1,5 +1,6 @@ { imports = [ + ./niri.nix ./acpid.nix ./anyrun.nix ./basePackages.nix diff --git a/modules/programs/greetd.nix b/modules/programs/greetd.nix index 22954a1..7156771 100644 --- a/modules/programs/greetd.nix +++ b/modules/programs/greetd.nix @@ -55,7 +55,8 @@ }; environments = lib.mkOption { default = [ - inputs.hyprland.packages.${config.conf.system}.hyprland + (lib.mkIf config.mods.hypr.hyprland.enable inputs.hyprland.packages.${config.conf.system}.hyprland) + (lib.mkIf config.mods.niri.enable pkgs.niri) ]; # no idea if these are written correctly example = [ diff --git a/modules/programs/niri.nix b/modules/programs/niri.nix new file mode 100644 index 0000000..93f7f45 --- /dev/null +++ b/modules/programs/niri.nix @@ -0,0 +1,48 @@ +{ + mkDashDefault, + config, + lib, + options, + pkgs, + ... +}: let + browserName = + if (builtins.isString config.mods.homePackages.browser) + then config.mods.homePackages.browser + else if config.mods.homePackages.browser ? meta && config.mods.homePackages.browser.meta ? mainProgram + then config.mods.homePackages.browser.meta.mainProgram + else config.mods.homePackages.browser.pname; +in { + options.mods.niri = { + enable = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = '' + Enable Niri + ''; + }; + }; + + config = lib.mkIf config.mods.niri.enable ( + lib.optionalAttrs (options ? wayland.windowManager.hyprland) { + # TODO deduplicate and abstract away base window management config + # install Niri related packages + home.packages = with pkgs; [ + xorg.xprop + grim + slurp + satty + xdg-desktop-portal-gtk + xdg-desktop-portal-gnome + kdePackages.xdg-desktop-portal-kde + xdg-desktop-portal-shana + copyq + wl-clipboard + + niri + xwayland-satellite + ]; + } + ); +} From 72afd686c03073da2499e5e5ed7ee079837d7d44 Mon Sep 17 00:00:00 2001 From: DashieTM Date: Sun, 28 Sep 2025 18:42:15 +0200 Subject: [PATCH 02/29] wip --- modules/programs/niri.nix | 418 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 418 insertions(+) diff --git a/modules/programs/niri.nix b/modules/programs/niri.nix index 93f7f45..ac160a4 100644 --- a/modules/programs/niri.nix +++ b/modules/programs/niri.nix @@ -43,6 +43,424 @@ in { niri xwayland-satellite ]; + + xdg.configFile."niri/config.kdl" = { + text = + /* + kdl + */ + '' + input { + keyboard { + xkb { + layout "enIntUmlaut" + } + repeat-delay 200 + repeat-rate 25 + numlock + } + + touchpad { + tap + natural-scroll + } + + mouse { + accel-speed 0.2 + accel-profile "flat" + } + focus-follows-mouse max-scroll-amount="25%" + } + + // Outputs + output "DP-1" { + mode "3440x1440@180" + scale 1 + transform "normal" + position x=2560 y=0 + } + + output "DP-2" { + mode "2560x1440@165" + scale 1 + transform "normal" + position x=0 y=0 + } + + output "DP-3" { + mode "1920x1080@144.001" + scale 1 + transform "90" + position x=6000 y=0 + } + + layout { + // Set gaps around windows in logical pixels. + gaps 10 + center-focused-column "never" + always-center-single-column + + preset-column-widths { + proportion 0.33333 + proportion 0.5 + proportion 0.66667 + } + + default-column-width { proportion 0.5; } + // You can change how the focus ring looks. + focus-ring { + width 3 + inactive-color "#505050" + active-gradient from="#ff0000" to="#0000ff" angle=45 + } + + border { + off + } + + // You can enable drop shadows for windows. + shadow { + on + softness 30 + spread 5 + offset x=0 y=5 + color "#0007" + } + } + + // Autostart + spawn-at-startup "ironbar" + spawn-at-startup "oxinoti" + spawn-at-startup "oxipaste_daemon" + + // To run a shell command (with variables, pipes, etc.), use spawn-sh-at-startup: + // spawn-sh-at-startup "qs -c ~/source/qs/MyAwesomeShell" + + hotkey-overlay { + skip-at-startup + } + + // Uncomment this line to ask the clients to omit their client-side decorations if possible. + // If the client will specifically ask for CSD, the request will be honored. + // Additionally, clients will be informed that they are tiled, removing some client-side rounded corners. + // This option will also fix border/focus ring drawing behind some semitransparent windows. + // After enabling or disabling this, you need to restart the apps for this to take effect. + prefer-no-csd + + // You can change the path where screenshots are saved. + // A ~ at the front will be expanded to the home directory. + // The path is formatted with strftime(3) to give you the screenshot date and time. + screenshot-path "~/Pictures/Screenshots/Screenshot from %Y-%m-%d %H-%M-%S.png" + + // You can also set this to null to disable saving screenshots to disk. + // screenshot-path null + + // Animation settings. + // The wiki explains how to configure individual animations: + // https://yalter.github.io/niri/Configuration:-Animations + animations { + // Uncomment to turn off all animations. + // off + + // Slow down all animations by this factor. Values below 1 speed them up instead. + // slowdown 3.0 + } + + // Block screencapture + window-rule { + match app-id=r#"^org\.keepassxc\.KeePassXC$"# + match app-id=r#"^org\.gnome\.World\.Secrets$"# + + block-out-from "screen-capture" + } + + window-rule { + match app-id=r#"^nheko$"# + match app-id=r#"^vesktop$"# + + open-maximized true + } + + // General rules + window-rule { + geometry-corner-radius 12 + clip-to-geometry true + } + + + binds { + // Keys consist of modifiers separated by + signs, followed by an XKB key name + // in the end. To find an XKB name for a particular key, you may use a program + // like wev. + // + // "Mod" is a special modifier equal to Super when running on a TTY, and to Alt + // when running as a winit window. + // + // Most actions that you can bind here can also be invoked programmatically with + // `niri msg action do-something`. + + // Mod-Shift-/, which is usually the same as Mod-?, + // shows a list of important hotkeys. + Mod+Shift+Slash { show-hotkey-overlay; } + + // Suggested binds for running programs: terminal, app launcher, screen locker. + Mod+T hotkey-overlay-title="Open a Terminal: alacritty" { spawn "kitty"; } + Mod+R hotkey-overlay-title="Run an Application: fuzzel" { spawn "oxirun"; } + Super+Shift+L hotkey-overlay-title="Lock the Screen: hyprlock" { spawn "hyprlock"; } + Mod+F hotkey-overlay-title="Browser: Zen" { spawn "zen"; } + Mod+G hotkey-overlay-title="Run oxicalc" { spawn "oxicalc"; } + Mod+A hotkey-overlay-title="Run Clipboard manager" { spawn "oxipaste"; } + Mod+D hotkey-overlay-title="Run Shutdown window" { spawn "oxishut"; } + Mod+M hotkey-overlay-title="Run Notification Center" { spawn "oxidash"; } + + // Use spawn-sh to run a shell command. Do this if you need pipes, multiple commands, etc. + // Note: the entire command goes as a single argument. It's passed verbatim to `sh -c`. + // For example, this is a standard bind to toggle the screen reader (orca). + // Super+Alt+S allow-when-locked=true hotkey-overlay-title=null { spawn-sh "pkill orca || exec orca"; } + + // Example volume keys mappings for PipeWire & WirePlumber. + // The allow-when-locked=true property makes them work even when the session is locked. + // Using spawn-sh allows to pass multiple arguments together with the command. + XF86AudioRaiseVolume allow-when-locked=true { spawn-sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1+"; } + XF86AudioLowerVolume allow-when-locked=true { spawn-sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1-"; } + XF86AudioMute allow-when-locked=true { spawn-sh "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; } + XF86AudioMicMute allow-when-locked=true { spawn-sh "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"; } + + // Example brightness key mappings for brightnessctl. + // You can use regular spawn with multiple arguments too (to avoid going through "sh"), + // but you need to manually put each argument in separate "" quotes. + XF86MonBrightnessUp allow-when-locked=true { spawn "brightnessctl" "--class=backlight" "set" "+10%"; } + XF86MonBrightnessDown allow-when-locked=true { spawn "brightnessctl" "--class=backlight" "set" "10%-"; } + + // Open/close the Overview: a zoomed-out view of workspaces and windows. + // You can also move the mouse into the top-left hot corner, + // or do a four-finger swipe up on a touchpad. + Mod+W repeat=false { toggle-overview; } + + Mod+Q repeat=false { close-window; } + + Mod+Left { focus-column-left; } + Mod+Down { focus-window-down; } + Mod+Up { focus-window-up; } + Mod+Right { focus-column-right; } + Mod+J { focus-column-left; } + Mod+K { focus-window-down; } + Mod+L { focus-window-up; } + Mod+semicolon { focus-column-right; } + + Mod+Ctrl+Left { move-column-left; } + Mod+Ctrl+Down { move-window-down; } + Mod+Ctrl+Up { move-window-up; } + Mod+Ctrl+Right { move-column-right; } + Mod+Ctrl+J { move-column-left; } + Mod+Ctrl+K { move-window-down; } + Mod+Ctrl+L { move-window-up; } + Mod+Ctrl+semicolon { move-column-right; } + + // Alternative commands that move across workspaces when reaching + // the first or last window in a column. + // Mod+J { focus-window-or-workspace-down; } + // Mod+K { focus-window-or-workspace-up; } + // Mod+Ctrl+J { move-window-down-or-to-workspace-down; } + // Mod+Ctrl+K { move-window-up-or-to-workspace-up; } + + Mod+Home { focus-column-first; } + Mod+End { focus-column-last; } + Mod+Ctrl+Home { move-column-to-first; } + Mod+Ctrl+End { move-column-to-last; } + + Mod+Shift+Left { focus-monitor-left; } + Mod+Shift+Down { focus-monitor-down; } + Mod+Shift+Up { focus-monitor-up; } + Mod+Shift+Right { focus-monitor-right; } + Mod+Shift+H { focus-monitor-left; } + Mod+Shift+J { focus-monitor-down; } + Mod+Shift+K { focus-monitor-up; } + Mod+Shift+L { focus-monitor-right; } + + Mod+Shift+Ctrl+Left { move-column-to-monitor-left; } + Mod+Shift+Ctrl+Down { move-column-to-monitor-down; } + Mod+Shift+Ctrl+Up { move-column-to-monitor-up; } + Mod+Shift+Ctrl+Right { move-column-to-monitor-right; } + Mod+Shift+Ctrl+H { move-column-to-monitor-left; } + Mod+Shift+Ctrl+J { move-column-to-monitor-down; } + Mod+Shift+Ctrl+K { move-column-to-monitor-up; } + Mod+Shift+Ctrl+L { move-column-to-monitor-right; } + + // Alternatively, there are commands to move just a single window: + // Mod+Shift+Ctrl+Left { move-window-to-monitor-left; } + // ... + + // And you can also move a whole workspace to another monitor: + // Mod+Shift+Ctrl+Left { move-workspace-to-monitor-left; } + // ... + + Mod+Page_Down { focus-workspace-down; } + Mod+Page_Up { focus-workspace-up; } + Mod+U { focus-workspace-down; } + Mod+I { focus-workspace-up; } + Mod+Ctrl+Page_Down { move-column-to-workspace-down; } + Mod+Ctrl+Page_Up { move-column-to-workspace-up; } + Mod+Ctrl+U { move-column-to-workspace-down; } + Mod+Ctrl+I { move-column-to-workspace-up; } + + // Alternatively, there are commands to move just a single window: + // Mod+Ctrl+Page_Down { move-window-to-workspace-down; } + // ... + + Mod+Shift+Page_Down { move-workspace-down; } + Mod+Shift+Page_Up { move-workspace-up; } + Mod+Shift+U { move-workspace-down; } + Mod+Shift+I { move-workspace-up; } + + // You can bind mouse wheel scroll ticks using the following syntax. + // These binds will change direction based on the natural-scroll setting. + // + // To avoid scrolling through workspaces really fast, you can use + // the cooldown-ms property. The bind will be rate-limited to this value. + // You can set a cooldown on any bind, but it's most useful for the wheel. + Mod+WheelScrollDown cooldown-ms=150 { focus-workspace-down; } + Mod+WheelScrollUp cooldown-ms=150 { focus-workspace-up; } + Mod+Ctrl+WheelScrollDown cooldown-ms=150 { move-column-to-workspace-down; } + Mod+Ctrl+WheelScrollUp cooldown-ms=150 { move-column-to-workspace-up; } + + Mod+WheelScrollRight { focus-column-right; } + Mod+WheelScrollLeft { focus-column-left; } + Mod+Ctrl+WheelScrollRight { move-column-right; } + Mod+Ctrl+WheelScrollLeft { move-column-left; } + + // Usually scrolling up and down with Shift in applications results in + // horizontal scrolling; these binds replicate that. + Mod+Shift+WheelScrollDown { focus-column-right; } + Mod+Shift+WheelScrollUp { focus-column-left; } + Mod+Ctrl+Shift+WheelScrollDown { move-column-right; } + Mod+Ctrl+Shift+WheelScrollUp { move-column-left; } + + // Similarly, you can bind touchpad scroll "ticks". + // Touchpad scrolling is continuous, so for these binds it is split into + // discrete intervals. + // These binds are also affected by touchpad's natural-scroll, so these + // example binds are "inverted", since we have natural-scroll enabled for + // touchpads by default. + // Mod+TouchpadScrollDown { spawn-sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.02+"; } + // Mod+TouchpadScrollUp { spawn-sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.02-"; } + + // You can refer to workspaces by index. However, keep in mind that + // niri is a dynamic workspace system, so these commands are kind of + // "best effort". Trying to refer to a workspace index bigger than + // the current workspace count will instead refer to the bottommost + // (empty) workspace. + // + // For example, with 2 workspaces + 1 empty, indices 3, 4, 5 and so on + // will all refer to the 3rd workspace. + Mod+1 { focus-workspace 1; } + Mod+2 { focus-workspace 2; } + Mod+3 { focus-workspace 3; } + Mod+4 { focus-workspace 4; } + Mod+5 { focus-workspace 5; } + Mod+6 { focus-workspace 6; } + Mod+7 { focus-workspace 7; } + Mod+8 { focus-workspace 8; } + Mod+9 { focus-workspace 9; } + Mod+Ctrl+1 { move-column-to-workspace 1; } + Mod+Ctrl+2 { move-column-to-workspace 2; } + Mod+Ctrl+3 { move-column-to-workspace 3; } + Mod+Ctrl+4 { move-column-to-workspace 4; } + Mod+Ctrl+5 { move-column-to-workspace 5; } + Mod+Ctrl+6 { move-column-to-workspace 6; } + Mod+Ctrl+7 { move-column-to-workspace 7; } + Mod+Ctrl+8 { move-column-to-workspace 8; } + Mod+Ctrl+9 { move-column-to-workspace 9; } + + // Alternatively, there are commands to move just a single window: + // Mod+Ctrl+1 { move-window-to-workspace 1; } + + // Switches focus between the current and the previous workspace. + // Mod+Tab { focus-workspace-previous; } + + // The following binds move the focused window in and out of a column. + // If the window is alone, they will consume it into the nearby column to the side. + // If the window is already in a column, they will expel it out. + Mod+BracketLeft { consume-or-expel-window-left; } + Mod+BracketRight { consume-or-expel-window-right; } + + // Consume one window from the right to the bottom of the focused column. + Mod+Comma { consume-window-into-column; } + // Expel the bottom window from the focused column to the right. + Mod+Period { expel-window-from-column; } + + Mod+Y { switch-preset-column-width; } + // Cycling through the presets in reverse order is also possible. + // Mod+R { switch-preset-column-width-back; } + Mod+Shift+R { switch-preset-window-height; } + Mod+Ctrl+R { reset-window-height; } + Mod+B { fullscreen-window; } + + // Expand the focused column to space not taken up by other fully visible columns. + // Makes the column "fill the rest of the space". + Mod+Ctrl+F { expand-column-to-available-width; } + + Mod+C { center-column; } + + // Center all fully visible columns on screen. + Mod+Ctrl+C { center-visible-columns; } + + // Finer width adjustments. + // This command can also: + // * set width in pixels: "1000" + // * adjust width in pixels: "-5" or "+5" + // * set width as a percentage of screen width: "25%" + // * adjust width as a percentage of screen width: "-10%" or "+10%" + // Pixel sizes use logical, or scaled, pixels. I.e. on an output with scale 2.0, + // set-column-width "100" will make the column occupy 200 physical screen pixels. + Mod+Minus { set-column-width "-10%"; } + Mod+Equal { set-column-width "+10%"; } + + // Finer height adjustments when in column with other windows. + Mod+Shift+Minus { set-window-height "-10%"; } + Mod+Shift+Equal { set-window-height "+10%"; } + + // Move the focused window between the floating and the tiling layout. + Mod+V { toggle-window-floating; } + Mod+Shift+V { switch-focus-between-floating-and-tiling; } + + // Toggle tabbed column display mode. + // Windows in this column will appear as vertical tabs, + // rather than stacked on top of each other. + // Mod+W { toggle-column-tabbed-display; } + + // Actions to switch layouts. + // Note: if you uncomment these, make sure you do NOT have + // a matching layout switch hotkey configured in xkb options above. + // Having both at once on the same hotkey will break the switching, + // since it will switch twice upon pressing the hotkey (once by xkb, once by niri). + // Mod+Space { switch-layout "next"; } + // Mod+Shift+Space { switch-layout "prev"; } + + Mod+S { screenshot; } + Ctrl+Print { screenshot-screen; } + Alt+Print { screenshot-window; } + + // Applications such as remote-desktop clients and software KVM switches may + // request that niri stops processing the keyboard shortcuts defined here + // so they may, for example, forward the key presses as-is to a remote machine. + // It's a good idea to bind an escape hatch to toggle the inhibitor, + // so a buggy application can't hold your session hostage. + // + // The allow-inhibiting=false property can be applied to other binds as well, + // which ensures niri always processes them, even when an inhibitor is active. + Mod+Escape allow-inhibiting=false { toggle-keyboard-shortcuts-inhibit; } + + // The quit action will show a confirmation dialog to avoid accidental exits. + Mod+Shift+M { quit; } + // Ctrl+Alt+Delete { quit; } + + // Powers off the monitors. To turn them back on, do any input like + // moving the mouse or pressing any other key. + Mod+Shift+P { power-off-monitors; } + } + ''; + }; } ); } From 614342b9f7ba9dd8b60c95932f844f6705d843cb Mon Sep 17 00:00:00 2001 From: DashieTM Date: Mon, 29 Sep 2025 00:37:59 +0200 Subject: [PATCH 03/29] wip --- flake.nix | 2 +- home/common.nix | 1 + lib/wm.nix | 449 ++++++++++++++++++++ modules/programs/default.nix | 1 + modules/programs/fastfetch.nix | 1 - modules/programs/fish.nix | 1 + modules/programs/greetd.nix | 21 +- modules/programs/hypr/hyprland.nix | 393 +++++++----------- modules/programs/hypr/hyprlock.nix | 12 +- modules/programs/ironbar.nix | 27 +- modules/programs/niri.nix | 631 +++++++++++++---------------- modules/programs/oxi/default.nix | 6 +- modules/programs/wm.nix | 403 ++++++++++++++++++ 13 files changed, 1336 insertions(+), 612 deletions(-) create mode 100644 lib/wm.nix create mode 100644 modules/programs/wm.nix diff --git a/flake.nix b/flake.nix index 4058fb8..665829b 100644 --- a/flake.nix +++ b/flake.nix @@ -10,7 +10,7 @@ url = "github:nix-community/lanzaboote/v0.4.2"; inputs.nixpkgs.follows = "unstable"; }; - statix.url = "github:oppiliappan/statix"; + statix.url = "github:oppiliappan/statix?ref=master"; # Darkreader requires es20, hence a stable pin pkgsDarkreader.url = "github:NixOs/nixpkgs/nixos-24.11"; diff --git a/home/common.nix b/home/common.nix index 1a3ccf3..fe2fa53 100644 --- a/home/common.nix +++ b/home/common.nix @@ -2,6 +2,7 @@ mkDashDefault, config, lib, + pkgs, ... }: let username = config.conf.username; diff --git a/lib/wm.nix b/lib/wm.nix new file mode 100644 index 0000000..1352623 --- /dev/null +++ b/lib/wm.nix @@ -0,0 +1,449 @@ +{lib, ...}: let + browserName = config: + if (builtins.isString config.mods.homePackages.browser) + then config.mods.homePackages.browser + else if config.mods.homePackages.browser ? meta && config.mods.homePackages.browser.meta ? mainProgram + then config.mods.homePackages.browser.meta.mainProgram + else config.mods.homePackages.browser.pname; + mkSimpleBind = modKeys: key: command: args: { + inherit modKeys key command args; + }; + mkRepeatSimpleBind = modKeys: key: command: args: { + inherit modKeys key command args; + meta.hyprland.repeat = true; + }; + mkSimpleCustomBind = modKeys: key: niri: hyprland: args: { + inherit modKeys key args; + command = { + inherit niri hyprland; + }; + }; + mkRepeatCustomBind = modKeys: key: niri: hyprland: args: { + inherit modKeys key args; + command = { + inherit niri hyprland; + }; + meta.hyprland.repeat = true; + }; + mkBindWithDesc = modKeys: key: command: args: desc: + { + meta.niri.desc = desc; + } + // mkSimpleBind modKeys key command args; +in { + defaultWindowRules = { + niri = [ + '' + match app-id=r#"^org\.keepassxc\.KeePassXC$"# + match app-id=r#"^org\.gnome\.World\.Secrets$"# + + block-out-from "screen-capture" + '' + '' + match app-id=r#"^steam$"# + open-on-workspace "0" + '' + '' + geometry-corner-radius 12 + clip-to-geometry true + '' + ]; + hyprland = [ + # window rules + "float,class:^(.*)(OxiCalc)(.*)$" + "float,class:^(.*)(winecfg.exe)(.*)$" + "float,class:^(.*)(copyq)(.*)$" + "center,class:^(.*)(swappy)(.*)$" + "workspace 10 silent,class:^(.*)(steam)(.*)$" + + # Otherwise neovide will ignore tiling + "suppressevent fullscreen maximize,class:^(.*)(neovide)(.*)$" + ]; + }; + + defaultStartup = config: { + all = [ + "systemctl --user import-environment" + "dbus-update-activation-environment --systemd --all" + "hyprctl setcursor ${config.mods.stylix.cursor.name} ${toString config.mods.stylix.cursor.size}" + # ensures the systemd service knows what "hyprctl" is :) + ( + if config.mods.gaming.gamemode + then "systemctl try-restart gamemoded.service --user" + else "" + ) + + # other programs + "${browserName config}" + ( + if config.mods.oxi.hyprdock.enable + then "hyprdock --server" + else "" + ) + ( + if config.mods.hypr.hyprpaper.enable + then "hyprpaper" + else "" + ) + ( + if config.mods.hypr.hyprland.useIronbar + then "ironbar" + else "" + ) + ( + if config.mods.oxi.oxipaste.enable + then "oxipaste_daemon" + else "" + ) + ( + if config.mods.oxi.oxinoti.enable + then "oxinoti" + else "" + ) + ]; + niri = [ + "XDG_CURRENT_DESKTOP=Niri" + "XDG_SESSION_DESKTOP=Niri" + "XDG_SESSION_TYPE=wayland" + ]; + hyprland = [ + "XDG_CURRENT_DESKTOP=Hyprland" + "XDG_SESSION_DESKTOP=Hyprland" + "XDG_SESSION_TYPE=wayland" + ]; + }; + + defaultEnv = config: { + all = { + GTK_CSD = "0"; + TERM = "kitty /bin/fish"; + HYPRCURSOR_THEME = config.mods.stylix.cursor.name; + HYPRCURSOR_SIZE = toString config.mods.stylix.cursor.size; + XCURSOR_THEME = config.mods.stylix.cursor.name; + XCURSOR_SIZE = toString config.mods.stylix.cursor.size; + QT_QPA_PLATFORM = "wayland"; + QT_QPA_PLATFORMTHEME = "qt5ct"; + QT_WAYLAND_FORCE_DPI = "96"; + QT_AUTO_SCREEN_SCALE_FACTOR = "0"; + QT_WAYLAND_DISABLE_WINDOWDECORATION = "1"; + QT_SCALE_FACTOR = "1"; + EDITOR = "neovide --novsync --nofork"; + + LIBVA_DRIVER_NAME = + if config.mods.gpu.nvidia.enable + then "nvidia" + else ""; + GBM_BACKEND = + if config.mods.gpu.nvidia.enable + then "nvidia-drm" + else ""; + __GLX_VENDOR_LIBRARY_NAME = + if config.mods.gpu.nvidia.enable + then "nvidia" + else ""; + }; + niri = {}; + hyprland = {}; + }; + + defaultBinds = config: [ + (mkSimpleBind ["Mod"] "1" "focusWorkspace" ["1"]) + (mkSimpleBind ["Mod"] "2" "focusWorkspace" ["2"]) + (mkSimpleBind ["Mod"] "3" "focusWorkspace" ["3"]) + (mkSimpleBind ["Mod"] "4" "focusWorkspace" ["4"]) + (mkSimpleBind ["Mod"] "5" "focusWorkspace" ["5"]) + (mkSimpleBind ["Mod"] "6" "focusWorkspace" ["6"]) + (mkSimpleBind ["Mod"] "7" "focusWorkspace" ["7"]) + (mkSimpleBind ["Mod"] "8" "focusWorkspace" ["8"]) + (mkSimpleBind ["Mod"] "9" "focusWorkspace" ["9"]) + (mkSimpleBind ["Mod"] "0" "focusWorkspace" ["0"]) + (mkSimpleBind ["Mod" "Shift"] "1" "moveToWorkspace" ["1"]) + (mkSimpleBind ["Mod" "Shift"] "2" "moveToWorkspace" ["2"]) + (mkSimpleBind ["Mod" "Shift"] "3" "moveToWorkspace" ["3"]) + (mkSimpleBind ["Mod" "Shift"] "4" "moveToWorkspace" ["4"]) + (mkSimpleBind ["Mod" "Shift"] "5" "moveToWorkspace" ["5"]) + (mkSimpleBind ["Mod" "Shift"] "6" "moveToWorkspace" ["6"]) + (mkSimpleBind ["Mod" "Shift"] "7" "moveToWorkspace" ["7"]) + (mkSimpleBind ["Mod" "Shift"] "8" "moveToWorkspace" ["8"]) + (mkSimpleBind ["Mod" "Shift"] "9" "moveToWorkspace" ["9"]) + (mkSimpleBind ["Mod" "Shift"] "0" "moveToWorkspace" ["0"]) + (mkSimpleBind ["Mod"] "B" "toggleFullscreen" []) + (mkSimpleBind ["Mod"] "V" "toggleFloating" []) + (mkSimpleBind ["Mod" "Shift"] "M" "quit" []) + (mkSimpleBind ["Mod"] "Left" "moveWindowLeft" []) + (mkSimpleBind ["Mod"] "Down" "moveWindowDown" []) + (mkSimpleBind ["Mod"] "Up" "moveWindowUp" []) + (mkSimpleBind ["Mod"] "Right" "moveWindowRight" []) + + (mkRepeatSimpleBind ["Mod"] "J" "moveFocusLeft" []) + (mkRepeatSimpleBind ["Mod"] "K" "moveFocusDown" []) + (mkRepeatSimpleBind ["Mod"] "L" "moveFocusUp" []) + (mkRepeatSimpleBind ["Mod"] "semicolon" "moveFocusRight" []) + + (mkBindWithDesc ["Mod"] "Q" "killActive" [] "Kill active window") + + (mkBindWithDesc ["Mod"] "N" "spawn" ["neovide"] "Open Neovide") + (mkBindWithDesc ["Mod"] "T" "spawn-sh" ["kitty" "-1"] "Open Kitty") + (mkBindWithDesc ["Mod" "Shift"] "L" "spawn" ["hyprlock"] "Lock screen") + + ( + if config.mods.yazi.enable + then mkBindWithDesc ["Mod"] "E" "spawn-sh" ["EDITOR='neovide --no-fork' kitty yazi"] "Open Yazi" + else {} + ) + ( + if config.mods.anyrun.enable + then mkBindWithDesc ["Mod"] "R" "spawn" ["anyrun"] "Open Anyrun" + else {} + ) + ( + if config.mods.oxi.oxirun.enable + then mkBindWithDesc ["Mod"] "R" "spawn" ["oxirun"] "Open OxiRun" + else {} + ) + ( + if config.mods.oxi.oxidash.enable + then mkBindWithDesc ["Mod"] "M" "spawn" ["oxidash"] "Open OxiDash" + else {} + ) + ( + if config.mods.oxi.oxicalc.enable + then mkBindWithDesc ["Mod"] "G" "spawn" ["oxicalc"] "Open Oxicalc" + else {} + ) + ( + if config.mods.oxi.oxishut.enable + then mkBindWithDesc ["Mod"] "D" "spawn" ["oxishut"] "Open OxiShut" + else {} + ) + ( + if config.mods.oxi.oxipaste.enable + then mkBindWithDesc ["Mod"] "A" "spawn" ["oxipaste"] "Open Oxipaste" + else {} + ) + ( + if config.mods.oxi.hyprdock.enable + then mkBindWithDesc ["Mod" "Shift"] "P" "spawn" ["hyprdock --gui"] "Open Hyprdock" + else {} + ) + ( + if config.mods.hypr.hyprlock.enable + then mkBindWithDesc ["Mod" "Shift" "Alt"] "L" "spawn-sh" ["playerctl -a pause & hyprlock & systemctl suspend"] "Lock and suspend" + else {} + ) + ( + if config.mods.hypr.hyprlock.enable + then mkBindWithDesc ["Mod" "Shift" "Alt"] "K" "spawn-sh" ["playerctl -a pause & hyprlock & systemctl hibernate"] "Lock and hibernate" + else {} + ) + + (mkBindWithDesc ["Mod"] "F" "spawn" ["${browserName config}"] "Open Browser") + ( + if + ( + browserName config == "firefox" || browserName config == "zen" + ) + then mkBindWithDesc ["Mod" "Shift"] "F" "spawn" ["${browserName config} -p special"] "Open Browser Special Profile" + else {} + ) + + (mkBindWithDesc ["Mod"] "S" "spawn-sh" [''grim -g \"$(slurp)\" - | wl-copy''] "Take Screenshot") + (mkBindWithDesc ["Mod" "Shift"] "S" "spawn-sh" [''grim -g \"$(slurp)\" - | satty -f -''] "Take Screenshot and edit") + + ( + if config.mods.scripts.audioControl + then { + key = "XF86AudioMute"; + command = "spawn-sh"; + args = ["audioControl mute"]; + meta.niri = { + allowWhileLocked = true; + desc = "Mute Audio"; + }; + } + else {} + ) + ( + if config.mods.scripts.audioControl + then { + key = "XF86AudioRaiseVolume"; + command = "spawn-sh"; + args = ["audioControl +5%"]; + meta.niri = { + allowWhileLocked = true; + desc = "Raise Audio Volume"; + }; + } + else {} + ) + ( + if config.mods.scripts.audioControl + then { + key = "XF86AudioLowerVolume"; + command = "spawn-sh"; + args = ["audioControl -5%"]; + meta.niri = { + allowWhileLocked = true; + desc = "Lower Audio Volume"; + }; + } + else {} + ) + { + key = "XF86AudioPlay"; + command = "spawn-sh"; + args = ["playerctl play-pause"]; + meta.niri = { + allowWhileLocked = true; + desc = "Play/Pause"; + }; + } + { + key = "XF86AudioNext"; + command = "spawn-sh"; + args = ["playerctl next"]; + meta.niri = { + allowWhileLocked = true; + desc = "Next Song"; + }; + } + { + key = "XF86AudioPrev"; + command = "spawn-sh"; + args = ["playerctl previous"]; + meta.niri = { + allowWhileLocked = true; + desc = "Previous Song"; + }; + } + ( + if config.mods.scripts.changeBrightness + then { + key = "XF86MonBrightnessDown"; + command = "spawn-sh"; + args = ["changeBrightness -10%"]; + meta.niri = { + allowWhileLocked = true; + desc = "Lower Brigthness"; + }; + } + else {} + ) + ( + if config.mods.scripts.changeBrightness + then { + key = "XF86MonBrightnessUp"; + command = "spawn-sh"; + args = ["changeBrightness +10%"]; + meta.niri = { + allowWhileLocked = true; + desc = "Raise Brigthness"; + }; + } + else {} + ) + + # Niri only keybinds + (mkSimpleCustomBind ["Mod"] "BracketLeft" "consume-or-expel-window-left" null []) + (mkSimpleCustomBind ["Mod"] "BracketRight" "consume-or-expel-window-right" null []) + (mkSimpleCustomBind ["Mod"] "Comma" "consume-window-into-column" null []) + (mkSimpleCustomBind ["Mod"] "Period" "expel-window-from-column" null []) + (mkSimpleCustomBind ["Mod"] "Y" "switch-preset-column-width" null []) + (mkSimpleCustomBind ["Mod"] "Tab" "focus-workspace-previous" null []) + (mkSimpleCustomBind ["Mod" "Shift"] "V" "switch-focus-between-floating-and-tiling" null []) + (mkSimpleCustomBind ["Mod" "Shift"] "B" "expand-column-to-available-width" null []) + (mkSimpleCustomBind ["Mod"] "U" "set-column-width" null ["-10%"]) + (mkSimpleCustomBind ["Mod"] "P" "set-column-width" null ["+10%"]) + (mkSimpleCustomBind ["Mod"] "O" "set-column-width" null ["50%"]) + (mkSimpleCustomBind ["Mod" "Shift"] "Minus" "set-window-height" null ["-10%"]) + (mkSimpleCustomBind ["Mod" "Shift"] "Equal" "set-window-height" null ["+10%"]) + (mkSimpleCustomBind ["Mod" "Ctrl"] "1" "move-column-to-workspace" null ["1"]) + (mkSimpleCustomBind ["Mod" "Ctrl"] "2" "move-column-to-workspace" null ["2"]) + (mkSimpleCustomBind ["Mod" "Ctrl"] "3" "move-column-to-workspace" null ["3"]) + (mkSimpleCustomBind ["Mod" "Ctrl"] "4" "move-column-to-workspace" null ["4"]) + (mkSimpleCustomBind ["Mod" "Ctrl"] "5" "move-column-to-workspace" null ["5"]) + (mkSimpleCustomBind ["Mod" "Ctrl"] "6" "move-column-to-workspace" null ["6"]) + (mkSimpleCustomBind ["Mod" "Ctrl"] "7" "move-column-to-workspace" null ["7"]) + (mkSimpleCustomBind ["Mod" "Ctrl"] "8" "move-column-to-workspace" null ["8"]) + (mkSimpleCustomBind ["Mod" "Ctrl"] "9" "move-column-to-workspace" null ["9"]) + (mkSimpleCustomBind ["Mod" "Ctrl"] "0" "move-column-to-workspace" null ["0"]) + (mkSimpleCustomBind ["Mod" "Shift"] "J" "focus-monitor-left" null []) + (mkSimpleCustomBind ["Mod" "Shift"] "semicolon" "focus-monitor-right" null []) + (mkSimpleCustomBind ["Mod" "Ctrl"] "J" "move-column-to-monitor-left" null []) + (mkSimpleCustomBind ["Mod" "Ctrl"] "semicolon" "move-column-to-monitor-right" null []) + (mkSimpleCustomBind ["Mod" "Shift"] "Slash" "show-hotkey-overlay" null []) + { + modKeys = ["Mod"]; + key = "W"; + command.niri = "toggle-overview"; + meta.niri = { + desc = "Overview"; + repeat = false; + }; + } + { + modKeys = ["Mod"]; + key = "Escape"; + command.niri = "toggle-keyboard-shortcuts-inhibit"; + meta.niri = { + allowInhibit = false; + }; + } + { + modKeys = ["Mod"]; + key = "WheelScrollUp"; + command.niri = "focus-workspace-up"; + meta.niri.cooldown = 150; + } + { + modKeys = ["Mod"]; + key = "WheelScrollDown"; + command.niri = "focus-workspace-down"; + meta.niri.cooldown = 150; + } + { + modKeys = ["Mod"]; + key = "WheelScrollRight"; + command.niri = "focus-column-right"; + meta.niri.cooldown = 150; + } + { + modKeys = ["Mod"]; + key = "WheelScrollLeft"; + command.niri = "focus-column-left"; + meta.niri.cooldown = 150; + } + + # Hyprland only keybinds + (mkSimpleCustomBind ["Mod"] "C" null "togglesplit" []) + (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "1" null "movetoworkspacesilent" ["1"]) + (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "2" null "movetoworkspacesilent" ["2"]) + (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "3" null "movetoworkspacesilent" ["3"]) + (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "4" null "movetoworkspacesilent" ["4"]) + (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "5" null "movetoworkspacesilent" ["5"]) + (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "6" null "movetoworkspacesilent" ["6"]) + (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "7" null "movetoworkspacesilent" ["7"]) + (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "8" null "movetoworkspacesilent" ["8"]) + (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "9" null "movetoworkspacesilent" ["9"]) + (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "0" null "movetoworkspacesilent" ["0"]) + (mkRepeatCustomBind ["Mod"] "U" null "resizeactive" ["-20" "0"]) + (mkRepeatCustomBind ["Mod"] "P" null "resizeactive" ["20" "0"]) + (mkRepeatCustomBind ["Mod"] "O" null "resizeactive" ["0" "-20"]) + (mkRepeatCustomBind ["Mod"] "I" null "resizeactive" ["0" "20"]) + (mkSimpleCustomBind ["Mod" "ALT"] "J" null "layoutmsg" ["preselect" "l"]) + (mkSimpleCustomBind ["Mod" "ALT"] "K" null "layoutmsg" ["preselect" "d"]) + (mkSimpleCustomBind ["Mod" "ALT"] "L" null "layoutmsg" ["preselect" "u"]) + (mkSimpleCustomBind ["Mod" "ALT"] "semicolon" null "layoutmsg" ["preselect" "r"]) + (mkSimpleCustomBind ["Mod" "ALT"] "H" null "layoutmsg" ["preselect" "n"]) + ( + if config.mods.hypr.hyprland.hyprspaceEnable + then { + modKeys = ["Mod"]; + key = "W"; + command.hyprland = "overview:toggle"; + args = []; + } + else {} + ) + ]; +} diff --git a/modules/programs/default.nix b/modules/programs/default.nix index e0ed56c..1c0baa5 100644 --- a/modules/programs/default.nix +++ b/modules/programs/default.nix @@ -49,6 +49,7 @@ ./virtmanager.nix ./xkb.nix ./xone.nix + ./wm.nix ./yazi ]; } diff --git a/modules/programs/fastfetch.nix b/modules/programs/fastfetch.nix index f73b2cd..9953d84 100644 --- a/modules/programs/fastfetch.nix +++ b/modules/programs/fastfetch.nix @@ -1,5 +1,4 @@ { - mkDashDefault, pkgs, lib, options, diff --git a/modules/programs/fish.nix b/modules/programs/fish.nix index 2f18036..f063f35 100644 --- a/modules/programs/fish.nix +++ b/modules/programs/fish.nix @@ -56,6 +56,7 @@ in { abbr --add ls 'lsd' abbr --add :q 'exit' abbr --add gh 'git push origin' + abbr --add gu 'git push upstream' abbr --add gl 'git pull origin' abbr --add gm 'git commit -m' abbr --add ga "git add -A" diff --git a/modules/programs/greetd.nix b/modules/programs/greetd.nix index 7156771..2c5f87f 100644 --- a/modules/programs/greetd.nix +++ b/modules/programs/greetd.nix @@ -18,7 +18,10 @@ ''; }; monitor = lib.mkOption { - default = "${config.mods.hypr.hyprland.defaultMonitor}"; + default = + if config.mods.wm.monitors != [] + then (builtins.elemAt config.mods.wm.monitors 0).name + else ""; example = "eDP-1"; type = lib.types.str; description = '' @@ -27,7 +30,10 @@ ''; }; scale = lib.mkOption { - default = "${config.mods.hypr.hyprland.defaultMonitorScale}"; + default = + if config.mods.wm.monitors != [] + then builtins.toString (builtins.elemAt config.mods.wm.monitors 0).scale + else ""; example = "1.5"; type = lib.types.str; description = '' @@ -46,7 +52,14 @@ description = "The compositor/greeter command to run"; }; resolution = lib.mkOption { - default = "${config.mods.hypr.hyprland.defaultMonitorMode}"; + default = + if config.mods.wm.monitors != [] + then let + resX = builtins.toString (builtins.elemAt config.mods.wm.monitors 0).resolutionX; + resY = builtins.toString (builtins.elemAt config.mods.wm.monitors 0).resolutionY; + refresh = builtins.toString (builtins.elemAt config.mods.wm.monitors 0).refreshrate; + in "${resX}x${resY}@${refresh}" + else ""; example = "3440x1440@180"; type = lib.types.str; description = '' @@ -83,7 +96,7 @@ }; config = let - username = config.conf.username; + inherit (config.conf) username; in lib.mkIf config.mods.greetd.enable ( lib.optionalAttrs (options ? environment) { diff --git a/modules/programs/hypr/hyprland.nix b/modules/programs/hypr/hyprland.nix index 111e10b..f6ee377 100644 --- a/modules/programs/hypr/hyprland.nix +++ b/modules/programs/hypr/hyprland.nix @@ -6,12 +6,7 @@ pkgs, ... }: let - browserName = - if (builtins.isString config.mods.homePackages.browser) - then config.mods.homePackages.browser - else if config.mods.homePackages.browser ? meta && config.mods.homePackages.browser.meta ? mainProgram - then config.mods.homePackages.browser.meta.mainProgram - else config.mods.homePackages.browser.pname; + defaultWmConf = import ../../../lib/wm.nix {inherit lib;}; in { options.mods.hypr.hyprland = { enable = lib.mkOption { @@ -22,64 +17,12 @@ in { Enable Hyprland ''; }; - defaultMonitor = lib.mkOption { - default = ""; - example = "eDP-1"; - type = lib.types.str; - description = '' - main monitor - ''; - }; - defaultMonitorMode = lib.mkOption { - default = ""; - example = "3440x1440@180"; - type = lib.types.str; - description = '' - main monitor mode: width x height @ refreshrate - ''; - }; - defaultMonitorScale = lib.mkOption { - default = "1"; - example = "1.5"; - type = lib.types.str; - description = '' - main monitor scaling - ''; - }; - monitor = lib.mkOption { - default = [ - # main monitor - "${config.mods.hypr.hyprland.defaultMonitor},${config.mods.hypr.hyprland.defaultMonitorMode},0x0,${config.mods.hypr.hyprland.defaultMonitorScale}" - # all others - ]; - example = ["DP-1,3440x1440@180,2560x0,1,vrr,0"]; - type = with lib.types; listOf str; - description = '' - The monitor configuration for hyprland. - ''; - }; - workspace = lib.mkOption { - default = []; - example = ["2,monitor:DP-1, default:true"]; - type = with lib.types; listOf str; - description = '' - The workspace configuration for hyprland. - ''; - }; noAtomic = lib.mkOption { default = false; example = true; type = lib.types.bool; description = '' - Use tearing - ''; - }; - extraAutostart = lib.mkOption { - default = []; - example = ["your application"]; - type = lib.types.listOf lib.types.str; - description = '' - Extra exec_once. + Use tearing (Warning, can be buggy) ''; }; useIronbar = lib.mkOption { @@ -90,14 +33,6 @@ in { Whether to use ironbar in hyprland. ''; }; - ironbarSingleMonitor = lib.mkOption { - default = true; - example = false; - type = lib.types.bool; - description = '' - Whether to use ironbar on a single monitor. - ''; - }; useDefaultConfig = lib.mkOption { default = true; example = false; @@ -160,7 +95,151 @@ in { hyprpicker ]; - wayland.windowManager.hyprland = { + wayland.windowManager.hyprland = let + mkWorkspace = workspaces: + builtins.map (workspace: let + default = + if workspace.default + then ",default:true" + else ""; + in "${workspace.name},monitor:${workspace.monitor}${default}") + workspaces; + mkTransform = transform: + if transform == "0" + then 0 + else if transform == "90" + then 1 + else if transform == "180" + then 2 + else if transform == "270" + then 3 + else 4; + mkVrr = vrr: + if vrr + then "1" + else "0"; + mkMonitors = monitors: + builtins.map ( + monitor: "${monitor.name},${builtins.toString monitor.resolutionX}x${builtins.toString monitor.resolutionY}@${builtins.toString monitor.refreshrate},${builtins.toString monitor.positionX}x${builtins.toString monitor.positionY},${builtins.toString monitor.scale}, transform,${builtins.toString (mkTransform monitor.transform)}, vrr,${mkVrr monitor.vrr}" + ) + monitors; + + mkMods = bind: let + mods = bind.modKeys or []; + in + builtins.map (mod: + if mod == "Mod" + then (lib.strings.toUpper config.mods.wm.modKey) + " " + else lib.strings.toUpper mod) + mods + |> lib.strings.concatStringsSep ""; + mkArgs = args: + if args != [] + then (lib.strings.concatStringsSep " " args) + else ""; + shouldRepeat = bind: bind ? meta && bind.meta ? hyprland && bind.meta.hyprland ? repeat && bind.meta.hyprland.repeat; + + defaultBinds = cfg: + if cfg.mods.wm.useDefaultBinds + then defaultWmConf.defaultBinds cfg + else []; + + mkEBinds = cfg: let + binds = cfg.mods.wm.binds ++ defaultBinds cfg; + in + binds + |> builtins.filter (bind: bind ? command && shouldRepeat bind && !hasInvalidCustomCommand bind) + |> builtins.map ( + bind: "${mkMods bind},${bind.key},${mkCommand bind}" + ); + mkBinds = cfg: let + binds = cfg.mods.wm.binds ++ defaultBinds cfg; + in + binds + |> builtins.filter (bind: bind ? command && !(shouldRepeat bind) && !hasInvalidCustomCommand bind) + |> builtins.map ( + bind: "${mkMods bind},${bind.key},${mkCommand bind}" + ); + mkCommand = bind: let + args = bind.args or []; + in + if bind.command == "quit" + then "exit" + else if bind.command == "killActive" + then "killactive" + else if bind.command == "moveWindowRight" + then "movewindow,r" + else if bind.command == "moveWindowDown" + then "movewindow,d" + else if bind.command == "moveWindowLeft" + then "movewindow,l" + else if bind.command == "moveWindowUp" + then "movewindow,u" + else if bind.command == "moveFocusUp" + then "movefocus,u" + else if bind.command == "moveFocusRight" + then "movefocus,r" + else if bind.command == "moveFocusDown" + then "movefocus,d" + else if bind.command == "moveFocusLeft" + then "movefocus,l" + else if bind.command == "toggleFloating" + then "togglefloating" + else if bind.command == "toggleFullscreen" + then "fullscreen" + else if bind.command == "focusWorkspace" + then "workspace" + "," + mkArgs args + else if bind.command == "moveToWorkspace" + then "movetoworkspace" + "," + mkArgs args + else if bind.command == "spawn" + then "exec" + "," + mkArgs args + else if bind.command == "spawn-sh" + then "exec" + "," + mkArgs args + else bind.command.hyprland + "," + mkArgs args; + hasInvalidCustomCommand = bind: !(builtins.isString bind.command) && bind.command.hyprland or null == null; + + mkEnv = config: let + defaultEnv = + if config.mods.wm.useDefaultEnv + then defaultWmConf.defaultEnv config + else { + all = {}; + hyprland = {}; + }; + userEnv = + if config.mods.wm.env ? all + then config.mods.wm.env.all // config.mods.wm.env.hyprland + else config.mods.wm.env; + env = userEnv // defaultEnv.all // defaultEnv.hyprland; + in + lib.attrsets.mapAttrsToList ( + name: value: "${name},${value}" + ) + env; + mkAutoStart = config: let + defaultStartup = + if config.mods.wm.useDefaultStartup + then defaultWmConf.defaultStartup config + else { + all = []; + hyprland = []; + }; + userStartup = + if config.mods.wm.startup ? all + then config.mods.wm.startup.all ++ config.mods.wm.startup.hyprland + else config.mods.wm.startup; + autoStart = userStartup ++ defaultStartup.all ++ defaultStartup.hyprland; + in + autoStart; + mkWindowRule = config: let + defaultWindowRules = + if config.mods.wm.useDefaultWindowRules + then defaultWmConf.defaultWindowRules.hyprland + else []; + in + # defaultWindowRules ++ config.mods.wm.windowRules.hyprland; + defaultWindowRules; + in { enable = true; package = mkDashDefault pkgs.hyprland; plugins = @@ -174,124 +253,13 @@ in { lib.mkMerge [ { - "$mod" = mkDashDefault "SUPER"; + "$mod" = mkDashDefault config.mods.wm.modKey; bindm = [ "$mod, mouse:272, movewindow" "$mod, mouse:273, resizeactive" ]; - bind = [ - # screenshots - ''$mod SUPER,S,exec,grim -g "$(slurp)" - | wl-copy'' - ''$mod SUPERSHIFT,S,exec,grim -g "$(slurp)" - | satty -f -'' - - # regular programs - "$mod SUPER,F,exec,${browserName}" - (lib.mkIf ( - browserName == "firefox" || browserName == "zen" - ) "$mod SUPERSHIFT,F,exec,${browserName} -p special") - "$mod SUPER,T,exec,kitty -1" - "$mod SUPER,E,exec,nautilus -w" - (lib.mkIf config.mods.yazi.enable "$mod SUPER,Y,exec, EDITOR='neovide --no-fork' kitty yazi") - "$mod SUPER,N,exec,neovide" - (lib.mkIf config.mods.anyrun.enable "$mod SUPER,R,exec,anyrun") - (lib.mkIf config.mods.oxi.oxirun.enable "$mod SUPER,R,exec,oxirun") - (lib.mkIf config.mods.oxi.oxidash.enable "$mod SUPER,M,exec,oxidash") - (lib.mkIf config.mods.oxi.oxicalc.enable "$mod SUPER,G,exec,oxicalc") - (lib.mkIf config.mods.oxi.oxishut.enable "$mod SUPER,D,exec,oxishut") - (lib.mkIf config.mods.oxi.oxipaste.enable "$mod SUPER,A,exec,oxipaste") - (lib.mkIf config.mods.oxi.hyprdock.enable "$mod SUPERSHIFT,P,exec,hyprdock --gui") - (lib.mkIf config.mods.hypr.hyprlock.enable "$mod SUPERSHIFT,L,exec, playerctl -a pause & hyprlock & systemctl suspend") - (lib.mkIf config.mods.hypr.hyprlock.enable "$mod SUPERSHIFT,K,exec, playerctl -a pause & hyprlock & systemctl hibernate") - - # media keys - (lib.mkIf config.mods.scripts.audioControl ",XF86AudioMute,exec, audioControl mute") - (lib.mkIf config.mods.scripts.audioControl ",XF86AudioLowerVolume,exec, audioControl sink -5%") - (lib.mkIf config.mods.scripts.audioControl ",XF86AudioRaiseVolume,exec, audioControl sink +5%") - ",XF86AudioPlay,exec, playerctl play-pause" - ",XF86AudioNext,exec, playerctl next" - ",XF86AudioPrev,exec, playerctl previous" - (lib.mkIf config.mods.scripts.changeBrightness ",XF86MonBrightnessDown,exec, changeBrightness 10%-") - (lib.mkIf config.mods.scripts.changeBrightness ",XF86MonBrightnessUp,exec, changeBrightness +10%") - - # hyprland keybinds - # misc - "$mod SUPER,V,togglefloating," - "$mod SUPER,B,fullscreen," - "$mod SUPER,C,togglesplit" - "$mod SUPER,Q,killactive," - "$mod SUPERSHIFTALT,M,exit," - "$mod SUPERSHIFT,W,togglespecialworkspace" - - # move - "$mod SUPER,left,movewindow,l" - "$mod SUPER,right,movewindow,r" - "$mod SUPER,up,movewindow,u" - "$mod SUPER,down,movewindow,d" - - # workspaces - "$mod SUPER,1,workspace,1" - "$mod SUPER,2,workspace,2" - "$mod SUPER,3,workspace,3" - "$mod SUPER,4,workspace,4" - "$mod SUPER,5,workspace,5" - "$mod SUPER,6,workspace,6" - "$mod SUPER,7,workspace,7" - "$mod SUPER,8,workspace,8" - "$mod SUPER,9,workspace,9" - "$mod SUPER,0,workspace,10" - - # move to workspace - "$mod SUPERSHIFT,1,movetoworkspace,1" - "$mod SUPERSHIFT,2,movetoworkspace,2" - "$mod SUPERSHIFT,3,movetoworkspace,3" - "$mod SUPERSHIFT,4,movetoworkspace,4" - "$mod SUPERSHIFT,5,movetoworkspace,5" - "$mod SUPERSHIFT,6,movetoworkspace,6" - "$mod SUPERSHIFT,7,movetoworkspace,7" - "$mod SUPERSHIFT,8,movetoworkspace,8" - "$mod SUPERSHIFT,9,movetoworkspace,9" - "$mod SUPERSHIFT,0,movetoworkspace,10" - - # move to workspace silent - "$mod SUPERSHIFTALT,1,movetoworkspacesilent,1" - "$mod SUPERSHIFTALT,2,movetoworkspacesilent,2" - "$mod SUPERSHIFTALT,3,movetoworkspacesilent,3" - "$mod SUPERSHIFTALT,4,movetoworkspacesilent,4" - "$mod SUPERSHIFTALT,5,movetoworkspacesilent,5" - "$mod SUPERSHIFTALT,6,movetoworkspacesilent,6" - "$mod SUPERSHIFTALT,7,movetoworkspacesilent,7" - "$mod SUPERSHIFTALT,8,movetoworkspacesilent,8" - "$mod SUPERSHIFTALT,9,movetoworkspacesilent,9" - "$mod SUPERSHIFTALT,0,movetoworkspacesilent,10" - - # preselection - "$mod SUPERALT,j,layoutmsg,preselect l" - "$mod SUPERALT,k,layoutmsg,preselect d" - "$mod SUPERALT,l,layoutmsg,preselect u" - "$mod SUPERALT,semicolon,layoutmsg,preselect r" - "$mod SUPERALT,h,layoutmsg,preselect n" - ]; - - binde = [ - # hyprland keybinds - # focus - "$mod SUPER,J,movefocus,l" - "$mod SUPER,semicolon,movefocus,r" - "$mod SUPER,L,movefocus,u" - "$mod SUPER,K,movefocus,d" - - # resize - "$mod SUPER,U,resizeactive,-20 0" - "$mod SUPER,P,resizeactive,20 0" - "$mod SUPER,O,resizeactive,0 -20" - "$mod SUPER,I,resizeactive,0 20" - - (lib.mkIf config.mods.hypr.hyprland.hyprspaceEnable - "SUPER, W, overview:toggle") - ]; - general = { gaps_out = mkDashDefault "3,5,5,5"; border_size = mkDashDefault 3; @@ -364,70 +332,19 @@ in { "3, horizontal, workspace" ]; - monitor = mkDashDefault config.mods.hypr.hyprland.monitor; - workspace = mkDashDefault config.mods.hypr.hyprland.workspace; - - env = [ - "GTK_CSD,0" - ''TERM,"kitty /bin/fish"'' - "XDG_CURRENT_DESKTOP=Hyprland" - "XDG_SESSION_TYPE=wayland" - "XDG_SESSION_DESKTOP=Hyprland" - "HYPRCURSOR_THEME,${config.mods.stylix.cursor.name}" - "HYPRCURSOR_SIZE,${toString config.mods.stylix.cursor.size}" - "XCURSOR_THEME,${config.mods.stylix.cursor.name}" - "XCURSOR_SIZE,${toString config.mods.stylix.cursor.size}" - "QT_QPA_PLATFORM,wayland" - "QT_QPA_PLATFORMTHEME,qt5ct" - "QT_WAYLAND_FORCE_DPI,96" - "QT_AUTO_SCREEN_SCALE_FACTOR,0" - "QT_WAYLAND_DISABLE_WINDOWDECORATION,1" - "QT_SCALE_FACTOR,1" - ''EDITOR,"neovide --novsync --nofork"'' - - (lib.mkIf config.mods.gpu.nvidia.enable "LIBVA_DRIVER_NAME,nvidia") - (lib.mkIf config.mods.gpu.nvidia.enable "XDG_SESSION_TYPE,wayland") - (lib.mkIf config.mods.gpu.nvidia.enable "GBM_BACKEND,nvidia-drm") - (lib.mkIf config.mods.gpu.nvidia.enable "__GLX_VENDOR_LIBRARY_NAME,nvidia") - ]; - layerrule = [ # layer rules # mainly to disable animations within slurp and grim "noanim, selection" ]; - windowrule = [ - # window rules - "float,class:^(.*)(OxiCalc)(.*)$" - "float,class:^(.*)(winecfg.exe)(.*)$" - "float,class:^(.*)(copyq)(.*)$" - "center,class:^(.*)(swappy)(.*)$" - "workspace 10 silent,class:^(.*)(steam)(.*)$" - - # Otherwise neovide will ignore tiling - "suppressevent fullscreen maximize,class:^(.*)(neovide)(.*)$" - ]; - - exec-once = - [ - # environment - "systemctl --user import-environment" - "dbus-update-activation-environment --systemd --all" - "hyprctl setcursor ${config.mods.stylix.cursor.name} ${toString config.mods.stylix.cursor.size}" - # ensures the systemd service knows what "hyprctl" is :) - (lib.mkIf config.mods.gaming.gamemode "systemctl try-restart gamemoded.service --user") - - # other programs - "${browserName}" - (lib.mkIf config.mods.oxi.hyprdock.enable "hyprdock --server") - (lib.mkIf config.mods.hypr.hyprpaper.enable "hyprpaper") - (lib.mkIf config.mods.hypr.hyprland.useIronbar "ironbar") - (lib.mkIf config.mods.oxi.oxipaste.enable "oxipaste_daemon") - (lib.mkIf config.mods.oxi.oxinoti.enable "oxinoti") - ] - ++ config.mods.hypr.hyprland.extraAutostart; - + workspace = mkDashDefault (mkWorkspace config.mods.wm.workspaces); + monitor = mkDashDefault (mkMonitors config.mods.wm.monitors); + env = mkDashDefault (mkEnv config); + bind = mkDashDefault (mkBinds config); + binde = mkDashDefault (mkEBinds config); + windowrule = mkDashDefault (mkWindowRule config); + exec-once = mkDashDefault (mkAutoStart config); plugin = config.mods.hypr.hyprland.pluginConfig; } config.mods.hypr.hyprland.customConfig diff --git a/modules/programs/hypr/hyprlock.nix b/modules/programs/hypr/hyprlock.nix index 30ea707..c152b22 100644 --- a/modules/programs/hypr/hyprlock.nix +++ b/modules/programs/hypr/hyprlock.nix @@ -24,14 +24,22 @@ input-field = [ { - monitor = "${config.mods.hypr.hyprland.defaultMonitor}"; + monitor = "${ + if config.mods.wm.monitors != [] + then (builtins.elemAt config.mods.wm.monitors 0).name + else "" + }"; placeholder_text = "password or something"; } ]; label = [ { - monitor = "${config.mods.hypr.hyprland.defaultMonitor}"; + monitor = "${ + if config.mods.wm.monitors != [] + then (builtins.elemAt config.mods.wm.monitors 0).name + else "" + }"; text = "$TIME"; font_size = 50; position = "0, 200"; diff --git a/modules/programs/ironbar.nix b/modules/programs/ironbar.nix index 9a4bac4..5757347 100644 --- a/modules/programs/ironbar.nix +++ b/modules/programs/ironbar.nix @@ -1,5 +1,4 @@ { - mkDashDefault, lib, config, pkgs, @@ -7,7 +6,7 @@ options, ... }: let - username = config.conf.username; + inherit (config.conf) username; base16 = pkgs.callPackage inputs.base16.lib {}; scheme = base16.mkSchemeAttrs config.stylix.base16Scheme; ironbarDefaultConfig = useBatteryModule: { @@ -183,8 +182,15 @@ ]; }; monitorConfig = useBatteryModule: - if config.mods.hypr.hyprland.ironbarSingleMonitor - then {monitors.${config.mods.hypr.hyprland.defaultMonitor} = ironbarDefaultConfig useBatteryModule;} + if config.mods.ironbar.ironbarSingleMonitor + then { + monitors.${ + if config.mods.wm.monitors != [] + then (builtins.elemAt config.mods.wm.monitors 0).name + else "" + } = + ironbarDefaultConfig useBatteryModule; + } else ironbarDefaultConfig useBatteryModule; in { options.mods = { @@ -195,6 +201,14 @@ in { type = lib.types.bool; description = "Enables ironbar"; }; + ironbarSingleMonitor = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = '' + Whether to use ironbar on a single monitor. + ''; + }; useDefaultConfig = lib.mkOption { default = true; example = false; @@ -257,6 +271,7 @@ in { @import url("/home/${username}/.config/gtk-3.0/gtk.css"); @define-color primary #${scheme.base0D}; + @define-color warning #${scheme.base0F}; @define-color muted-text #${scheme.base05}; @define-color background #${scheme.base00}; @define-color secondary-background #${scheme.base02}; @@ -406,6 +421,10 @@ in { color: @primary; } + .workspaces .item:not(.visible) { + color: @warning; + } + .workspaces .item.focused { background-color: @primary; color: @background; diff --git a/modules/programs/niri.nix b/modules/programs/niri.nix index ac160a4..cf39776 100644 --- a/modules/programs/niri.nix +++ b/modules/programs/niri.nix @@ -6,12 +6,7 @@ pkgs, ... }: let - browserName = - if (builtins.isString config.mods.homePackages.browser) - then config.mods.homePackages.browser - else if config.mods.homePackages.browser ? meta && config.mods.homePackages.browser.meta ? mainProgram - then config.mods.homePackages.browser.meta.mainProgram - else config.mods.homePackages.browser.pname; + defaultWmConf = import ../../lib/wm.nix {inherit lib;}; in { options.mods.niri = { enable = lib.mkOption { @@ -22,6 +17,23 @@ in { Enable Niri ''; }; + useDefaultConfig = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = '' + Use preconfigured Niri config. + ''; + }; + customConfig = lib.mkOption { + default = ''''; + example = ''''; + type = lib.types.lines; + description = '' + Custom Niri configuration. + Will be merged with default configuration if enabled. + ''; + }; }; config = lib.mkIf config.mods.niri.enable ( @@ -44,8 +56,243 @@ in { xwayland-satellite ]; - xdg.configFile."niri/config.kdl" = { - text = + xdg.configFile."niri/config.kdl" = let + mkNiriMod = mods: + builtins.map (mod: + if mod == "Mod" + then config.mods.wm.modKey + "+" + else "${mod}" + "+") + mods + |> lib.strings.concatStringsSep ""; + mkNiriArg = args: + if args != [] + then "\"${(lib.strings.concatStringsSep " " args)}\"" + else ""; + mkNiriCommand = bind: let + args = bind.args or []; + in + if bind.command == "quit" + then "quit;" + else if bind.command == "killActive" + then "close-window;" + else if bind.command == "moveFocusTop" + then "focus-window-up;" + else if bind.command == "focusWorkspace" + then "focus-workspace" + " " + mkNiriArg args + ";" + else if bind.command == "moveWindowRight" + then "move-column-right-or-to-monitor-right;" + else if bind.command == "moveWindowDown" + then "move-window-down;" + else if bind.command == "moveWindowLeft" + then "move-column-left-or-to-monitor-left;" + else if bind.command == "moveWindowUp" + then "move-window-up;" + else if bind.command == "moveFocusUp" + then "focus-window-up;" + else if bind.command == "moveFocusRight" + then "focus-column-or-monitor-right;" + else if bind.command == "moveFocusDown" + then "focus-window-down;" + else if bind.command == "moveFocusLeft" + then "focus-column-or-monitor-left;" + else if bind.command == "toggleFloating" + then "toggle-window-floating;" + else if bind.command == "toggleFullscreen" + then "fullscreen-window;" + else if bind.command == "moveToWorkspace" + then "move-window-to-workspace" + " " + mkNiriArg args + ";" + else if bind.command == "spawn" + then "spawn" + " " + mkNiriArg args + ";" + else if bind.command == "spawn-sh" + then "spawn-sh" + " " + mkNiriArg args + ";" + else if bind.command.niri != null + then bind.command.niri + " " + mkNiriArg args + ";" + else ""; + + mkNiriBinds = cfg: + '' binds { + '' + + ( + ( + builtins.map ( + bind: + /* + kdl + */ + if bind ? key && bind ? command + then '' + ${mkNiriMod (bind.modKeys or [])}${bind.key} ${ + if + bind ? meta + && bind.meta ? niri + then + ( + if + bind.meta.niri ? desc + && bind.meta.niri.desc != "" + then "hotkey-overlay-title=\"" + bind.meta.niri.desc + "\"" + else "" + ) + + " " + + ( + if + bind.meta.niri ? repeat + && bind.meta.niri.repeat + then "repeat=true" + else "repeat=false" + ) + + " " + + ( + if + bind.meta.niri ? allowWhileLocked + && bind.meta.niri.allowWhileLocked + then "allow-when-locked=true" + else "" + ) + + " " + + ( + if + bind.meta.niri ? allowInhibit + && bind.meta.niri.allowInhibit + then "allow-inhibiting=true" + else "allow-inhibiting=false" + ) + else "" + } { ${ + mkNiriCommand bind + } } + '' + else '''' + ) + (( + cfg.mods.wm.binds + ++ ( + if cfg.mods.wm.useDefaultBinds + then defaultWmConf.defaultBinds cfg + else [] + ) + ) + |> builtins.filter (bind: !(hasInvalidCustomCommand bind))) + ) + |> lib.strings.concatLines + ) + + '' + } + ''; + mkVrr = vrr: + if vrr + then "true" + else "false"; + mkNiriMonitors = cfg: + (builtins.map ( + monitor: + # TODO vrr + /* + kdl + */ + '' + output "${monitor.name}" { + variable-refresh-rate on-demand=${mkVrr monitor.vrr} + mode "${builtins.toString monitor.resolutionX}x${builtins.toString monitor.resolutionY}@${builtins.toString monitor.refreshrate}" + scale ${builtins.toString monitor.scale} + transform "${ + if (monitor.transform == "0") + then "normal" + else monitor.transform + }" + position x=${builtins.toString monitor.positionX} y=${builtins.toString monitor.positionY} + } + '' + ) + cfg.mods.wm.monitors) + |> lib.strings.concatLines; + mkNiriWorkspaces = cfg: + (builtins.map ( + workspace: + /* + kdl + */ + '' + workspace "${workspace.name}" { + open-on-output "${workspace.monitor}" + } + '' + ) + cfg.mods.wm.workspaces) + |> lib.strings.concatLines; + mkNiriWindowRules = cfg: ( + ( + builtins.map ( + rule: + /* + kdl + */ + '' + window-rule { + ${rule} + } + '' + ) + ( + cfg.mods.wm.windowRules.niri + ++ ( + if cfg.mods.wm.useDefaultWindowRules + then defaultWmConf.defaultWindowRules.niri + else [] + ) + ) + ) + |> lib.strings.concatLines + ); + hasInvalidCustomCommand = bind: !(bind ? command) || (!(builtins.isString bind.command) && bind.command.niri or null == null); + mkNiriEnv = config: let + defaultEnv = + if config.mods.wm.useDefaultEnv + then defaultWmConf.defaultEnv config + else { + all = {}; + niri = {}; + }; + userEnv = + if config.mods.wm.env ? all + then config.mods.wm.env.all // config.mods.wm.env.niri + else config.mods.wm.env; + env = + userEnv + // defaultEnv.all + // defaultEnv.niri; + in + '' + environment { + '' + + ( + lib.attrsets.mapAttrsToList ( + name: value: "${name} \"${value}\"" + ) + env + |> lib.strings.concatLines + ) + + '' + } + ''; + mkNiriAutoStart = config: let + defaultStartup = + if config.mods.wm.useDefaultStartup + then defaultWmConf.defaultStartup config + else { + all = {}; + niri = {}; + }; + userStartup = + if config.mods.wm.startup ? all + then config.mods.wm.startup.all ++ config.mods.wm.startup.niri + else config.mods.wm.startup; + autoStart = userStartup ++ defaultStartup.all ++ defaultStartup.niri; + in + (builtins.map (value: "spawn-at-startup \"${value}\"") + autoStart) + |> lib.strings.concatLines; + defaultConfig = /* kdl */ @@ -69,31 +316,10 @@ in { accel-speed 0.2 accel-profile "flat" } + focus-follows-mouse max-scroll-amount="25%" } - // Outputs - output "DP-1" { - mode "3440x1440@180" - scale 1 - transform "normal" - position x=2560 y=0 - } - - output "DP-2" { - mode "2560x1440@165" - scale 1 - transform "normal" - position x=0 y=0 - } - - output "DP-3" { - mode "1920x1080@144.001" - scale 1 - transform "90" - position x=6000 y=0 - } - layout { // Set gaps around windows in logical pixels. gaps 10 @@ -103,15 +329,14 @@ in { preset-column-widths { proportion 0.33333 proportion 0.5 - proportion 0.66667 + proportion 1.0 } default-column-width { proportion 0.5; } - // You can change how the focus ring looks. focus-ring { width 3 inactive-color "#505050" - active-gradient from="#ff0000" to="#0000ff" angle=45 + active-gradient from="#ff0000" to="#00ff00" angle=45 } border { @@ -129,338 +354,26 @@ in { } // Autostart - spawn-at-startup "ironbar" - spawn-at-startup "oxinoti" - spawn-at-startup "oxipaste_daemon" - - // To run a shell command (with variables, pipes, etc.), use spawn-sh-at-startup: - // spawn-sh-at-startup "qs -c ~/source/qs/MyAwesomeShell" hotkey-overlay { skip-at-startup } - // Uncomment this line to ask the clients to omit their client-side decorations if possible. - // If the client will specifically ask for CSD, the request will be honored. - // Additionally, clients will be informed that they are tiled, removing some client-side rounded corners. - // This option will also fix border/focus ring drawing behind some semitransparent windows. - // After enabling or disabling this, you need to restart the apps for this to take effect. prefer-no-csd - - // You can change the path where screenshots are saved. - // A ~ at the front will be expanded to the home directory. - // The path is formatted with strftime(3) to give you the screenshot date and time. - screenshot-path "~/Pictures/Screenshots/Screenshot from %Y-%m-%d %H-%M-%S.png" - - // You can also set this to null to disable saving screenshots to disk. - // screenshot-path null - - // Animation settings. - // The wiki explains how to configure individual animations: - // https://yalter.github.io/niri/Configuration:-Animations - animations { - // Uncomment to turn off all animations. - // off - - // Slow down all animations by this factor. Values below 1 speed them up instead. - // slowdown 3.0 - } - - // Block screencapture - window-rule { - match app-id=r#"^org\.keepassxc\.KeePassXC$"# - match app-id=r#"^org\.gnome\.World\.Secrets$"# - - block-out-from "screen-capture" - } - - window-rule { - match app-id=r#"^nheko$"# - match app-id=r#"^vesktop$"# - - open-maximized true - } - - // General rules - window-rule { - geometry-corner-radius 12 - clip-to-geometry true - } - - - binds { - // Keys consist of modifiers separated by + signs, followed by an XKB key name - // in the end. To find an XKB name for a particular key, you may use a program - // like wev. - // - // "Mod" is a special modifier equal to Super when running on a TTY, and to Alt - // when running as a winit window. - // - // Most actions that you can bind here can also be invoked programmatically with - // `niri msg action do-something`. - - // Mod-Shift-/, which is usually the same as Mod-?, - // shows a list of important hotkeys. - Mod+Shift+Slash { show-hotkey-overlay; } - - // Suggested binds for running programs: terminal, app launcher, screen locker. - Mod+T hotkey-overlay-title="Open a Terminal: alacritty" { spawn "kitty"; } - Mod+R hotkey-overlay-title="Run an Application: fuzzel" { spawn "oxirun"; } - Super+Shift+L hotkey-overlay-title="Lock the Screen: hyprlock" { spawn "hyprlock"; } - Mod+F hotkey-overlay-title="Browser: Zen" { spawn "zen"; } - Mod+G hotkey-overlay-title="Run oxicalc" { spawn "oxicalc"; } - Mod+A hotkey-overlay-title="Run Clipboard manager" { spawn "oxipaste"; } - Mod+D hotkey-overlay-title="Run Shutdown window" { spawn "oxishut"; } - Mod+M hotkey-overlay-title="Run Notification Center" { spawn "oxidash"; } - - // Use spawn-sh to run a shell command. Do this if you need pipes, multiple commands, etc. - // Note: the entire command goes as a single argument. It's passed verbatim to `sh -c`. - // For example, this is a standard bind to toggle the screen reader (orca). - // Super+Alt+S allow-when-locked=true hotkey-overlay-title=null { spawn-sh "pkill orca || exec orca"; } - - // Example volume keys mappings for PipeWire & WirePlumber. - // The allow-when-locked=true property makes them work even when the session is locked. - // Using spawn-sh allows to pass multiple arguments together with the command. - XF86AudioRaiseVolume allow-when-locked=true { spawn-sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1+"; } - XF86AudioLowerVolume allow-when-locked=true { spawn-sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.1-"; } - XF86AudioMute allow-when-locked=true { spawn-sh "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; } - XF86AudioMicMute allow-when-locked=true { spawn-sh "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"; } - - // Example brightness key mappings for brightnessctl. - // You can use regular spawn with multiple arguments too (to avoid going through "sh"), - // but you need to manually put each argument in separate "" quotes. - XF86MonBrightnessUp allow-when-locked=true { spawn "brightnessctl" "--class=backlight" "set" "+10%"; } - XF86MonBrightnessDown allow-when-locked=true { spawn "brightnessctl" "--class=backlight" "set" "10%-"; } - - // Open/close the Overview: a zoomed-out view of workspaces and windows. - // You can also move the mouse into the top-left hot corner, - // or do a four-finger swipe up on a touchpad. - Mod+W repeat=false { toggle-overview; } - - Mod+Q repeat=false { close-window; } - - Mod+Left { focus-column-left; } - Mod+Down { focus-window-down; } - Mod+Up { focus-window-up; } - Mod+Right { focus-column-right; } - Mod+J { focus-column-left; } - Mod+K { focus-window-down; } - Mod+L { focus-window-up; } - Mod+semicolon { focus-column-right; } - - Mod+Ctrl+Left { move-column-left; } - Mod+Ctrl+Down { move-window-down; } - Mod+Ctrl+Up { move-window-up; } - Mod+Ctrl+Right { move-column-right; } - Mod+Ctrl+J { move-column-left; } - Mod+Ctrl+K { move-window-down; } - Mod+Ctrl+L { move-window-up; } - Mod+Ctrl+semicolon { move-column-right; } - - // Alternative commands that move across workspaces when reaching - // the first or last window in a column. - // Mod+J { focus-window-or-workspace-down; } - // Mod+K { focus-window-or-workspace-up; } - // Mod+Ctrl+J { move-window-down-or-to-workspace-down; } - // Mod+Ctrl+K { move-window-up-or-to-workspace-up; } - - Mod+Home { focus-column-first; } - Mod+End { focus-column-last; } - Mod+Ctrl+Home { move-column-to-first; } - Mod+Ctrl+End { move-column-to-last; } - - Mod+Shift+Left { focus-monitor-left; } - Mod+Shift+Down { focus-monitor-down; } - Mod+Shift+Up { focus-monitor-up; } - Mod+Shift+Right { focus-monitor-right; } - Mod+Shift+H { focus-monitor-left; } - Mod+Shift+J { focus-monitor-down; } - Mod+Shift+K { focus-monitor-up; } - Mod+Shift+L { focus-monitor-right; } - - Mod+Shift+Ctrl+Left { move-column-to-monitor-left; } - Mod+Shift+Ctrl+Down { move-column-to-monitor-down; } - Mod+Shift+Ctrl+Up { move-column-to-monitor-up; } - Mod+Shift+Ctrl+Right { move-column-to-monitor-right; } - Mod+Shift+Ctrl+H { move-column-to-monitor-left; } - Mod+Shift+Ctrl+J { move-column-to-monitor-down; } - Mod+Shift+Ctrl+K { move-column-to-monitor-up; } - Mod+Shift+Ctrl+L { move-column-to-monitor-right; } - - // Alternatively, there are commands to move just a single window: - // Mod+Shift+Ctrl+Left { move-window-to-monitor-left; } - // ... - - // And you can also move a whole workspace to another monitor: - // Mod+Shift+Ctrl+Left { move-workspace-to-monitor-left; } - // ... - - Mod+Page_Down { focus-workspace-down; } - Mod+Page_Up { focus-workspace-up; } - Mod+U { focus-workspace-down; } - Mod+I { focus-workspace-up; } - Mod+Ctrl+Page_Down { move-column-to-workspace-down; } - Mod+Ctrl+Page_Up { move-column-to-workspace-up; } - Mod+Ctrl+U { move-column-to-workspace-down; } - Mod+Ctrl+I { move-column-to-workspace-up; } - - // Alternatively, there are commands to move just a single window: - // Mod+Ctrl+Page_Down { move-window-to-workspace-down; } - // ... - - Mod+Shift+Page_Down { move-workspace-down; } - Mod+Shift+Page_Up { move-workspace-up; } - Mod+Shift+U { move-workspace-down; } - Mod+Shift+I { move-workspace-up; } - - // You can bind mouse wheel scroll ticks using the following syntax. - // These binds will change direction based on the natural-scroll setting. - // - // To avoid scrolling through workspaces really fast, you can use - // the cooldown-ms property. The bind will be rate-limited to this value. - // You can set a cooldown on any bind, but it's most useful for the wheel. - Mod+WheelScrollDown cooldown-ms=150 { focus-workspace-down; } - Mod+WheelScrollUp cooldown-ms=150 { focus-workspace-up; } - Mod+Ctrl+WheelScrollDown cooldown-ms=150 { move-column-to-workspace-down; } - Mod+Ctrl+WheelScrollUp cooldown-ms=150 { move-column-to-workspace-up; } - - Mod+WheelScrollRight { focus-column-right; } - Mod+WheelScrollLeft { focus-column-left; } - Mod+Ctrl+WheelScrollRight { move-column-right; } - Mod+Ctrl+WheelScrollLeft { move-column-left; } - - // Usually scrolling up and down with Shift in applications results in - // horizontal scrolling; these binds replicate that. - Mod+Shift+WheelScrollDown { focus-column-right; } - Mod+Shift+WheelScrollUp { focus-column-left; } - Mod+Ctrl+Shift+WheelScrollDown { move-column-right; } - Mod+Ctrl+Shift+WheelScrollUp { move-column-left; } - - // Similarly, you can bind touchpad scroll "ticks". - // Touchpad scrolling is continuous, so for these binds it is split into - // discrete intervals. - // These binds are also affected by touchpad's natural-scroll, so these - // example binds are "inverted", since we have natural-scroll enabled for - // touchpads by default. - // Mod+TouchpadScrollDown { spawn-sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.02+"; } - // Mod+TouchpadScrollUp { spawn-sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.02-"; } - - // You can refer to workspaces by index. However, keep in mind that - // niri is a dynamic workspace system, so these commands are kind of - // "best effort". Trying to refer to a workspace index bigger than - // the current workspace count will instead refer to the bottommost - // (empty) workspace. - // - // For example, with 2 workspaces + 1 empty, indices 3, 4, 5 and so on - // will all refer to the 3rd workspace. - Mod+1 { focus-workspace 1; } - Mod+2 { focus-workspace 2; } - Mod+3 { focus-workspace 3; } - Mod+4 { focus-workspace 4; } - Mod+5 { focus-workspace 5; } - Mod+6 { focus-workspace 6; } - Mod+7 { focus-workspace 7; } - Mod+8 { focus-workspace 8; } - Mod+9 { focus-workspace 9; } - Mod+Ctrl+1 { move-column-to-workspace 1; } - Mod+Ctrl+2 { move-column-to-workspace 2; } - Mod+Ctrl+3 { move-column-to-workspace 3; } - Mod+Ctrl+4 { move-column-to-workspace 4; } - Mod+Ctrl+5 { move-column-to-workspace 5; } - Mod+Ctrl+6 { move-column-to-workspace 6; } - Mod+Ctrl+7 { move-column-to-workspace 7; } - Mod+Ctrl+8 { move-column-to-workspace 8; } - Mod+Ctrl+9 { move-column-to-workspace 9; } - - // Alternatively, there are commands to move just a single window: - // Mod+Ctrl+1 { move-window-to-workspace 1; } - - // Switches focus between the current and the previous workspace. - // Mod+Tab { focus-workspace-previous; } - - // The following binds move the focused window in and out of a column. - // If the window is alone, they will consume it into the nearby column to the side. - // If the window is already in a column, they will expel it out. - Mod+BracketLeft { consume-or-expel-window-left; } - Mod+BracketRight { consume-or-expel-window-right; } - - // Consume one window from the right to the bottom of the focused column. - Mod+Comma { consume-window-into-column; } - // Expel the bottom window from the focused column to the right. - Mod+Period { expel-window-from-column; } - - Mod+Y { switch-preset-column-width; } - // Cycling through the presets in reverse order is also possible. - // Mod+R { switch-preset-column-width-back; } - Mod+Shift+R { switch-preset-window-height; } - Mod+Ctrl+R { reset-window-height; } - Mod+B { fullscreen-window; } - - // Expand the focused column to space not taken up by other fully visible columns. - // Makes the column "fill the rest of the space". - Mod+Ctrl+F { expand-column-to-available-width; } - - Mod+C { center-column; } - - // Center all fully visible columns on screen. - Mod+Ctrl+C { center-visible-columns; } - - // Finer width adjustments. - // This command can also: - // * set width in pixels: "1000" - // * adjust width in pixels: "-5" or "+5" - // * set width as a percentage of screen width: "25%" - // * adjust width as a percentage of screen width: "-10%" or "+10%" - // Pixel sizes use logical, or scaled, pixels. I.e. on an output with scale 2.0, - // set-column-width "100" will make the column occupy 200 physical screen pixels. - Mod+Minus { set-column-width "-10%"; } - Mod+Equal { set-column-width "+10%"; } - - // Finer height adjustments when in column with other windows. - Mod+Shift+Minus { set-window-height "-10%"; } - Mod+Shift+Equal { set-window-height "+10%"; } - - // Move the focused window between the floating and the tiling layout. - Mod+V { toggle-window-floating; } - Mod+Shift+V { switch-focus-between-floating-and-tiling; } - - // Toggle tabbed column display mode. - // Windows in this column will appear as vertical tabs, - // rather than stacked on top of each other. - // Mod+W { toggle-column-tabbed-display; } - - // Actions to switch layouts. - // Note: if you uncomment these, make sure you do NOT have - // a matching layout switch hotkey configured in xkb options above. - // Having both at once on the same hotkey will break the switching, - // since it will switch twice upon pressing the hotkey (once by xkb, once by niri). - // Mod+Space { switch-layout "next"; } - // Mod+Shift+Space { switch-layout "prev"; } - - Mod+S { screenshot; } - Ctrl+Print { screenshot-screen; } - Alt+Print { screenshot-window; } - - // Applications such as remote-desktop clients and software KVM switches may - // request that niri stops processing the keyboard shortcuts defined here - // so they may, for example, forward the key presses as-is to a remote machine. - // It's a good idea to bind an escape hatch to toggle the inhibitor, - // so a buggy application can't hold your session hostage. - // - // The allow-inhibiting=false property can be applied to other binds as well, - // which ensures niri always processes them, even when an inhibitor is active. - Mod+Escape allow-inhibiting=false { toggle-keyboard-shortcuts-inhibit; } - - // The quit action will show a confirmation dialog to avoid accidental exits. - Mod+Shift+M { quit; } - // Ctrl+Alt+Delete { quit; } - - // Powers off the monitors. To turn them back on, do any input like - // moving the mouse or pressing any other key. - Mod+Shift+P { power-off-monitors; } - } - ''; - }; + '' + + mkNiriMonitors config + + mkNiriBinds config + + mkNiriWorkspaces config + + mkNiriWindowRules config + + mkNiriEnv config + + mkNiriAutoStart config; + in + mkDashDefault { + text = + if config.mods.niri.useDefaultConfig + then defaultConfig + config.mods.niri.customConfig + else config.mods.niri.customConfig; + }; } ); } diff --git a/modules/programs/oxi/default.nix b/modules/programs/oxi/default.nix index 99de567..942d0d1 100644 --- a/modules/programs/oxi/default.nix +++ b/modules/programs/oxi/default.nix @@ -54,8 +54,8 @@ lib.optionalAttrs (options ? home.packages) { programs = { hyprdock = { - enable = config.mods.oxi.hyprdock.enable; - settings = config.mods.oxi.hyprdock.settings; + inherit (config.mods.oxi.hyprdock) enable; + inherit (config.mods.oxi.hyprdock) settings; }; oxicalc.enable = lib.mkIf config.mods.oxi.oxicalc.enable true; ReSet = lib.mkIf config.mods.oxi.ReSet.enable { @@ -75,7 +75,7 @@ }; } // lib.optionalAttrs (options ? services.logind) { - services.logind.lidSwitchExternalPower = "ignore"; + services.logind.settings.Login.HandleLidSwitchExternalPower = "ignore"; } ); } diff --git a/modules/programs/wm.nix b/modules/programs/wm.nix new file mode 100644 index 0000000..2dd6bba --- /dev/null +++ b/modules/programs/wm.nix @@ -0,0 +1,403 @@ +{lib, ...}: let + wmWorkspace = with lib.types; { + options = { + name = lib.mkOption { + default = ""; + example = "1"; + type = str; + description = "Name of the workspace"; + }; + default = lib.mkOption { + default = false; + example = true; + type = bool; + description = "Whether the workspace is the default workspace. (Currently doesn't do anything on niri)"; + }; + monitor = lib.mkOption { + default = ""; + example = "DP-1"; + type = str; + description = "Name of the monitor to bind the workspace to"; + }; + }; + }; + + wmOptions = with lib.types; { + options = { + name = lib.mkOption { + default = "DP-1"; + example = "DP-1"; + type = str; + description = "Name of the monitor"; + }; + resolutionX = lib.mkOption { + default = 1920; + example = 2560; + type = number; + description = "ResolutionX of the monitor"; + }; + resolutionY = lib.mkOption { + default = 1080; + example = 1440; + type = number; + description = "ResolutionY of the monitor"; + }; + refreshrate = lib.mkOption { + default = 60; + example = 144; + type = number; + description = "Refreshrate of the monitor"; + }; + positionX = lib.mkOption { + default = 0; + example = 1920; + type = number; + description = "PositionX of the monitor"; + }; + positionY = lib.mkOption { + default = 0; + example = 1080; + type = number; + description = "PositionY of the monitor"; + }; + scale = lib.mkOption { + default = 1; + example = 2; + type = number; + description = "Scale of the monitor"; + }; + transform = lib.mkOption { + default = "0"; + example = "90"; + type = enum ["0" "90" "180" "270" "360"]; + description = "Transform of the monitor"; + }; + vrr = lib.mkOption { + default = false; + example = true; + type = bool; + description = "VRR status of the monitor"; + }; + }; + }; + + modKeys = lib.types.enum ["Mod" "Super" "Alt" "Shift" "Ctrl"]; + + customCommand = with lib.types; { + options = { + niri = lib.mkOption { + default = null; + example = "kitty"; + type = either null str; + description = "Command to use in niri"; + }; + hyprland = lib.mkOption { + default = null; + example = "kitty"; + type = either null str; + description = "Command to use in hyprland"; + }; + }; + }; + + envOptions = with lib.types; { + options = { + all = lib.mkOption { + default = {}; + example = {}; + type = attrsOf str; + description = "General Env"; + }; + niri = lib.mkOption { + default = {}; + example = {}; + type = attrsOf str; + description = "Niri Env"; + }; + hyprland = lib.mkOption { + default = {}; + example = {}; + type = attrsOf str; + description = "Hyprland Env"; + }; + }; + }; + + startupOptions = with lib.types; { + options = { + all = lib.mkOption { + default = []; + example = []; + type = listOf str; + description = "General Startup commands"; + }; + niri = lib.mkOption { + default = []; + example = []; + type = listOf str; + description = "Niri Startup commands"; + }; + hyprland = lib.mkOption { + default = []; + example = []; + type = listOf str; + description = "Hyprland Startup commands"; + }; + }; + }; + + windowRuleOptions = with lib.types; { + options = { + niri = lib.mkOption { + default = []; + example = []; + type = listOf lines; + description = "Niri window rules"; + }; + hyprland = lib.mkOption { + default = []; + example = []; + type = listOf str; + description = "Hyprland window rules"; + }; + }; + }; + + bindOptions = with lib.types; { + options = { + modKeys = lib.mkOption { + default = []; + example = ["Mod"]; + type = listOf modKeys; + description = "List of modifier keys"; + }; + key = lib.mkOption { + default = ""; + example = "Q"; + type = str; + description = "Key to bind"; + }; + command = lib.mkOption { + default = ""; + example = "killActive"; + type = either (submodule customCommand) (enum [ + "spawn" + "spawn-sh" + "quit" + "killActive" + "moveFocusUp" + "moveFocusRight" + "moveFocusDown" + "moveFocusLeft" + "moveWindowUp" + "moveWindowRight" + "moveWindowDown" + "moveWindowLeft" + "focusWorkspace" + "moveToWorkspace" + "toggleFloating" + "toggleFullscreen" + ]); + description = "Command to execute"; + }; + args = lib.mkOption { + default = []; + example = []; + type = listOf str; + description = "Additional arguments for the command"; + }; + meta = lib.mkOption { + default = {}; + example = {}; + type = submodule { + options = { + niri = lib.mkOption { + default = {}; + type = submodule { + options = { + desc = lib.mkOption { + default = ""; + type = str; + description = "Description for Hotkey overview"; + }; + repeat = lib.mkOption { + type = bool; + default = true; + description = "Whether to repeat the keybind on hold"; + }; + allowInhibit = lib.mkOption { + type = bool; + default = true; + description = "Whether to allow inhibiting"; + }; + allowWhileLocked = lib.mkOption { + type = bool; + default = false; + description = "Whether to allow while locked"; + }; + cooldown = lib.mkOption { + type = number; + default = 0; + description = "Cooldown on bind"; + }; + }; + }; + description = "Niri meta for keybinds"; + }; + hyprland = lib.mkOption { + default = {}; + type = submodule { + options = { + repeat = lib.mkOption { + type = bool; + default = true; + description = "Whether to repeat the keybind on hold"; + }; + }; + }; + description = "Niri meta for keybinds"; + }; + }; + }; + description = "Custom metadata per bind. Note, only supported environments are taken into account."; + }; + }; + }; +in { + options.mods.wm = { + modKey = lib.mkOption { + default = "Super"; + example = "Alt"; + type = modKeys; + description = "Mod key"; + }; + + env = lib.mkOption { + default = {}; + example = { + all = { + EDITOR = "Neovim"; + }; + niri = { + EDITOR = "Emacs"; + }; + }; + type = with lib.types; either (submodule envOptions) (attrsOf str); + description = "Environment configuration"; + }; + + useDefaultEnv = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = "Whether to use default env variables"; + }; + + startup = lib.mkOption { + default = []; + example = { + all = ["oxinoti"]; + niri = ["someniricommand"]; + hyprland = ["somehyprlandcommand"]; + }; + type = with lib.types; either (submodule startupOptions) (listOf str); + description = "Start commands"; + }; + + useDefaultStartup = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = "Whether to use default autostart commands"; + }; + + useDefaultWindowRules = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = "Whether to use default window rules"; + }; + + windowRules = lib.mkOption { + default = []; + example = { + niri = [ + '' + match app-id=r#"^org\.keepassxc\.KeePassXC$"# + match app-id=r#"^org\.gnome\.World\.Secrets$"# + + block-out-from "screen-capture" + '' + '' + match app-id=r#"^steam$"# + open-on-workspace "0" + '' + ]; + }; + type = lib.types.submodule windowRuleOptions; + description = "Window rules"; + }; + + workspaces = lib.mkOption { + default = []; + example = [ + { + name = "chat"; + monitor = "DP-1"; + } + ]; + type = + lib.types.listOf (lib.types.submodule wmWorkspace); + description = "Workspace configuration"; + }; + + monitors = lib.mkOption { + default = []; + example = [ + { + name = "DP-1"; + resolutionX = 1920; + resolutionY = 1080; + refreshrate = 144; + positionX = 0; + positionY = 0; + scale = 1; + transform = "0"; + vrr = false; + } + ]; + type = + lib.types.listOf (lib.types.submodule wmOptions); + description = "Monitor configuration"; + }; + + useDefaultBinds = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = "Whether to use default keybinds"; + }; + + binds = lib.mkOption { + default = []; + example = [ + { + modKeys = ["Mod"]; + key = "Q"; + command = "killActive"; + args = []; + meta = { + niri = { + desc = "Kill the active window"; + repeat = false; + }; + hyprland = {}; + }; + } + ]; + type = + lib.types.listOf (lib.types.submodule bindOptions); + description = "Bind configuration"; + }; + }; +} From 1857504bacbe6ce972f33e5e3a318475b210cb05 Mon Sep 17 00:00:00 2001 From: DashieTM Date: Sun, 5 Oct 2025 13:24:30 +0200 Subject: [PATCH 04/29] feature(niri): Init module --- flake.nix | 2 +- home/common.nix | 1 + lib/wm.nix | 449 +++++++++++++++++++++++++++++ modules/programs/default.nix | 2 + modules/programs/fastfetch.nix | 1 - modules/programs/fish.nix | 1 + modules/programs/greetd.nix | 24 +- modules/programs/hypr/hyprland.nix | 393 ++++++++++--------------- modules/programs/hypr/hyprlock.nix | 12 +- modules/programs/ironbar.nix | 27 +- modules/programs/niri.nix | 379 ++++++++++++++++++++++++ modules/programs/oxi/default.nix | 6 +- modules/programs/wm.nix | 403 ++++++++++++++++++++++++++ 13 files changed, 1446 insertions(+), 254 deletions(-) create mode 100644 lib/wm.nix create mode 100644 modules/programs/niri.nix create mode 100644 modules/programs/wm.nix diff --git a/flake.nix b/flake.nix index 4058fb8..665829b 100644 --- a/flake.nix +++ b/flake.nix @@ -10,7 +10,7 @@ url = "github:nix-community/lanzaboote/v0.4.2"; inputs.nixpkgs.follows = "unstable"; }; - statix.url = "github:oppiliappan/statix"; + statix.url = "github:oppiliappan/statix?ref=master"; # Darkreader requires es20, hence a stable pin pkgsDarkreader.url = "github:NixOs/nixpkgs/nixos-24.11"; diff --git a/home/common.nix b/home/common.nix index 1a3ccf3..fe2fa53 100644 --- a/home/common.nix +++ b/home/common.nix @@ -2,6 +2,7 @@ mkDashDefault, config, lib, + pkgs, ... }: let username = config.conf.username; diff --git a/lib/wm.nix b/lib/wm.nix new file mode 100644 index 0000000..1352623 --- /dev/null +++ b/lib/wm.nix @@ -0,0 +1,449 @@ +{lib, ...}: let + browserName = config: + if (builtins.isString config.mods.homePackages.browser) + then config.mods.homePackages.browser + else if config.mods.homePackages.browser ? meta && config.mods.homePackages.browser.meta ? mainProgram + then config.mods.homePackages.browser.meta.mainProgram + else config.mods.homePackages.browser.pname; + mkSimpleBind = modKeys: key: command: args: { + inherit modKeys key command args; + }; + mkRepeatSimpleBind = modKeys: key: command: args: { + inherit modKeys key command args; + meta.hyprland.repeat = true; + }; + mkSimpleCustomBind = modKeys: key: niri: hyprland: args: { + inherit modKeys key args; + command = { + inherit niri hyprland; + }; + }; + mkRepeatCustomBind = modKeys: key: niri: hyprland: args: { + inherit modKeys key args; + command = { + inherit niri hyprland; + }; + meta.hyprland.repeat = true; + }; + mkBindWithDesc = modKeys: key: command: args: desc: + { + meta.niri.desc = desc; + } + // mkSimpleBind modKeys key command args; +in { + defaultWindowRules = { + niri = [ + '' + match app-id=r#"^org\.keepassxc\.KeePassXC$"# + match app-id=r#"^org\.gnome\.World\.Secrets$"# + + block-out-from "screen-capture" + '' + '' + match app-id=r#"^steam$"# + open-on-workspace "0" + '' + '' + geometry-corner-radius 12 + clip-to-geometry true + '' + ]; + hyprland = [ + # window rules + "float,class:^(.*)(OxiCalc)(.*)$" + "float,class:^(.*)(winecfg.exe)(.*)$" + "float,class:^(.*)(copyq)(.*)$" + "center,class:^(.*)(swappy)(.*)$" + "workspace 10 silent,class:^(.*)(steam)(.*)$" + + # Otherwise neovide will ignore tiling + "suppressevent fullscreen maximize,class:^(.*)(neovide)(.*)$" + ]; + }; + + defaultStartup = config: { + all = [ + "systemctl --user import-environment" + "dbus-update-activation-environment --systemd --all" + "hyprctl setcursor ${config.mods.stylix.cursor.name} ${toString config.mods.stylix.cursor.size}" + # ensures the systemd service knows what "hyprctl" is :) + ( + if config.mods.gaming.gamemode + then "systemctl try-restart gamemoded.service --user" + else "" + ) + + # other programs + "${browserName config}" + ( + if config.mods.oxi.hyprdock.enable + then "hyprdock --server" + else "" + ) + ( + if config.mods.hypr.hyprpaper.enable + then "hyprpaper" + else "" + ) + ( + if config.mods.hypr.hyprland.useIronbar + then "ironbar" + else "" + ) + ( + if config.mods.oxi.oxipaste.enable + then "oxipaste_daemon" + else "" + ) + ( + if config.mods.oxi.oxinoti.enable + then "oxinoti" + else "" + ) + ]; + niri = [ + "XDG_CURRENT_DESKTOP=Niri" + "XDG_SESSION_DESKTOP=Niri" + "XDG_SESSION_TYPE=wayland" + ]; + hyprland = [ + "XDG_CURRENT_DESKTOP=Hyprland" + "XDG_SESSION_DESKTOP=Hyprland" + "XDG_SESSION_TYPE=wayland" + ]; + }; + + defaultEnv = config: { + all = { + GTK_CSD = "0"; + TERM = "kitty /bin/fish"; + HYPRCURSOR_THEME = config.mods.stylix.cursor.name; + HYPRCURSOR_SIZE = toString config.mods.stylix.cursor.size; + XCURSOR_THEME = config.mods.stylix.cursor.name; + XCURSOR_SIZE = toString config.mods.stylix.cursor.size; + QT_QPA_PLATFORM = "wayland"; + QT_QPA_PLATFORMTHEME = "qt5ct"; + QT_WAYLAND_FORCE_DPI = "96"; + QT_AUTO_SCREEN_SCALE_FACTOR = "0"; + QT_WAYLAND_DISABLE_WINDOWDECORATION = "1"; + QT_SCALE_FACTOR = "1"; + EDITOR = "neovide --novsync --nofork"; + + LIBVA_DRIVER_NAME = + if config.mods.gpu.nvidia.enable + then "nvidia" + else ""; + GBM_BACKEND = + if config.mods.gpu.nvidia.enable + then "nvidia-drm" + else ""; + __GLX_VENDOR_LIBRARY_NAME = + if config.mods.gpu.nvidia.enable + then "nvidia" + else ""; + }; + niri = {}; + hyprland = {}; + }; + + defaultBinds = config: [ + (mkSimpleBind ["Mod"] "1" "focusWorkspace" ["1"]) + (mkSimpleBind ["Mod"] "2" "focusWorkspace" ["2"]) + (mkSimpleBind ["Mod"] "3" "focusWorkspace" ["3"]) + (mkSimpleBind ["Mod"] "4" "focusWorkspace" ["4"]) + (mkSimpleBind ["Mod"] "5" "focusWorkspace" ["5"]) + (mkSimpleBind ["Mod"] "6" "focusWorkspace" ["6"]) + (mkSimpleBind ["Mod"] "7" "focusWorkspace" ["7"]) + (mkSimpleBind ["Mod"] "8" "focusWorkspace" ["8"]) + (mkSimpleBind ["Mod"] "9" "focusWorkspace" ["9"]) + (mkSimpleBind ["Mod"] "0" "focusWorkspace" ["0"]) + (mkSimpleBind ["Mod" "Shift"] "1" "moveToWorkspace" ["1"]) + (mkSimpleBind ["Mod" "Shift"] "2" "moveToWorkspace" ["2"]) + (mkSimpleBind ["Mod" "Shift"] "3" "moveToWorkspace" ["3"]) + (mkSimpleBind ["Mod" "Shift"] "4" "moveToWorkspace" ["4"]) + (mkSimpleBind ["Mod" "Shift"] "5" "moveToWorkspace" ["5"]) + (mkSimpleBind ["Mod" "Shift"] "6" "moveToWorkspace" ["6"]) + (mkSimpleBind ["Mod" "Shift"] "7" "moveToWorkspace" ["7"]) + (mkSimpleBind ["Mod" "Shift"] "8" "moveToWorkspace" ["8"]) + (mkSimpleBind ["Mod" "Shift"] "9" "moveToWorkspace" ["9"]) + (mkSimpleBind ["Mod" "Shift"] "0" "moveToWorkspace" ["0"]) + (mkSimpleBind ["Mod"] "B" "toggleFullscreen" []) + (mkSimpleBind ["Mod"] "V" "toggleFloating" []) + (mkSimpleBind ["Mod" "Shift"] "M" "quit" []) + (mkSimpleBind ["Mod"] "Left" "moveWindowLeft" []) + (mkSimpleBind ["Mod"] "Down" "moveWindowDown" []) + (mkSimpleBind ["Mod"] "Up" "moveWindowUp" []) + (mkSimpleBind ["Mod"] "Right" "moveWindowRight" []) + + (mkRepeatSimpleBind ["Mod"] "J" "moveFocusLeft" []) + (mkRepeatSimpleBind ["Mod"] "K" "moveFocusDown" []) + (mkRepeatSimpleBind ["Mod"] "L" "moveFocusUp" []) + (mkRepeatSimpleBind ["Mod"] "semicolon" "moveFocusRight" []) + + (mkBindWithDesc ["Mod"] "Q" "killActive" [] "Kill active window") + + (mkBindWithDesc ["Mod"] "N" "spawn" ["neovide"] "Open Neovide") + (mkBindWithDesc ["Mod"] "T" "spawn-sh" ["kitty" "-1"] "Open Kitty") + (mkBindWithDesc ["Mod" "Shift"] "L" "spawn" ["hyprlock"] "Lock screen") + + ( + if config.mods.yazi.enable + then mkBindWithDesc ["Mod"] "E" "spawn-sh" ["EDITOR='neovide --no-fork' kitty yazi"] "Open Yazi" + else {} + ) + ( + if config.mods.anyrun.enable + then mkBindWithDesc ["Mod"] "R" "spawn" ["anyrun"] "Open Anyrun" + else {} + ) + ( + if config.mods.oxi.oxirun.enable + then mkBindWithDesc ["Mod"] "R" "spawn" ["oxirun"] "Open OxiRun" + else {} + ) + ( + if config.mods.oxi.oxidash.enable + then mkBindWithDesc ["Mod"] "M" "spawn" ["oxidash"] "Open OxiDash" + else {} + ) + ( + if config.mods.oxi.oxicalc.enable + then mkBindWithDesc ["Mod"] "G" "spawn" ["oxicalc"] "Open Oxicalc" + else {} + ) + ( + if config.mods.oxi.oxishut.enable + then mkBindWithDesc ["Mod"] "D" "spawn" ["oxishut"] "Open OxiShut" + else {} + ) + ( + if config.mods.oxi.oxipaste.enable + then mkBindWithDesc ["Mod"] "A" "spawn" ["oxipaste"] "Open Oxipaste" + else {} + ) + ( + if config.mods.oxi.hyprdock.enable + then mkBindWithDesc ["Mod" "Shift"] "P" "spawn" ["hyprdock --gui"] "Open Hyprdock" + else {} + ) + ( + if config.mods.hypr.hyprlock.enable + then mkBindWithDesc ["Mod" "Shift" "Alt"] "L" "spawn-sh" ["playerctl -a pause & hyprlock & systemctl suspend"] "Lock and suspend" + else {} + ) + ( + if config.mods.hypr.hyprlock.enable + then mkBindWithDesc ["Mod" "Shift" "Alt"] "K" "spawn-sh" ["playerctl -a pause & hyprlock & systemctl hibernate"] "Lock and hibernate" + else {} + ) + + (mkBindWithDesc ["Mod"] "F" "spawn" ["${browserName config}"] "Open Browser") + ( + if + ( + browserName config == "firefox" || browserName config == "zen" + ) + then mkBindWithDesc ["Mod" "Shift"] "F" "spawn" ["${browserName config} -p special"] "Open Browser Special Profile" + else {} + ) + + (mkBindWithDesc ["Mod"] "S" "spawn-sh" [''grim -g \"$(slurp)\" - | wl-copy''] "Take Screenshot") + (mkBindWithDesc ["Mod" "Shift"] "S" "spawn-sh" [''grim -g \"$(slurp)\" - | satty -f -''] "Take Screenshot and edit") + + ( + if config.mods.scripts.audioControl + then { + key = "XF86AudioMute"; + command = "spawn-sh"; + args = ["audioControl mute"]; + meta.niri = { + allowWhileLocked = true; + desc = "Mute Audio"; + }; + } + else {} + ) + ( + if config.mods.scripts.audioControl + then { + key = "XF86AudioRaiseVolume"; + command = "spawn-sh"; + args = ["audioControl +5%"]; + meta.niri = { + allowWhileLocked = true; + desc = "Raise Audio Volume"; + }; + } + else {} + ) + ( + if config.mods.scripts.audioControl + then { + key = "XF86AudioLowerVolume"; + command = "spawn-sh"; + args = ["audioControl -5%"]; + meta.niri = { + allowWhileLocked = true; + desc = "Lower Audio Volume"; + }; + } + else {} + ) + { + key = "XF86AudioPlay"; + command = "spawn-sh"; + args = ["playerctl play-pause"]; + meta.niri = { + allowWhileLocked = true; + desc = "Play/Pause"; + }; + } + { + key = "XF86AudioNext"; + command = "spawn-sh"; + args = ["playerctl next"]; + meta.niri = { + allowWhileLocked = true; + desc = "Next Song"; + }; + } + { + key = "XF86AudioPrev"; + command = "spawn-sh"; + args = ["playerctl previous"]; + meta.niri = { + allowWhileLocked = true; + desc = "Previous Song"; + }; + } + ( + if config.mods.scripts.changeBrightness + then { + key = "XF86MonBrightnessDown"; + command = "spawn-sh"; + args = ["changeBrightness -10%"]; + meta.niri = { + allowWhileLocked = true; + desc = "Lower Brigthness"; + }; + } + else {} + ) + ( + if config.mods.scripts.changeBrightness + then { + key = "XF86MonBrightnessUp"; + command = "spawn-sh"; + args = ["changeBrightness +10%"]; + meta.niri = { + allowWhileLocked = true; + desc = "Raise Brigthness"; + }; + } + else {} + ) + + # Niri only keybinds + (mkSimpleCustomBind ["Mod"] "BracketLeft" "consume-or-expel-window-left" null []) + (mkSimpleCustomBind ["Mod"] "BracketRight" "consume-or-expel-window-right" null []) + (mkSimpleCustomBind ["Mod"] "Comma" "consume-window-into-column" null []) + (mkSimpleCustomBind ["Mod"] "Period" "expel-window-from-column" null []) + (mkSimpleCustomBind ["Mod"] "Y" "switch-preset-column-width" null []) + (mkSimpleCustomBind ["Mod"] "Tab" "focus-workspace-previous" null []) + (mkSimpleCustomBind ["Mod" "Shift"] "V" "switch-focus-between-floating-and-tiling" null []) + (mkSimpleCustomBind ["Mod" "Shift"] "B" "expand-column-to-available-width" null []) + (mkSimpleCustomBind ["Mod"] "U" "set-column-width" null ["-10%"]) + (mkSimpleCustomBind ["Mod"] "P" "set-column-width" null ["+10%"]) + (mkSimpleCustomBind ["Mod"] "O" "set-column-width" null ["50%"]) + (mkSimpleCustomBind ["Mod" "Shift"] "Minus" "set-window-height" null ["-10%"]) + (mkSimpleCustomBind ["Mod" "Shift"] "Equal" "set-window-height" null ["+10%"]) + (mkSimpleCustomBind ["Mod" "Ctrl"] "1" "move-column-to-workspace" null ["1"]) + (mkSimpleCustomBind ["Mod" "Ctrl"] "2" "move-column-to-workspace" null ["2"]) + (mkSimpleCustomBind ["Mod" "Ctrl"] "3" "move-column-to-workspace" null ["3"]) + (mkSimpleCustomBind ["Mod" "Ctrl"] "4" "move-column-to-workspace" null ["4"]) + (mkSimpleCustomBind ["Mod" "Ctrl"] "5" "move-column-to-workspace" null ["5"]) + (mkSimpleCustomBind ["Mod" "Ctrl"] "6" "move-column-to-workspace" null ["6"]) + (mkSimpleCustomBind ["Mod" "Ctrl"] "7" "move-column-to-workspace" null ["7"]) + (mkSimpleCustomBind ["Mod" "Ctrl"] "8" "move-column-to-workspace" null ["8"]) + (mkSimpleCustomBind ["Mod" "Ctrl"] "9" "move-column-to-workspace" null ["9"]) + (mkSimpleCustomBind ["Mod" "Ctrl"] "0" "move-column-to-workspace" null ["0"]) + (mkSimpleCustomBind ["Mod" "Shift"] "J" "focus-monitor-left" null []) + (mkSimpleCustomBind ["Mod" "Shift"] "semicolon" "focus-monitor-right" null []) + (mkSimpleCustomBind ["Mod" "Ctrl"] "J" "move-column-to-monitor-left" null []) + (mkSimpleCustomBind ["Mod" "Ctrl"] "semicolon" "move-column-to-monitor-right" null []) + (mkSimpleCustomBind ["Mod" "Shift"] "Slash" "show-hotkey-overlay" null []) + { + modKeys = ["Mod"]; + key = "W"; + command.niri = "toggle-overview"; + meta.niri = { + desc = "Overview"; + repeat = false; + }; + } + { + modKeys = ["Mod"]; + key = "Escape"; + command.niri = "toggle-keyboard-shortcuts-inhibit"; + meta.niri = { + allowInhibit = false; + }; + } + { + modKeys = ["Mod"]; + key = "WheelScrollUp"; + command.niri = "focus-workspace-up"; + meta.niri.cooldown = 150; + } + { + modKeys = ["Mod"]; + key = "WheelScrollDown"; + command.niri = "focus-workspace-down"; + meta.niri.cooldown = 150; + } + { + modKeys = ["Mod"]; + key = "WheelScrollRight"; + command.niri = "focus-column-right"; + meta.niri.cooldown = 150; + } + { + modKeys = ["Mod"]; + key = "WheelScrollLeft"; + command.niri = "focus-column-left"; + meta.niri.cooldown = 150; + } + + # Hyprland only keybinds + (mkSimpleCustomBind ["Mod"] "C" null "togglesplit" []) + (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "1" null "movetoworkspacesilent" ["1"]) + (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "2" null "movetoworkspacesilent" ["2"]) + (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "3" null "movetoworkspacesilent" ["3"]) + (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "4" null "movetoworkspacesilent" ["4"]) + (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "5" null "movetoworkspacesilent" ["5"]) + (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "6" null "movetoworkspacesilent" ["6"]) + (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "7" null "movetoworkspacesilent" ["7"]) + (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "8" null "movetoworkspacesilent" ["8"]) + (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "9" null "movetoworkspacesilent" ["9"]) + (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "0" null "movetoworkspacesilent" ["0"]) + (mkRepeatCustomBind ["Mod"] "U" null "resizeactive" ["-20" "0"]) + (mkRepeatCustomBind ["Mod"] "P" null "resizeactive" ["20" "0"]) + (mkRepeatCustomBind ["Mod"] "O" null "resizeactive" ["0" "-20"]) + (mkRepeatCustomBind ["Mod"] "I" null "resizeactive" ["0" "20"]) + (mkSimpleCustomBind ["Mod" "ALT"] "J" null "layoutmsg" ["preselect" "l"]) + (mkSimpleCustomBind ["Mod" "ALT"] "K" null "layoutmsg" ["preselect" "d"]) + (mkSimpleCustomBind ["Mod" "ALT"] "L" null "layoutmsg" ["preselect" "u"]) + (mkSimpleCustomBind ["Mod" "ALT"] "semicolon" null "layoutmsg" ["preselect" "r"]) + (mkSimpleCustomBind ["Mod" "ALT"] "H" null "layoutmsg" ["preselect" "n"]) + ( + if config.mods.hypr.hyprland.hyprspaceEnable + then { + modKeys = ["Mod"]; + key = "W"; + command.hyprland = "overview:toggle"; + args = []; + } + else {} + ) + ]; +} diff --git a/modules/programs/default.nix b/modules/programs/default.nix index ebc1ff4..1c0baa5 100644 --- a/modules/programs/default.nix +++ b/modules/programs/default.nix @@ -1,5 +1,6 @@ { imports = [ + ./niri.nix ./acpid.nix ./anyrun.nix ./basePackages.nix @@ -48,6 +49,7 @@ ./virtmanager.nix ./xkb.nix ./xone.nix + ./wm.nix ./yazi ]; } diff --git a/modules/programs/fastfetch.nix b/modules/programs/fastfetch.nix index f73b2cd..9953d84 100644 --- a/modules/programs/fastfetch.nix +++ b/modules/programs/fastfetch.nix @@ -1,5 +1,4 @@ { - mkDashDefault, pkgs, lib, options, diff --git a/modules/programs/fish.nix b/modules/programs/fish.nix index 2f18036..f063f35 100644 --- a/modules/programs/fish.nix +++ b/modules/programs/fish.nix @@ -56,6 +56,7 @@ in { abbr --add ls 'lsd' abbr --add :q 'exit' abbr --add gh 'git push origin' + abbr --add gu 'git push upstream' abbr --add gl 'git pull origin' abbr --add gm 'git commit -m' abbr --add ga "git add -A" diff --git a/modules/programs/greetd.nix b/modules/programs/greetd.nix index 22954a1..2c5f87f 100644 --- a/modules/programs/greetd.nix +++ b/modules/programs/greetd.nix @@ -18,7 +18,10 @@ ''; }; monitor = lib.mkOption { - default = "${config.mods.hypr.hyprland.defaultMonitor}"; + default = + if config.mods.wm.monitors != [] + then (builtins.elemAt config.mods.wm.monitors 0).name + else ""; example = "eDP-1"; type = lib.types.str; description = '' @@ -27,7 +30,10 @@ ''; }; scale = lib.mkOption { - default = "${config.mods.hypr.hyprland.defaultMonitorScale}"; + default = + if config.mods.wm.monitors != [] + then builtins.toString (builtins.elemAt config.mods.wm.monitors 0).scale + else ""; example = "1.5"; type = lib.types.str; description = '' @@ -46,7 +52,14 @@ description = "The compositor/greeter command to run"; }; resolution = lib.mkOption { - default = "${config.mods.hypr.hyprland.defaultMonitorMode}"; + default = + if config.mods.wm.monitors != [] + then let + resX = builtins.toString (builtins.elemAt config.mods.wm.monitors 0).resolutionX; + resY = builtins.toString (builtins.elemAt config.mods.wm.monitors 0).resolutionY; + refresh = builtins.toString (builtins.elemAt config.mods.wm.monitors 0).refreshrate; + in "${resX}x${resY}@${refresh}" + else ""; example = "3440x1440@180"; type = lib.types.str; description = '' @@ -55,7 +68,8 @@ }; environments = lib.mkOption { default = [ - inputs.hyprland.packages.${config.conf.system}.hyprland + (lib.mkIf config.mods.hypr.hyprland.enable inputs.hyprland.packages.${config.conf.system}.hyprland) + (lib.mkIf config.mods.niri.enable pkgs.niri) ]; # no idea if these are written correctly example = [ @@ -82,7 +96,7 @@ }; config = let - username = config.conf.username; + inherit (config.conf) username; in lib.mkIf config.mods.greetd.enable ( lib.optionalAttrs (options ? environment) { diff --git a/modules/programs/hypr/hyprland.nix b/modules/programs/hypr/hyprland.nix index 111e10b..f6ee377 100644 --- a/modules/programs/hypr/hyprland.nix +++ b/modules/programs/hypr/hyprland.nix @@ -6,12 +6,7 @@ pkgs, ... }: let - browserName = - if (builtins.isString config.mods.homePackages.browser) - then config.mods.homePackages.browser - else if config.mods.homePackages.browser ? meta && config.mods.homePackages.browser.meta ? mainProgram - then config.mods.homePackages.browser.meta.mainProgram - else config.mods.homePackages.browser.pname; + defaultWmConf = import ../../../lib/wm.nix {inherit lib;}; in { options.mods.hypr.hyprland = { enable = lib.mkOption { @@ -22,64 +17,12 @@ in { Enable Hyprland ''; }; - defaultMonitor = lib.mkOption { - default = ""; - example = "eDP-1"; - type = lib.types.str; - description = '' - main monitor - ''; - }; - defaultMonitorMode = lib.mkOption { - default = ""; - example = "3440x1440@180"; - type = lib.types.str; - description = '' - main monitor mode: width x height @ refreshrate - ''; - }; - defaultMonitorScale = lib.mkOption { - default = "1"; - example = "1.5"; - type = lib.types.str; - description = '' - main monitor scaling - ''; - }; - monitor = lib.mkOption { - default = [ - # main monitor - "${config.mods.hypr.hyprland.defaultMonitor},${config.mods.hypr.hyprland.defaultMonitorMode},0x0,${config.mods.hypr.hyprland.defaultMonitorScale}" - # all others - ]; - example = ["DP-1,3440x1440@180,2560x0,1,vrr,0"]; - type = with lib.types; listOf str; - description = '' - The monitor configuration for hyprland. - ''; - }; - workspace = lib.mkOption { - default = []; - example = ["2,monitor:DP-1, default:true"]; - type = with lib.types; listOf str; - description = '' - The workspace configuration for hyprland. - ''; - }; noAtomic = lib.mkOption { default = false; example = true; type = lib.types.bool; description = '' - Use tearing - ''; - }; - extraAutostart = lib.mkOption { - default = []; - example = ["your application"]; - type = lib.types.listOf lib.types.str; - description = '' - Extra exec_once. + Use tearing (Warning, can be buggy) ''; }; useIronbar = lib.mkOption { @@ -90,14 +33,6 @@ in { Whether to use ironbar in hyprland. ''; }; - ironbarSingleMonitor = lib.mkOption { - default = true; - example = false; - type = lib.types.bool; - description = '' - Whether to use ironbar on a single monitor. - ''; - }; useDefaultConfig = lib.mkOption { default = true; example = false; @@ -160,7 +95,151 @@ in { hyprpicker ]; - wayland.windowManager.hyprland = { + wayland.windowManager.hyprland = let + mkWorkspace = workspaces: + builtins.map (workspace: let + default = + if workspace.default + then ",default:true" + else ""; + in "${workspace.name},monitor:${workspace.monitor}${default}") + workspaces; + mkTransform = transform: + if transform == "0" + then 0 + else if transform == "90" + then 1 + else if transform == "180" + then 2 + else if transform == "270" + then 3 + else 4; + mkVrr = vrr: + if vrr + then "1" + else "0"; + mkMonitors = monitors: + builtins.map ( + monitor: "${monitor.name},${builtins.toString monitor.resolutionX}x${builtins.toString monitor.resolutionY}@${builtins.toString monitor.refreshrate},${builtins.toString monitor.positionX}x${builtins.toString monitor.positionY},${builtins.toString monitor.scale}, transform,${builtins.toString (mkTransform monitor.transform)}, vrr,${mkVrr monitor.vrr}" + ) + monitors; + + mkMods = bind: let + mods = bind.modKeys or []; + in + builtins.map (mod: + if mod == "Mod" + then (lib.strings.toUpper config.mods.wm.modKey) + " " + else lib.strings.toUpper mod) + mods + |> lib.strings.concatStringsSep ""; + mkArgs = args: + if args != [] + then (lib.strings.concatStringsSep " " args) + else ""; + shouldRepeat = bind: bind ? meta && bind.meta ? hyprland && bind.meta.hyprland ? repeat && bind.meta.hyprland.repeat; + + defaultBinds = cfg: + if cfg.mods.wm.useDefaultBinds + then defaultWmConf.defaultBinds cfg + else []; + + mkEBinds = cfg: let + binds = cfg.mods.wm.binds ++ defaultBinds cfg; + in + binds + |> builtins.filter (bind: bind ? command && shouldRepeat bind && !hasInvalidCustomCommand bind) + |> builtins.map ( + bind: "${mkMods bind},${bind.key},${mkCommand bind}" + ); + mkBinds = cfg: let + binds = cfg.mods.wm.binds ++ defaultBinds cfg; + in + binds + |> builtins.filter (bind: bind ? command && !(shouldRepeat bind) && !hasInvalidCustomCommand bind) + |> builtins.map ( + bind: "${mkMods bind},${bind.key},${mkCommand bind}" + ); + mkCommand = bind: let + args = bind.args or []; + in + if bind.command == "quit" + then "exit" + else if bind.command == "killActive" + then "killactive" + else if bind.command == "moveWindowRight" + then "movewindow,r" + else if bind.command == "moveWindowDown" + then "movewindow,d" + else if bind.command == "moveWindowLeft" + then "movewindow,l" + else if bind.command == "moveWindowUp" + then "movewindow,u" + else if bind.command == "moveFocusUp" + then "movefocus,u" + else if bind.command == "moveFocusRight" + then "movefocus,r" + else if bind.command == "moveFocusDown" + then "movefocus,d" + else if bind.command == "moveFocusLeft" + then "movefocus,l" + else if bind.command == "toggleFloating" + then "togglefloating" + else if bind.command == "toggleFullscreen" + then "fullscreen" + else if bind.command == "focusWorkspace" + then "workspace" + "," + mkArgs args + else if bind.command == "moveToWorkspace" + then "movetoworkspace" + "," + mkArgs args + else if bind.command == "spawn" + then "exec" + "," + mkArgs args + else if bind.command == "spawn-sh" + then "exec" + "," + mkArgs args + else bind.command.hyprland + "," + mkArgs args; + hasInvalidCustomCommand = bind: !(builtins.isString bind.command) && bind.command.hyprland or null == null; + + mkEnv = config: let + defaultEnv = + if config.mods.wm.useDefaultEnv + then defaultWmConf.defaultEnv config + else { + all = {}; + hyprland = {}; + }; + userEnv = + if config.mods.wm.env ? all + then config.mods.wm.env.all // config.mods.wm.env.hyprland + else config.mods.wm.env; + env = userEnv // defaultEnv.all // defaultEnv.hyprland; + in + lib.attrsets.mapAttrsToList ( + name: value: "${name},${value}" + ) + env; + mkAutoStart = config: let + defaultStartup = + if config.mods.wm.useDefaultStartup + then defaultWmConf.defaultStartup config + else { + all = []; + hyprland = []; + }; + userStartup = + if config.mods.wm.startup ? all + then config.mods.wm.startup.all ++ config.mods.wm.startup.hyprland + else config.mods.wm.startup; + autoStart = userStartup ++ defaultStartup.all ++ defaultStartup.hyprland; + in + autoStart; + mkWindowRule = config: let + defaultWindowRules = + if config.mods.wm.useDefaultWindowRules + then defaultWmConf.defaultWindowRules.hyprland + else []; + in + # defaultWindowRules ++ config.mods.wm.windowRules.hyprland; + defaultWindowRules; + in { enable = true; package = mkDashDefault pkgs.hyprland; plugins = @@ -174,124 +253,13 @@ in { lib.mkMerge [ { - "$mod" = mkDashDefault "SUPER"; + "$mod" = mkDashDefault config.mods.wm.modKey; bindm = [ "$mod, mouse:272, movewindow" "$mod, mouse:273, resizeactive" ]; - bind = [ - # screenshots - ''$mod SUPER,S,exec,grim -g "$(slurp)" - | wl-copy'' - ''$mod SUPERSHIFT,S,exec,grim -g "$(slurp)" - | satty -f -'' - - # regular programs - "$mod SUPER,F,exec,${browserName}" - (lib.mkIf ( - browserName == "firefox" || browserName == "zen" - ) "$mod SUPERSHIFT,F,exec,${browserName} -p special") - "$mod SUPER,T,exec,kitty -1" - "$mod SUPER,E,exec,nautilus -w" - (lib.mkIf config.mods.yazi.enable "$mod SUPER,Y,exec, EDITOR='neovide --no-fork' kitty yazi") - "$mod SUPER,N,exec,neovide" - (lib.mkIf config.mods.anyrun.enable "$mod SUPER,R,exec,anyrun") - (lib.mkIf config.mods.oxi.oxirun.enable "$mod SUPER,R,exec,oxirun") - (lib.mkIf config.mods.oxi.oxidash.enable "$mod SUPER,M,exec,oxidash") - (lib.mkIf config.mods.oxi.oxicalc.enable "$mod SUPER,G,exec,oxicalc") - (lib.mkIf config.mods.oxi.oxishut.enable "$mod SUPER,D,exec,oxishut") - (lib.mkIf config.mods.oxi.oxipaste.enable "$mod SUPER,A,exec,oxipaste") - (lib.mkIf config.mods.oxi.hyprdock.enable "$mod SUPERSHIFT,P,exec,hyprdock --gui") - (lib.mkIf config.mods.hypr.hyprlock.enable "$mod SUPERSHIFT,L,exec, playerctl -a pause & hyprlock & systemctl suspend") - (lib.mkIf config.mods.hypr.hyprlock.enable "$mod SUPERSHIFT,K,exec, playerctl -a pause & hyprlock & systemctl hibernate") - - # media keys - (lib.mkIf config.mods.scripts.audioControl ",XF86AudioMute,exec, audioControl mute") - (lib.mkIf config.mods.scripts.audioControl ",XF86AudioLowerVolume,exec, audioControl sink -5%") - (lib.mkIf config.mods.scripts.audioControl ",XF86AudioRaiseVolume,exec, audioControl sink +5%") - ",XF86AudioPlay,exec, playerctl play-pause" - ",XF86AudioNext,exec, playerctl next" - ",XF86AudioPrev,exec, playerctl previous" - (lib.mkIf config.mods.scripts.changeBrightness ",XF86MonBrightnessDown,exec, changeBrightness 10%-") - (lib.mkIf config.mods.scripts.changeBrightness ",XF86MonBrightnessUp,exec, changeBrightness +10%") - - # hyprland keybinds - # misc - "$mod SUPER,V,togglefloating," - "$mod SUPER,B,fullscreen," - "$mod SUPER,C,togglesplit" - "$mod SUPER,Q,killactive," - "$mod SUPERSHIFTALT,M,exit," - "$mod SUPERSHIFT,W,togglespecialworkspace" - - # move - "$mod SUPER,left,movewindow,l" - "$mod SUPER,right,movewindow,r" - "$mod SUPER,up,movewindow,u" - "$mod SUPER,down,movewindow,d" - - # workspaces - "$mod SUPER,1,workspace,1" - "$mod SUPER,2,workspace,2" - "$mod SUPER,3,workspace,3" - "$mod SUPER,4,workspace,4" - "$mod SUPER,5,workspace,5" - "$mod SUPER,6,workspace,6" - "$mod SUPER,7,workspace,7" - "$mod SUPER,8,workspace,8" - "$mod SUPER,9,workspace,9" - "$mod SUPER,0,workspace,10" - - # move to workspace - "$mod SUPERSHIFT,1,movetoworkspace,1" - "$mod SUPERSHIFT,2,movetoworkspace,2" - "$mod SUPERSHIFT,3,movetoworkspace,3" - "$mod SUPERSHIFT,4,movetoworkspace,4" - "$mod SUPERSHIFT,5,movetoworkspace,5" - "$mod SUPERSHIFT,6,movetoworkspace,6" - "$mod SUPERSHIFT,7,movetoworkspace,7" - "$mod SUPERSHIFT,8,movetoworkspace,8" - "$mod SUPERSHIFT,9,movetoworkspace,9" - "$mod SUPERSHIFT,0,movetoworkspace,10" - - # move to workspace silent - "$mod SUPERSHIFTALT,1,movetoworkspacesilent,1" - "$mod SUPERSHIFTALT,2,movetoworkspacesilent,2" - "$mod SUPERSHIFTALT,3,movetoworkspacesilent,3" - "$mod SUPERSHIFTALT,4,movetoworkspacesilent,4" - "$mod SUPERSHIFTALT,5,movetoworkspacesilent,5" - "$mod SUPERSHIFTALT,6,movetoworkspacesilent,6" - "$mod SUPERSHIFTALT,7,movetoworkspacesilent,7" - "$mod SUPERSHIFTALT,8,movetoworkspacesilent,8" - "$mod SUPERSHIFTALT,9,movetoworkspacesilent,9" - "$mod SUPERSHIFTALT,0,movetoworkspacesilent,10" - - # preselection - "$mod SUPERALT,j,layoutmsg,preselect l" - "$mod SUPERALT,k,layoutmsg,preselect d" - "$mod SUPERALT,l,layoutmsg,preselect u" - "$mod SUPERALT,semicolon,layoutmsg,preselect r" - "$mod SUPERALT,h,layoutmsg,preselect n" - ]; - - binde = [ - # hyprland keybinds - # focus - "$mod SUPER,J,movefocus,l" - "$mod SUPER,semicolon,movefocus,r" - "$mod SUPER,L,movefocus,u" - "$mod SUPER,K,movefocus,d" - - # resize - "$mod SUPER,U,resizeactive,-20 0" - "$mod SUPER,P,resizeactive,20 0" - "$mod SUPER,O,resizeactive,0 -20" - "$mod SUPER,I,resizeactive,0 20" - - (lib.mkIf config.mods.hypr.hyprland.hyprspaceEnable - "SUPER, W, overview:toggle") - ]; - general = { gaps_out = mkDashDefault "3,5,5,5"; border_size = mkDashDefault 3; @@ -364,70 +332,19 @@ in { "3, horizontal, workspace" ]; - monitor = mkDashDefault config.mods.hypr.hyprland.monitor; - workspace = mkDashDefault config.mods.hypr.hyprland.workspace; - - env = [ - "GTK_CSD,0" - ''TERM,"kitty /bin/fish"'' - "XDG_CURRENT_DESKTOP=Hyprland" - "XDG_SESSION_TYPE=wayland" - "XDG_SESSION_DESKTOP=Hyprland" - "HYPRCURSOR_THEME,${config.mods.stylix.cursor.name}" - "HYPRCURSOR_SIZE,${toString config.mods.stylix.cursor.size}" - "XCURSOR_THEME,${config.mods.stylix.cursor.name}" - "XCURSOR_SIZE,${toString config.mods.stylix.cursor.size}" - "QT_QPA_PLATFORM,wayland" - "QT_QPA_PLATFORMTHEME,qt5ct" - "QT_WAYLAND_FORCE_DPI,96" - "QT_AUTO_SCREEN_SCALE_FACTOR,0" - "QT_WAYLAND_DISABLE_WINDOWDECORATION,1" - "QT_SCALE_FACTOR,1" - ''EDITOR,"neovide --novsync --nofork"'' - - (lib.mkIf config.mods.gpu.nvidia.enable "LIBVA_DRIVER_NAME,nvidia") - (lib.mkIf config.mods.gpu.nvidia.enable "XDG_SESSION_TYPE,wayland") - (lib.mkIf config.mods.gpu.nvidia.enable "GBM_BACKEND,nvidia-drm") - (lib.mkIf config.mods.gpu.nvidia.enable "__GLX_VENDOR_LIBRARY_NAME,nvidia") - ]; - layerrule = [ # layer rules # mainly to disable animations within slurp and grim "noanim, selection" ]; - windowrule = [ - # window rules - "float,class:^(.*)(OxiCalc)(.*)$" - "float,class:^(.*)(winecfg.exe)(.*)$" - "float,class:^(.*)(copyq)(.*)$" - "center,class:^(.*)(swappy)(.*)$" - "workspace 10 silent,class:^(.*)(steam)(.*)$" - - # Otherwise neovide will ignore tiling - "suppressevent fullscreen maximize,class:^(.*)(neovide)(.*)$" - ]; - - exec-once = - [ - # environment - "systemctl --user import-environment" - "dbus-update-activation-environment --systemd --all" - "hyprctl setcursor ${config.mods.stylix.cursor.name} ${toString config.mods.stylix.cursor.size}" - # ensures the systemd service knows what "hyprctl" is :) - (lib.mkIf config.mods.gaming.gamemode "systemctl try-restart gamemoded.service --user") - - # other programs - "${browserName}" - (lib.mkIf config.mods.oxi.hyprdock.enable "hyprdock --server") - (lib.mkIf config.mods.hypr.hyprpaper.enable "hyprpaper") - (lib.mkIf config.mods.hypr.hyprland.useIronbar "ironbar") - (lib.mkIf config.mods.oxi.oxipaste.enable "oxipaste_daemon") - (lib.mkIf config.mods.oxi.oxinoti.enable "oxinoti") - ] - ++ config.mods.hypr.hyprland.extraAutostart; - + workspace = mkDashDefault (mkWorkspace config.mods.wm.workspaces); + monitor = mkDashDefault (mkMonitors config.mods.wm.monitors); + env = mkDashDefault (mkEnv config); + bind = mkDashDefault (mkBinds config); + binde = mkDashDefault (mkEBinds config); + windowrule = mkDashDefault (mkWindowRule config); + exec-once = mkDashDefault (mkAutoStart config); plugin = config.mods.hypr.hyprland.pluginConfig; } config.mods.hypr.hyprland.customConfig diff --git a/modules/programs/hypr/hyprlock.nix b/modules/programs/hypr/hyprlock.nix index 30ea707..c152b22 100644 --- a/modules/programs/hypr/hyprlock.nix +++ b/modules/programs/hypr/hyprlock.nix @@ -24,14 +24,22 @@ input-field = [ { - monitor = "${config.mods.hypr.hyprland.defaultMonitor}"; + monitor = "${ + if config.mods.wm.monitors != [] + then (builtins.elemAt config.mods.wm.monitors 0).name + else "" + }"; placeholder_text = "password or something"; } ]; label = [ { - monitor = "${config.mods.hypr.hyprland.defaultMonitor}"; + monitor = "${ + if config.mods.wm.monitors != [] + then (builtins.elemAt config.mods.wm.monitors 0).name + else "" + }"; text = "$TIME"; font_size = 50; position = "0, 200"; diff --git a/modules/programs/ironbar.nix b/modules/programs/ironbar.nix index 9a4bac4..5757347 100644 --- a/modules/programs/ironbar.nix +++ b/modules/programs/ironbar.nix @@ -1,5 +1,4 @@ { - mkDashDefault, lib, config, pkgs, @@ -7,7 +6,7 @@ options, ... }: let - username = config.conf.username; + inherit (config.conf) username; base16 = pkgs.callPackage inputs.base16.lib {}; scheme = base16.mkSchemeAttrs config.stylix.base16Scheme; ironbarDefaultConfig = useBatteryModule: { @@ -183,8 +182,15 @@ ]; }; monitorConfig = useBatteryModule: - if config.mods.hypr.hyprland.ironbarSingleMonitor - then {monitors.${config.mods.hypr.hyprland.defaultMonitor} = ironbarDefaultConfig useBatteryModule;} + if config.mods.ironbar.ironbarSingleMonitor + then { + monitors.${ + if config.mods.wm.monitors != [] + then (builtins.elemAt config.mods.wm.monitors 0).name + else "" + } = + ironbarDefaultConfig useBatteryModule; + } else ironbarDefaultConfig useBatteryModule; in { options.mods = { @@ -195,6 +201,14 @@ in { type = lib.types.bool; description = "Enables ironbar"; }; + ironbarSingleMonitor = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = '' + Whether to use ironbar on a single monitor. + ''; + }; useDefaultConfig = lib.mkOption { default = true; example = false; @@ -257,6 +271,7 @@ in { @import url("/home/${username}/.config/gtk-3.0/gtk.css"); @define-color primary #${scheme.base0D}; + @define-color warning #${scheme.base0F}; @define-color muted-text #${scheme.base05}; @define-color background #${scheme.base00}; @define-color secondary-background #${scheme.base02}; @@ -406,6 +421,10 @@ in { color: @primary; } + .workspaces .item:not(.visible) { + color: @warning; + } + .workspaces .item.focused { background-color: @primary; color: @background; diff --git a/modules/programs/niri.nix b/modules/programs/niri.nix new file mode 100644 index 0000000..cf39776 --- /dev/null +++ b/modules/programs/niri.nix @@ -0,0 +1,379 @@ +{ + mkDashDefault, + config, + lib, + options, + pkgs, + ... +}: let + defaultWmConf = import ../../lib/wm.nix {inherit lib;}; +in { + options.mods.niri = { + enable = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = '' + Enable Niri + ''; + }; + useDefaultConfig = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = '' + Use preconfigured Niri config. + ''; + }; + customConfig = lib.mkOption { + default = ''''; + example = ''''; + type = lib.types.lines; + description = '' + Custom Niri configuration. + Will be merged with default configuration if enabled. + ''; + }; + }; + + config = lib.mkIf config.mods.niri.enable ( + lib.optionalAttrs (options ? wayland.windowManager.hyprland) { + # TODO deduplicate and abstract away base window management config + # install Niri related packages + home.packages = with pkgs; [ + xorg.xprop + grim + slurp + satty + xdg-desktop-portal-gtk + xdg-desktop-portal-gnome + kdePackages.xdg-desktop-portal-kde + xdg-desktop-portal-shana + copyq + wl-clipboard + + niri + xwayland-satellite + ]; + + xdg.configFile."niri/config.kdl" = let + mkNiriMod = mods: + builtins.map (mod: + if mod == "Mod" + then config.mods.wm.modKey + "+" + else "${mod}" + "+") + mods + |> lib.strings.concatStringsSep ""; + mkNiriArg = args: + if args != [] + then "\"${(lib.strings.concatStringsSep " " args)}\"" + else ""; + mkNiriCommand = bind: let + args = bind.args or []; + in + if bind.command == "quit" + then "quit;" + else if bind.command == "killActive" + then "close-window;" + else if bind.command == "moveFocusTop" + then "focus-window-up;" + else if bind.command == "focusWorkspace" + then "focus-workspace" + " " + mkNiriArg args + ";" + else if bind.command == "moveWindowRight" + then "move-column-right-or-to-monitor-right;" + else if bind.command == "moveWindowDown" + then "move-window-down;" + else if bind.command == "moveWindowLeft" + then "move-column-left-or-to-monitor-left;" + else if bind.command == "moveWindowUp" + then "move-window-up;" + else if bind.command == "moveFocusUp" + then "focus-window-up;" + else if bind.command == "moveFocusRight" + then "focus-column-or-monitor-right;" + else if bind.command == "moveFocusDown" + then "focus-window-down;" + else if bind.command == "moveFocusLeft" + then "focus-column-or-monitor-left;" + else if bind.command == "toggleFloating" + then "toggle-window-floating;" + else if bind.command == "toggleFullscreen" + then "fullscreen-window;" + else if bind.command == "moveToWorkspace" + then "move-window-to-workspace" + " " + mkNiriArg args + ";" + else if bind.command == "spawn" + then "spawn" + " " + mkNiriArg args + ";" + else if bind.command == "spawn-sh" + then "spawn-sh" + " " + mkNiriArg args + ";" + else if bind.command.niri != null + then bind.command.niri + " " + mkNiriArg args + ";" + else ""; + + mkNiriBinds = cfg: + '' binds { + '' + + ( + ( + builtins.map ( + bind: + /* + kdl + */ + if bind ? key && bind ? command + then '' + ${mkNiriMod (bind.modKeys or [])}${bind.key} ${ + if + bind ? meta + && bind.meta ? niri + then + ( + if + bind.meta.niri ? desc + && bind.meta.niri.desc != "" + then "hotkey-overlay-title=\"" + bind.meta.niri.desc + "\"" + else "" + ) + + " " + + ( + if + bind.meta.niri ? repeat + && bind.meta.niri.repeat + then "repeat=true" + else "repeat=false" + ) + + " " + + ( + if + bind.meta.niri ? allowWhileLocked + && bind.meta.niri.allowWhileLocked + then "allow-when-locked=true" + else "" + ) + + " " + + ( + if + bind.meta.niri ? allowInhibit + && bind.meta.niri.allowInhibit + then "allow-inhibiting=true" + else "allow-inhibiting=false" + ) + else "" + } { ${ + mkNiriCommand bind + } } + '' + else '''' + ) + (( + cfg.mods.wm.binds + ++ ( + if cfg.mods.wm.useDefaultBinds + then defaultWmConf.defaultBinds cfg + else [] + ) + ) + |> builtins.filter (bind: !(hasInvalidCustomCommand bind))) + ) + |> lib.strings.concatLines + ) + + '' + } + ''; + mkVrr = vrr: + if vrr + then "true" + else "false"; + mkNiriMonitors = cfg: + (builtins.map ( + monitor: + # TODO vrr + /* + kdl + */ + '' + output "${monitor.name}" { + variable-refresh-rate on-demand=${mkVrr monitor.vrr} + mode "${builtins.toString monitor.resolutionX}x${builtins.toString monitor.resolutionY}@${builtins.toString monitor.refreshrate}" + scale ${builtins.toString monitor.scale} + transform "${ + if (monitor.transform == "0") + then "normal" + else monitor.transform + }" + position x=${builtins.toString monitor.positionX} y=${builtins.toString monitor.positionY} + } + '' + ) + cfg.mods.wm.monitors) + |> lib.strings.concatLines; + mkNiriWorkspaces = cfg: + (builtins.map ( + workspace: + /* + kdl + */ + '' + workspace "${workspace.name}" { + open-on-output "${workspace.monitor}" + } + '' + ) + cfg.mods.wm.workspaces) + |> lib.strings.concatLines; + mkNiriWindowRules = cfg: ( + ( + builtins.map ( + rule: + /* + kdl + */ + '' + window-rule { + ${rule} + } + '' + ) + ( + cfg.mods.wm.windowRules.niri + ++ ( + if cfg.mods.wm.useDefaultWindowRules + then defaultWmConf.defaultWindowRules.niri + else [] + ) + ) + ) + |> lib.strings.concatLines + ); + hasInvalidCustomCommand = bind: !(bind ? command) || (!(builtins.isString bind.command) && bind.command.niri or null == null); + mkNiriEnv = config: let + defaultEnv = + if config.mods.wm.useDefaultEnv + then defaultWmConf.defaultEnv config + else { + all = {}; + niri = {}; + }; + userEnv = + if config.mods.wm.env ? all + then config.mods.wm.env.all // config.mods.wm.env.niri + else config.mods.wm.env; + env = + userEnv + // defaultEnv.all + // defaultEnv.niri; + in + '' + environment { + '' + + ( + lib.attrsets.mapAttrsToList ( + name: value: "${name} \"${value}\"" + ) + env + |> lib.strings.concatLines + ) + + '' + } + ''; + mkNiriAutoStart = config: let + defaultStartup = + if config.mods.wm.useDefaultStartup + then defaultWmConf.defaultStartup config + else { + all = {}; + niri = {}; + }; + userStartup = + if config.mods.wm.startup ? all + then config.mods.wm.startup.all ++ config.mods.wm.startup.niri + else config.mods.wm.startup; + autoStart = userStartup ++ defaultStartup.all ++ defaultStartup.niri; + in + (builtins.map (value: "spawn-at-startup \"${value}\"") + autoStart) + |> lib.strings.concatLines; + defaultConfig = + /* + kdl + */ + '' + input { + keyboard { + xkb { + layout "enIntUmlaut" + } + repeat-delay 200 + repeat-rate 25 + numlock + } + + touchpad { + tap + natural-scroll + } + + mouse { + accel-speed 0.2 + accel-profile "flat" + } + + focus-follows-mouse max-scroll-amount="25%" + } + + layout { + // Set gaps around windows in logical pixels. + gaps 10 + center-focused-column "never" + always-center-single-column + + preset-column-widths { + proportion 0.33333 + proportion 0.5 + proportion 1.0 + } + + default-column-width { proportion 0.5; } + focus-ring { + width 3 + inactive-color "#505050" + active-gradient from="#ff0000" to="#00ff00" angle=45 + } + + border { + off + } + + // You can enable drop shadows for windows. + shadow { + on + softness 30 + spread 5 + offset x=0 y=5 + color "#0007" + } + } + + // Autostart + + hotkey-overlay { + skip-at-startup + } + + prefer-no-csd + '' + + mkNiriMonitors config + + mkNiriBinds config + + mkNiriWorkspaces config + + mkNiriWindowRules config + + mkNiriEnv config + + mkNiriAutoStart config; + in + mkDashDefault { + text = + if config.mods.niri.useDefaultConfig + then defaultConfig + config.mods.niri.customConfig + else config.mods.niri.customConfig; + }; + } + ); +} diff --git a/modules/programs/oxi/default.nix b/modules/programs/oxi/default.nix index 99de567..942d0d1 100644 --- a/modules/programs/oxi/default.nix +++ b/modules/programs/oxi/default.nix @@ -54,8 +54,8 @@ lib.optionalAttrs (options ? home.packages) { programs = { hyprdock = { - enable = config.mods.oxi.hyprdock.enable; - settings = config.mods.oxi.hyprdock.settings; + inherit (config.mods.oxi.hyprdock) enable; + inherit (config.mods.oxi.hyprdock) settings; }; oxicalc.enable = lib.mkIf config.mods.oxi.oxicalc.enable true; ReSet = lib.mkIf config.mods.oxi.ReSet.enable { @@ -75,7 +75,7 @@ }; } // lib.optionalAttrs (options ? services.logind) { - services.logind.lidSwitchExternalPower = "ignore"; + services.logind.settings.Login.HandleLidSwitchExternalPower = "ignore"; } ); } diff --git a/modules/programs/wm.nix b/modules/programs/wm.nix new file mode 100644 index 0000000..2dd6bba --- /dev/null +++ b/modules/programs/wm.nix @@ -0,0 +1,403 @@ +{lib, ...}: let + wmWorkspace = with lib.types; { + options = { + name = lib.mkOption { + default = ""; + example = "1"; + type = str; + description = "Name of the workspace"; + }; + default = lib.mkOption { + default = false; + example = true; + type = bool; + description = "Whether the workspace is the default workspace. (Currently doesn't do anything on niri)"; + }; + monitor = lib.mkOption { + default = ""; + example = "DP-1"; + type = str; + description = "Name of the monitor to bind the workspace to"; + }; + }; + }; + + wmOptions = with lib.types; { + options = { + name = lib.mkOption { + default = "DP-1"; + example = "DP-1"; + type = str; + description = "Name of the monitor"; + }; + resolutionX = lib.mkOption { + default = 1920; + example = 2560; + type = number; + description = "ResolutionX of the monitor"; + }; + resolutionY = lib.mkOption { + default = 1080; + example = 1440; + type = number; + description = "ResolutionY of the monitor"; + }; + refreshrate = lib.mkOption { + default = 60; + example = 144; + type = number; + description = "Refreshrate of the monitor"; + }; + positionX = lib.mkOption { + default = 0; + example = 1920; + type = number; + description = "PositionX of the monitor"; + }; + positionY = lib.mkOption { + default = 0; + example = 1080; + type = number; + description = "PositionY of the monitor"; + }; + scale = lib.mkOption { + default = 1; + example = 2; + type = number; + description = "Scale of the monitor"; + }; + transform = lib.mkOption { + default = "0"; + example = "90"; + type = enum ["0" "90" "180" "270" "360"]; + description = "Transform of the monitor"; + }; + vrr = lib.mkOption { + default = false; + example = true; + type = bool; + description = "VRR status of the monitor"; + }; + }; + }; + + modKeys = lib.types.enum ["Mod" "Super" "Alt" "Shift" "Ctrl"]; + + customCommand = with lib.types; { + options = { + niri = lib.mkOption { + default = null; + example = "kitty"; + type = either null str; + description = "Command to use in niri"; + }; + hyprland = lib.mkOption { + default = null; + example = "kitty"; + type = either null str; + description = "Command to use in hyprland"; + }; + }; + }; + + envOptions = with lib.types; { + options = { + all = lib.mkOption { + default = {}; + example = {}; + type = attrsOf str; + description = "General Env"; + }; + niri = lib.mkOption { + default = {}; + example = {}; + type = attrsOf str; + description = "Niri Env"; + }; + hyprland = lib.mkOption { + default = {}; + example = {}; + type = attrsOf str; + description = "Hyprland Env"; + }; + }; + }; + + startupOptions = with lib.types; { + options = { + all = lib.mkOption { + default = []; + example = []; + type = listOf str; + description = "General Startup commands"; + }; + niri = lib.mkOption { + default = []; + example = []; + type = listOf str; + description = "Niri Startup commands"; + }; + hyprland = lib.mkOption { + default = []; + example = []; + type = listOf str; + description = "Hyprland Startup commands"; + }; + }; + }; + + windowRuleOptions = with lib.types; { + options = { + niri = lib.mkOption { + default = []; + example = []; + type = listOf lines; + description = "Niri window rules"; + }; + hyprland = lib.mkOption { + default = []; + example = []; + type = listOf str; + description = "Hyprland window rules"; + }; + }; + }; + + bindOptions = with lib.types; { + options = { + modKeys = lib.mkOption { + default = []; + example = ["Mod"]; + type = listOf modKeys; + description = "List of modifier keys"; + }; + key = lib.mkOption { + default = ""; + example = "Q"; + type = str; + description = "Key to bind"; + }; + command = lib.mkOption { + default = ""; + example = "killActive"; + type = either (submodule customCommand) (enum [ + "spawn" + "spawn-sh" + "quit" + "killActive" + "moveFocusUp" + "moveFocusRight" + "moveFocusDown" + "moveFocusLeft" + "moveWindowUp" + "moveWindowRight" + "moveWindowDown" + "moveWindowLeft" + "focusWorkspace" + "moveToWorkspace" + "toggleFloating" + "toggleFullscreen" + ]); + description = "Command to execute"; + }; + args = lib.mkOption { + default = []; + example = []; + type = listOf str; + description = "Additional arguments for the command"; + }; + meta = lib.mkOption { + default = {}; + example = {}; + type = submodule { + options = { + niri = lib.mkOption { + default = {}; + type = submodule { + options = { + desc = lib.mkOption { + default = ""; + type = str; + description = "Description for Hotkey overview"; + }; + repeat = lib.mkOption { + type = bool; + default = true; + description = "Whether to repeat the keybind on hold"; + }; + allowInhibit = lib.mkOption { + type = bool; + default = true; + description = "Whether to allow inhibiting"; + }; + allowWhileLocked = lib.mkOption { + type = bool; + default = false; + description = "Whether to allow while locked"; + }; + cooldown = lib.mkOption { + type = number; + default = 0; + description = "Cooldown on bind"; + }; + }; + }; + description = "Niri meta for keybinds"; + }; + hyprland = lib.mkOption { + default = {}; + type = submodule { + options = { + repeat = lib.mkOption { + type = bool; + default = true; + description = "Whether to repeat the keybind on hold"; + }; + }; + }; + description = "Niri meta for keybinds"; + }; + }; + }; + description = "Custom metadata per bind. Note, only supported environments are taken into account."; + }; + }; + }; +in { + options.mods.wm = { + modKey = lib.mkOption { + default = "Super"; + example = "Alt"; + type = modKeys; + description = "Mod key"; + }; + + env = lib.mkOption { + default = {}; + example = { + all = { + EDITOR = "Neovim"; + }; + niri = { + EDITOR = "Emacs"; + }; + }; + type = with lib.types; either (submodule envOptions) (attrsOf str); + description = "Environment configuration"; + }; + + useDefaultEnv = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = "Whether to use default env variables"; + }; + + startup = lib.mkOption { + default = []; + example = { + all = ["oxinoti"]; + niri = ["someniricommand"]; + hyprland = ["somehyprlandcommand"]; + }; + type = with lib.types; either (submodule startupOptions) (listOf str); + description = "Start commands"; + }; + + useDefaultStartup = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = "Whether to use default autostart commands"; + }; + + useDefaultWindowRules = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = "Whether to use default window rules"; + }; + + windowRules = lib.mkOption { + default = []; + example = { + niri = [ + '' + match app-id=r#"^org\.keepassxc\.KeePassXC$"# + match app-id=r#"^org\.gnome\.World\.Secrets$"# + + block-out-from "screen-capture" + '' + '' + match app-id=r#"^steam$"# + open-on-workspace "0" + '' + ]; + }; + type = lib.types.submodule windowRuleOptions; + description = "Window rules"; + }; + + workspaces = lib.mkOption { + default = []; + example = [ + { + name = "chat"; + monitor = "DP-1"; + } + ]; + type = + lib.types.listOf (lib.types.submodule wmWorkspace); + description = "Workspace configuration"; + }; + + monitors = lib.mkOption { + default = []; + example = [ + { + name = "DP-1"; + resolutionX = 1920; + resolutionY = 1080; + refreshrate = 144; + positionX = 0; + positionY = 0; + scale = 1; + transform = "0"; + vrr = false; + } + ]; + type = + lib.types.listOf (lib.types.submodule wmOptions); + description = "Monitor configuration"; + }; + + useDefaultBinds = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = "Whether to use default keybinds"; + }; + + binds = lib.mkOption { + default = []; + example = [ + { + modKeys = ["Mod"]; + key = "Q"; + command = "killActive"; + args = []; + meta = { + niri = { + desc = "Kill the active window"; + repeat = false; + }; + hyprland = {}; + }; + } + ]; + type = + lib.types.listOf (lib.types.submodule bindOptions); + description = "Bind configuration"; + }; + }; +} From 1f367f80fa54c656636a22e863a53d596163e10d Mon Sep 17 00:00:00 2001 From: DashieTM Date: Sun, 5 Oct 2025 13:37:51 +0200 Subject: [PATCH 05/29] chore(documentation): Add niri --- docs/src/README.md | 35 +++++++++++-------------- example/hosts/example/configuration.nix | 32 +++++++++------------- 2 files changed, 28 insertions(+), 39 deletions(-) diff --git a/docs/src/README.md b/docs/src/README.md index 6233312..cae9646 100644 --- a/docs/src/README.md +++ b/docs/src/README.md @@ -74,26 +74,20 @@ Here is a minimal required configuration.nix (the TODOs mention a required chang # default disk config has root home boot and swap partition, overwrite if you want something different sops.enable = false; nextcloud.enable = false; - hypr.hyprland = { - # TODO monitor configuration for hyprland (hyprland is default) - # should be something like DP-1 - defaultMonitor = "YOURMONITOR"; - # width x height @ refreshrate - defaultMonitorMode = "1920x1080@60"; - # scale for your main monitor - defaultMonitorScale = "1"; - # additional configruation can be done as well - # customConfig = { - # monitor = [ - # # default - # "${config.mods.hypr.hyprland.defaultMonitor},${config.mods.hypr.hyprland.defaultMonitorMode},0x0,${config.mods.hypr.hyprland.defaultMonitorScale}" - # # second example monitor - # "DP-2,3440x1440@180,auto,1" - # # all others - # ",highrr,auto,1" - # ]; - # } - }; + wm.monitors = [ + # Example + # { + # name = "DP-1"; + # resolutionX = 3440; + # resolutionY = 1440; + # refreshrate = 180; + # positionX = 2560; + # positionY = 0; + # scale = 1; + # transform = "0"; + # vrr = false; + # } + ]; gpu.nvidia.enable = true; kdeConnect.enable = true; # login manager: @@ -234,6 +228,7 @@ These modules attempt to combine the home-manager and nixos packages/options to For package lists, please check the individual modules, as the lists can be long. - Hyprland: Installs and configures Hyprland with various additional packages +- Niri: Installs and configures Niri with various additional packages - acpid : Enables the acpid daemon - base packages : A list of system packages to be installed by default - bluetooth : Configures/enables bluetooth and installs tools for bluetooth diff --git a/example/hosts/example/configuration.nix b/example/hosts/example/configuration.nix index 5d9e612..dbe8cd0 100644 --- a/example/hosts/example/configuration.nix +++ b/example/hosts/example/configuration.nix @@ -18,26 +18,20 @@ # default disk config has root home boot and swap partition, overwrite if you want something different sops.enable = false; nextcloud.enable = false; - hypr.hyprland = { - # TODO monitor configuration for hyprland (hyprland is default) - # should be something like DP-1 - defaultMonitor = "YOURMONITOR"; - # width x height @ refreshrate - defaultMonitorMode = "1920x1080@60"; - # scale for your main monitor - defaultMonitorScale = "1"; - # additional configruation can be done as well - # customConfig = { - # monitor = [ - # # default - # "${config.mods.hypr.hyprland.defaultMonitor},${config.mods.hypr.hyprland.defaultMonitorMode},0x0,${config.mods.hypr.hyprland.defaultMonitorScale}" - # # second example monitor - # "DP-2,3440x1440@180,auto,1" - # # all others - # ",highrr,auto,1" - # ]; + wm.monitors = [ + # Example + # { + # name = "DP-1"; + # resolutionX = 3440; + # resolutionY = 1440; + # refreshrate = 180; + # positionX = 2560; + # positionY = 0; + # scale = 1; + # transform = "0"; + # vrr = false; # } - }; + ]; gpu.nvidia.enable = true; kdeConnect.enable = true; # login manager: From 6f90f67384d437f7271c8ecde4b4c73b4f91e314 Mon Sep 17 00:00:00 2001 From: DashieTM Date: Sun, 5 Oct 2025 13:39:04 +0200 Subject: [PATCH 06/29] chore(statix): Apply fixes --- modules/programs/hypr/hyprland.nix | 2 +- modules/programs/niri.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/programs/hypr/hyprland.nix b/modules/programs/hypr/hyprland.nix index f6ee377..906476d 100644 --- a/modules/programs/hypr/hyprland.nix +++ b/modules/programs/hypr/hyprland.nix @@ -161,7 +161,7 @@ in { bind: "${mkMods bind},${bind.key},${mkCommand bind}" ); mkCommand = bind: let - args = bind.args or []; + inherit (bind) args; in if bind.command == "quit" then "exit" diff --git a/modules/programs/niri.nix b/modules/programs/niri.nix index cf39776..a45d419 100644 --- a/modules/programs/niri.nix +++ b/modules/programs/niri.nix @@ -69,7 +69,7 @@ in { then "\"${(lib.strings.concatStringsSep " " args)}\"" else ""; mkNiriCommand = bind: let - args = bind.args or []; + inherit (bind) args; in if bind.command == "quit" then "quit;" From 65e21a7d0006959f8a4dfe5f6446f54dd96020fc Mon Sep 17 00:00:00 2001 From: DashieTM Date: Tue, 7 Oct 2025 12:34:48 +0200 Subject: [PATCH 07/29] chore(wm): Conditionally check for args --- modules/programs/hypr/hyprland.nix | 2 +- modules/programs/niri.nix | 2 +- modules/programs/wm.nix | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/programs/hypr/hyprland.nix b/modules/programs/hypr/hyprland.nix index 906476d..f6ee377 100644 --- a/modules/programs/hypr/hyprland.nix +++ b/modules/programs/hypr/hyprland.nix @@ -161,7 +161,7 @@ in { bind: "${mkMods bind},${bind.key},${mkCommand bind}" ); mkCommand = bind: let - inherit (bind) args; + args = bind.args or []; in if bind.command == "quit" then "exit" diff --git a/modules/programs/niri.nix b/modules/programs/niri.nix index a45d419..cf39776 100644 --- a/modules/programs/niri.nix +++ b/modules/programs/niri.nix @@ -69,7 +69,7 @@ in { then "\"${(lib.strings.concatStringsSep " " args)}\"" else ""; mkNiriCommand = bind: let - inherit (bind) args; + args = bind.args or []; in if bind.command == "quit" then "quit;" diff --git a/modules/programs/wm.nix b/modules/programs/wm.nix index 2dd6bba..0f794d3 100644 --- a/modules/programs/wm.nix +++ b/modules/programs/wm.nix @@ -319,7 +319,7 @@ in { }; windowRules = lib.mkOption { - default = []; + default = {}; example = { niri = [ '' From a49055c1cc1e3183665f69fbeb746c62dddca665 Mon Sep 17 00:00:00 2001 From: DashieTM Date: Tue, 7 Oct 2025 12:49:57 +0200 Subject: [PATCH 08/29] chore(ironbar): Update upower module --- modules/programs/ironbar.nix | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/modules/programs/ironbar.nix b/modules/programs/ironbar.nix index 5757347..b34b32a 100644 --- a/modules/programs/ironbar.nix +++ b/modules/programs/ironbar.nix @@ -13,9 +13,14 @@ end = [ (lib.mkIf useBatteryModule { - type = "upower"; + type = "battery"; class = "battery"; icon_size = 0; + format = "{percentage}%"; + thresholds = { + warning = 20; + critical = 5; + }; }) { class = "music"; @@ -430,8 +435,8 @@ in { color: @background; } - /* upower */ - .upower { + /* battery */ + .battery { font-size: 13px; padding: 0px 4px 0px 0px; margin: 2px 0px 2px 0px; @@ -439,21 +444,21 @@ in { color: @primary; } - .upower .icon { + .battery .icon { opacity: 0.0; } - .upower .label { + .battery .label { margin: 2px 0px 0px -8px; color: @primary; } - .upower:hover { + .battery:hover { background-color: @secondary-background; border-radius: 5px; } - .popup-upower { + .popup-battery { background-color: @background; color: @primary; border-radius: 8px; From db861d807a472ec1b8d575ee622d38e8d0919e3b Mon Sep 17 00:00:00 2001 From: DashieTM Date: Tue, 7 Oct 2025 15:41:50 +0200 Subject: [PATCH 09/29] chore(niri): Add anti flicker for nvidia --- modules/programs/niri.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/programs/niri.nix b/modules/programs/niri.nix index cf39776..a973774 100644 --- a/modules/programs/niri.nix +++ b/modules/programs/niri.nix @@ -353,6 +353,16 @@ in { } } + ${ + if config.mods.gpu.nvidia.enable + then '' + debug { + wait-for-frame-completion-before-queueing + } + '' + else '''' + } + // Autostart hotkey-overlay { From 2c218306b9773244ada6193796cb95fbe6d135fd Mon Sep 17 00:00:00 2001 From: DashieTM Date: Fri, 10 Oct 2025 19:29:14 +0200 Subject: [PATCH 10/29] chore(wm): Fix hyprland keybinds --- base/common_hardware.nix | 2 ++ lib/wm.nix | 6 +++--- modules/programs/hypr/hyprland.nix | 22 +++++++++++----------- modules/programs/niri.nix | 7 +++++-- modules/programs/printing.nix | 4 ++++ modules/programs/virtmanager.nix | 2 -- 6 files changed, 25 insertions(+), 18 deletions(-) diff --git a/base/common_hardware.nix b/base/common_hardware.nix index 56a6dc6..8df238a 100644 --- a/base/common_hardware.nix +++ b/base/common_hardware.nix @@ -164,6 +164,8 @@ in { "vboxusers" "video" "audio" + "scanner" + "lp" ]; packages = with pkgs; [ home-manager diff --git a/lib/wm.nix b/lib/wm.nix index 1352623..3b5819d 100644 --- a/lib/wm.nix +++ b/lib/wm.nix @@ -1,4 +1,4 @@ -{lib, ...}: let +let browserName = config: if (builtins.isString config.mods.homePackages.browser) then config.mods.homePackages.browser @@ -247,8 +247,8 @@ in { else {} ) - (mkBindWithDesc ["Mod"] "S" "spawn-sh" [''grim -g \"$(slurp)\" - | wl-copy''] "Take Screenshot") - (mkBindWithDesc ["Mod" "Shift"] "S" "spawn-sh" [''grim -g \"$(slurp)\" - | satty -f -''] "Take Screenshot and edit") + (mkBindWithDesc ["Mod"] "S" "spawn-sh" [''grim -g "$(slurp)" - | wl-copy''] "Take Screenshot") + (mkBindWithDesc ["Mod" "Shift"] "S" "spawn-sh" [''grim -g "$(slurp)" - | satty -f -''] "Take Screenshot and edit") ( if config.mods.scripts.audioControl diff --git a/modules/programs/hypr/hyprland.nix b/modules/programs/hypr/hyprland.nix index f6ee377..f32bc74 100644 --- a/modules/programs/hypr/hyprland.nix +++ b/modules/programs/hypr/hyprland.nix @@ -6,7 +6,7 @@ pkgs, ... }: let - defaultWmConf = import ../../../lib/wm.nix {inherit lib;}; + defaultWmConf = import ../../../lib/wm.nix; in { options.mods.hypr.hyprland = { enable = lib.mkOption { @@ -137,7 +137,7 @@ in { if args != [] then (lib.strings.concatStringsSep " " args) else ""; - shouldRepeat = bind: bind ? meta && bind.meta ? hyprland && bind.meta.hyprland ? repeat && bind.meta.hyprland.repeat; + shouldRepeat = bind: bind ? meta && bind.meta ? hyprland && bind.meta.hyprland ? repeat && bind.meta.hyprland.repeat == true; defaultBinds = cfg: if cfg.mods.wm.useDefaultBinds @@ -148,7 +148,7 @@ in { binds = cfg.mods.wm.binds ++ defaultBinds cfg; in binds - |> builtins.filter (bind: bind ? command && shouldRepeat bind && !hasInvalidCustomCommand bind) + |> builtins.filter (bind: bind ? command && shouldRepeat bind && !(hasInvalidCustomCommand bind)) |> builtins.map ( bind: "${mkMods bind},${bind.key},${mkCommand bind}" ); @@ -156,7 +156,7 @@ in { binds = cfg.mods.wm.binds ++ defaultBinds cfg; in binds - |> builtins.filter (bind: bind ? command && !(shouldRepeat bind) && !hasInvalidCustomCommand bind) + |> builtins.filter (bind: bind ? command && !(shouldRepeat bind) && !(hasInvalidCustomCommand bind)) |> builtins.map ( bind: "${mkMods bind},${bind.key},${mkCommand bind}" ); @@ -338,13 +338,13 @@ in { "noanim, selection" ]; - workspace = mkDashDefault (mkWorkspace config.mods.wm.workspaces); - monitor = mkDashDefault (mkMonitors config.mods.wm.monitors); - env = mkDashDefault (mkEnv config); - bind = mkDashDefault (mkBinds config); - binde = mkDashDefault (mkEBinds config); - windowrule = mkDashDefault (mkWindowRule config); - exec-once = mkDashDefault (mkAutoStart config); + workspace = mkWorkspace config.mods.wm.workspaces; + monitor = mkMonitors config.mods.wm.monitors; + env = mkEnv config; + bind = mkBinds config; + binde = mkEBinds config; + windowrule = mkWindowRule config; + exec-once = mkAutoStart config; plugin = config.mods.hypr.hyprland.pluginConfig; } config.mods.hypr.hyprland.customConfig diff --git a/modules/programs/niri.nix b/modules/programs/niri.nix index a973774..0531829 100644 --- a/modules/programs/niri.nix +++ b/modules/programs/niri.nix @@ -6,7 +6,7 @@ pkgs, ... }: let - defaultWmConf = import ../../lib/wm.nix {inherit lib;}; + defaultWmConf = import ../../lib/wm.nix; in { options.mods.niri = { enable = lib.mkOption { @@ -66,7 +66,10 @@ in { |> lib.strings.concatStringsSep ""; mkNiriArg = args: if args != [] - then "\"${(lib.strings.concatStringsSep " " args)}\"" + then let + concatCommand = lib.strings.concatStringsSep " " args; + validCommand = builtins.replaceStrings [''"''] [''\"''] concatCommand; + in "\"${validCommand}\"" else ""; mkNiriCommand = bind: let args = bind.args or []; diff --git a/modules/programs/printing.nix b/modules/programs/printing.nix index 848ffef..98bbe4f 100644 --- a/modules/programs/printing.nix +++ b/modules/programs/printing.nix @@ -16,6 +16,10 @@ config = lib.mkIf config.mods.printing.enable ( lib.optionalAttrs (options ? services.printing) { # Enable CUPS to print documents. + environment.systemPackages = with pkgs; [ + simple-scan + ]; + hardware.sane.enable = true; services = { printing = { enable = true; diff --git a/modules/programs/virtmanager.nix b/modules/programs/virtmanager.nix index bf81b93..de38848 100644 --- a/modules/programs/virtmanager.nix +++ b/modules/programs/virtmanager.nix @@ -44,8 +44,6 @@ in { qemu = { package = mkDashDefault pkgs.qemu_kvm; swtpm.enable = mkDashDefault true; - ovmf.enable = mkDashDefault true; - ovmf.packages = [pkgs.OVMFFull.fd]; }; }; spiceUSBRedirection.enable = mkDashDefault true; From af31c8f5f043886e112686f688c38bc4a25eaf85 Mon Sep 17 00:00:00 2001 From: DashieTM Date: Fri, 10 Oct 2025 21:08:59 +0200 Subject: [PATCH 11/29] chore(yazi): Add backspace --- lib/wm.nix | 8 ++++---- modules/programs/yazi/yazi.nix | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/wm.nix b/lib/wm.nix index 3b5819d..a4bfd31 100644 --- a/lib/wm.nix +++ b/lib/wm.nix @@ -156,7 +156,7 @@ in { (mkSimpleBind ["Mod"] "7" "focusWorkspace" ["7"]) (mkSimpleBind ["Mod"] "8" "focusWorkspace" ["8"]) (mkSimpleBind ["Mod"] "9" "focusWorkspace" ["9"]) - (mkSimpleBind ["Mod"] "0" "focusWorkspace" ["0"]) + (mkSimpleBind ["Mod"] "0" "focusWorkspace" ["10"]) (mkSimpleBind ["Mod" "Shift"] "1" "moveToWorkspace" ["1"]) (mkSimpleBind ["Mod" "Shift"] "2" "moveToWorkspace" ["2"]) (mkSimpleBind ["Mod" "Shift"] "3" "moveToWorkspace" ["3"]) @@ -166,7 +166,7 @@ in { (mkSimpleBind ["Mod" "Shift"] "7" "moveToWorkspace" ["7"]) (mkSimpleBind ["Mod" "Shift"] "8" "moveToWorkspace" ["8"]) (mkSimpleBind ["Mod" "Shift"] "9" "moveToWorkspace" ["9"]) - (mkSimpleBind ["Mod" "Shift"] "0" "moveToWorkspace" ["0"]) + (mkSimpleBind ["Mod" "Shift"] "0" "moveToWorkspace" ["10"]) (mkSimpleBind ["Mod"] "B" "toggleFullscreen" []) (mkSimpleBind ["Mod"] "V" "toggleFloating" []) (mkSimpleBind ["Mod" "Shift"] "M" "quit" []) @@ -366,7 +366,7 @@ in { (mkSimpleCustomBind ["Mod" "Ctrl"] "7" "move-column-to-workspace" null ["7"]) (mkSimpleCustomBind ["Mod" "Ctrl"] "8" "move-column-to-workspace" null ["8"]) (mkSimpleCustomBind ["Mod" "Ctrl"] "9" "move-column-to-workspace" null ["9"]) - (mkSimpleCustomBind ["Mod" "Ctrl"] "0" "move-column-to-workspace" null ["0"]) + (mkSimpleCustomBind ["Mod" "Ctrl"] "0" "move-column-to-workspace" null ["10"]) (mkSimpleCustomBind ["Mod" "Shift"] "J" "focus-monitor-left" null []) (mkSimpleCustomBind ["Mod" "Shift"] "semicolon" "focus-monitor-right" null []) (mkSimpleCustomBind ["Mod" "Ctrl"] "J" "move-column-to-monitor-left" null []) @@ -425,7 +425,7 @@ in { (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "7" null "movetoworkspacesilent" ["7"]) (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "8" null "movetoworkspacesilent" ["8"]) (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "9" null "movetoworkspacesilent" ["9"]) - (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "0" null "movetoworkspacesilent" ["0"]) + (mkSimpleCustomBind ["Mod" "SHIFT" "ALT"] "0" null "movetoworkspacesilent" ["10"]) (mkRepeatCustomBind ["Mod"] "U" null "resizeactive" ["-20" "0"]) (mkRepeatCustomBind ["Mod"] "P" null "resizeactive" ["20" "0"]) (mkRepeatCustomBind ["Mod"] "O" null "resizeactive" ["0" "-20"]) diff --git a/modules/programs/yazi/yazi.nix b/modules/programs/yazi/yazi.nix index bed1c03..e76ac11 100644 --- a/modules/programs/yazi/yazi.nix +++ b/modules/programs/yazi/yazi.nix @@ -102,6 +102,11 @@ }; keymap = { mgr.keymap = [ + { + on = ""; + run = "backspace"; + desc = "Delete the character before the cursor"; + } { on = [""]; run = "escape"; From ec3d1a83399d92a260bbd8f6a42ea238ea7dbbe9 Mon Sep 17 00:00:00 2001 From: DashieTM Date: Fri, 10 Oct 2025 21:08:59 +0200 Subject: [PATCH 12/29] chore(yazi): Add backspace --- modules/programs/yazi/yazi.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/programs/yazi/yazi.nix b/modules/programs/yazi/yazi.nix index e76ac11..0a6aec6 100644 --- a/modules/programs/yazi/yazi.nix +++ b/modules/programs/yazi/yazi.nix @@ -768,6 +768,11 @@ ]; input.keymap = [ + { + on = ""; + run = "backspace"; + desc = "Delete the character before the cursor"; + } { on = [""]; run = "close"; From 96cf0a24c1578fd32cb0f9c84bc3c34b569d209d Mon Sep 17 00:00:00 2001 From: DashieTM Date: Sat, 11 Oct 2025 09:24:32 +0200 Subject: [PATCH 13/29] chore(scx): Allow setting the scheduler --- modules/programs/gaming.nix | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/modules/programs/gaming.nix b/modules/programs/gaming.nix index 3483171..6189cce 100644 --- a/modules/programs/gaming.nix +++ b/modules/programs/gaming.nix @@ -74,18 +74,50 @@ type = lib.types.int; description = "Your gpu device.(Physical id of lshw)"; }; + scheduler = lib.mkOption { + default = "scx_rustland"; + example = "scx_rusty"; + type = with lib.types; + nullOr (enum [ + "scx_bpfland" + "scx_chaos" + "scx_cosmos" + "scx_central" + "scx_flash" + "scx_flatcg" + "scx_lavd" + "scx_layered" + "scx_mitosis" + "scx_nest" + "scx_p2dq" + "scx_pair" + "scx_prev" + "scx_qmap" + "scx_rlfifo" + "scx_rustland" + "scx_rusty" + "scx_sdt" + "scx_simple" + "scx_tickless" + "scx_userland" + "scx_wd40" + ]); + description = "Scheduler to use, null disables this"; + }; }; config = lib.mkIf config.mods.gaming.enable ( lib.optionalAttrs (options ? environment.systemPackages) { environment.systemPackages = config.mods.gaming.tools; boot.kernelPackages = lib.mkForce pkgs.linuxPackages_cachyos; - services.scx.enable = true; + services.scx = lib.mkIf (config.mods.gaming.scheduler != null) { + enable = true; + inherit (config.mods.gaming) scheduler; + }; programs = { steam.enable = mkDashDefault config.mods.gaming.steam; gamemode.enable = true; gamemode = { - enableRenice = mkDashDefault true; settings = { general = { desiredgov = mkDashDefault "performance"; From b39db82a29e1d69ed12a8f9417f0b7c2ea5fdfd2 Mon Sep 17 00:00:00 2001 From: DashieTM Date: Sat, 1 Nov 2025 23:19:25 +0100 Subject: [PATCH 14/29] feature(config): Allow pkgs config --- docs/src/README.md | 31 ++++++++++++++ flake.nix | 38 +++++------------- lib/default.nix | 67 +++++++++++++++++++++++++------ modules/programs/gpu.nix | 2 +- modules/programs/homePackages.nix | 10 ++--- modules/programs/ironbar.nix | 4 +- modules/programs/media.nix | 2 +- modules/programs/stylix.nix | 2 +- 8 files changed, 104 insertions(+), 52 deletions(-) diff --git a/docs/src/README.md b/docs/src/README.md index cae9646..6ac856e 100644 --- a/docs/src/README.md +++ b/docs/src/README.md @@ -165,6 +165,37 @@ nixosConfigurations = inputs.dashNix.dashNixLib.buildSystems { root = ./.; inherit additionalInputs; }; ``` +## Configuring pkgs + +While DashNix offers a default pkgs config, you may want to permit an unsecure packages or add an overlay to them. +You can configure both stable and unstable pkgs the following way: + +```nix +currentSystem = "x86_64-linux"; +permittedPackages = [ + "some package" +]; +config = { + system = currentSystem; + config = { + allowUnfree = true; + permittedInsecurePackages = permittedPackages; + }; +}; +unstableBundle = { + pkgs = inputs.unstable; + inherit config; +}; +inputs.dashNix.dashNixLib.buildSystems { + root = ./.; + inherit unstableBundle; +} +``` + +With this you could also change your input to something different should you wish to do so. +Note that overriding inputs via the flake still works, +this way however ensures you can also configure the inputs. + ## Stable/Unstable Sometimes you want to differentiate between systems that are stable and unstable, e.g. for servers and desktops/laptops. diff --git a/flake.nix b/flake.nix index 665829b..8033b24 100644 --- a/flake.nix +++ b/flake.nix @@ -59,47 +59,27 @@ currentSystem = "x86_64-linux"; permittedPackages = [ "olm-3.2.16" - # well done dotnet... - # this is just for omnisharp - "dotnet-core-combined" - "dotnet-wrapped-combined" - "dotnet-combined" - "dotnet-sdk-6.0.428" - "dotnet-sdk-wrapped-6.0.428" - "dotnet-sdk-6.0.136" - "dotnet-sdk-wrapped-6.0.136" - "dotnet-sdk-7.0.120" - "dotnet-sdk-wrapped-7.0.120" - "dotnet-sdk-7.0.410" - "dotnet-sdk-wrapped-7.0.410" - "jitsi-meet-1.0.8043" - "nextcloud-27.1.11" ]; - stable = import ./lib/importPkgs.nix { - inherit inputs permittedPackages currentSystem; - pkgs = inputs.stable; - }; - unstable = import ./lib/importPkgs.nix { - inherit inputs permittedPackages currentSystem; - pkgs = inputs.unstable; - }; - pkgsDarkreader = import ./lib/importPkgs.nix { - inherit inputs permittedPackages currentSystem; - pkgs = inputs.pkgsDarkreader; - }; + importPkgsFn = import ./lib/importPkgs.nix; + defaultConfigureFn = pkgs: + importPkgsFn { + inherit inputs currentSystem permittedPackages pkgs; + }; + stable = defaultConfigureFn inputs.stable; + unstable = defaultConfigureFn inputs.unstable; + pkgsDarkreader = defaultConfigureFn inputs.pkgsDarkreader; in rec { dashNixLib = import ./lib { inherit self inputs unstable - stable + permittedPackages ; dashNixAdditionalProps = { inherit pkgsDarkreader; }; system = currentSystem; - inherit (inputs.unstable) lib; }; docs = import ./docs { inherit inputs; diff --git a/lib/default.nix b/lib/default.nix index 30d34ec..0254ba2 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,13 +1,35 @@ { inputs, - lib, unstable, self, - stable, system, + permittedPackages, dashNixAdditionalProps ? {}, ... -}: { +}: let + defaultConfig = { + config = { + allowUnfree = true; + permittedInsecurePackages = permittedPackages; + }; + overlays = [ + inputs.nur.overlays.default + inputs.chaoticNyx.overlays.cache-friendly + ]; + inherit system; + }; + mkPkgs = { + pkgs, + config, + }: let + overlays = + if (config ? overlays) + then config.overlays + else []; + comnbinedConfig = config // {overlays = overlays ++ defaultConfig.overlays;}; + in + import pkgs comnbinedConfig; +in { /* * # buildSystems @@ -75,9 +97,27 @@ ]; }, additionalInputs ? {}, + unstableBundle ? {}, + stableBundle ? {}, overridePkgs ? false, ... - }: + }: let + unstableInput = unstableBundle.pkgs or inputs.unstable; + stableInput = stableBundle.pkgs or inputs.stable; + unstableConfig = unstableBundle.config or defaultConfig; + stableConfig = stableBundle.config or defaultConfig; + + unstablePkgs = mkPkgs { + pkgs = unstableInput; + config = unstableConfig; + }; + stablePkgs = mkPkgs { + pkgs = stableInput; + config = stableConfig; + }; + inputlib = unstableInput.lib; + inherit (unstablePkgs) lib; + in builtins.listToAttrs ( map (name: { @@ -94,27 +134,28 @@ additionalHomeConfig system root - stable - unstable additionalInputs dashNixAdditionalProps + lib ; + stable = stablePkgs; + unstable = unstablePkgs; pkgs = lib.mkForce ( if overridePkgs - then stable - else unstable + then stablePkgs + else unstablePkgs ); alternativePkgs = if overridePkgs - then unstable - else stable; + then unstablePkgs + else stablePkgs; hostName = name; homeMods = mods.home; additionalHomeMods = additionalMods.home; mkDashDefault = import ./override.nix {inherit lib;}; }; in - inputs.unstable.lib.nixosSystem { + inputlib.nixosSystem { modules = [ {_module.args = args;} @@ -122,8 +163,8 @@ ] ++ mods.nixos ++ additionalMods.nixos - ++ inputs.unstable.lib.optional (builtins.pathExists additionalNixosConfig) additionalNixosConfig - ++ inputs.unstable.lib.optional (builtins.pathExists mod) mod; + ++ lib.optional (builtins.pathExists additionalNixosConfig) additionalNixosConfig + ++ lib.optional (builtins.pathExists mod) mod; }; }) ( diff --git a/modules/programs/gpu.nix b/modules/programs/gpu.nix index 8fd8959..87305f0 100644 --- a/modules/programs/gpu.nix +++ b/modules/programs/gpu.nix @@ -87,7 +87,7 @@ pkgs.intel-media-driver) (lib.mkIf config.mods.gpu.vapi.enable pkgs.libvdpau-va-gl) (lib.mkIf config.mods.gpu.vapi.enable pkgs.libva) - (lib.mkIf config.mods.gpu.vapi.enable pkgs.vaapiVdpau) + (lib.mkIf config.mods.gpu.vapi.enable pkgs.libva-vdpau-driver) (lib.mkIf (config.mods.gpu.intelgpu.enable || config.mods.gpu.amdgpu.enable) pkgs.mesa) ]; rocmPackages = [ diff --git a/modules/programs/homePackages.nix b/modules/programs/homePackages.nix index eabd176..c987c94 100644 --- a/modules/programs/homePackages.nix +++ b/modules/programs/homePackages.nix @@ -102,11 +102,11 @@ (lib.mkIf config.mods.homePackages.orcaSlicer orca-slicer) (lib.mkIf config.mods.homePackages.vesktop vesktop) (lib.mkIf config.mods.homePackages.nextcloudClient nextcloud-client) - (lib.mkIf (!isNull config.mods.homePackages.matrixClient) config.mods.homePackages.matrixClient) - (lib.mkIf (!isNull config.mods.homePackages.mailClient) config.mods.homePackages.mailClient) + (lib.mkIf (config.mods.homePackages.matrixClient != null) config.mods.homePackages.matrixClient) + (lib.mkIf (config.mods.homePackages.mailClient != null) config.mods.homePackages.mailClient) (lib.mkIf ( # NOTE: This should be package, but nix doesn't have that.... - builtins.isAttrs config.mods.homePackages.browser && !isNull config.mods.homePackages.browser + builtins.isAttrs config.mods.homePackages.browser && config.mods.homePackages.browser != null ) config.mods.homePackages.browser) adw-gtk3 @@ -128,10 +128,10 @@ nh nix-index playerctl - poppler_utils + poppler-utils pulseaudio libsForQt5.qt5ct - qt6ct + qt6Packages.qt6ct fcp ripgrep rm-improved diff --git a/modules/programs/ironbar.nix b/modules/programs/ironbar.nix index b34b32a..b955d51 100644 --- a/modules/programs/ironbar.nix +++ b/modules/programs/ironbar.nix @@ -4,6 +4,7 @@ pkgs, inputs, options, + mkDashDefault, ... }: let inherit (config.conf) username; @@ -263,8 +264,7 @@ in { config = lib.mkIf (config.mods.ironbar.enable || config.mods.hypr.hyprland.useIronbar) ( lib.optionalAttrs (options ? programs.ironbar) { programs.ironbar = { - # TODO broken - # package = mkDashDefault pkgs.ironbar; + package = mkDashDefault pkgs.ironbar; enable = true; style = if config.mods.ironbar.useDefaultCss diff --git a/modules/programs/media.nix b/modules/programs/media.nix index f05500d..6afa15e 100644 --- a/modules/programs/media.nix +++ b/modules/programs/media.nix @@ -94,7 +94,7 @@ zathura evince libreoffice-fresh - onlyoffice-bin + onlyoffice-desktopeditors pdftk pdfpc polylux2pdfpc diff --git a/modules/programs/stylix.nix b/modules/programs/stylix.nix index 124cc64..dd11e8c 100644 --- a/modules/programs/stylix.nix +++ b/modules/programs/stylix.nix @@ -91,7 +91,7 @@ in { }; emoji = { - package = pkgs.noto-fonts-emoji; + package = pkgs.noto-fonts-color-emoji; name = "Noto Color Emoji"; }; }; From bafff7242749556df20c67c3c24953cf11696d34 Mon Sep 17 00:00:00 2001 From: DashieTM Date: Sat, 1 Nov 2025 23:34:33 +0100 Subject: [PATCH 15/29] chore(docs): Update ISO instructions --- docs/src/README.md | 2 +- modules/programs/greetd.nix | 2 +- modules/programs/media.nix | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/src/README.md b/docs/src/README.md index 6ac856e..064cdd4 100644 --- a/docs/src/README.md +++ b/docs/src/README.md @@ -220,7 +220,7 @@ E.g. stable/hosts/yourserver and unstable/hosts/yourdesktop # Installation -You can find a custom ISO on my NextCloud server: [Link](https://cloud.dashie.org/s/z7G3zS9SXeEt2ERD). +You can find a custom ISO in the releases: [Link](https://github.com/Xetibo/DashNix/releases). With this, you will receive the example config in /iso/example alongside the gnome desktop environment, as well as a few tools like gnome-disks, Neovim, Vscodium, a browser etc. diff --git a/modules/programs/greetd.nix b/modules/programs/greetd.nix index 2c5f87f..5c68d7b 100644 --- a/modules/programs/greetd.nix +++ b/modules/programs/greetd.nix @@ -47,7 +47,7 @@ } --config /etc/greetd/hyprgreet.conf"; example = "${ lib.getExe pkgs.cage - } -s -- ${lib.getExe pkgs.greetd.regreet}"; + } -s -- ${lib.getExe pkgs.regreet}"; type = lib.types.str; description = "The compositor/greeter command to run"; }; diff --git a/modules/programs/media.nix b/modules/programs/media.nix index 6afa15e..e701fb1 100644 --- a/modules/programs/media.nix +++ b/modules/programs/media.nix @@ -39,7 +39,7 @@ filePickerPortal = lib.mkOption { default = "Term"; example = "Gnome"; - type = with lib.types; oneOf [(enum ["Gnome" "Kde" "Lxqt" "Gtk" "Term" "Default"]) string]; + type = with lib.types; oneOf [(enum ["Gnome" "Kde" "Lxqt" "Gtk" "Term" "Default"]) str]; description = '' The file picker portal to use (set with shana). Default removes the config, allowing you to set it yourself. From fe090a95bce087fa832207b0cdb927ab758431c6 Mon Sep 17 00:00:00 2001 From: DashieTM Date: Sun, 2 Nov 2025 21:51:56 +0100 Subject: [PATCH 16/29] chore(docs): Add instructions for experimental features on install --- docs/src/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/src/README.md b/docs/src/README.md index 064cdd4..6128784 100644 --- a/docs/src/README.md +++ b/docs/src/README.md @@ -239,17 +239,17 @@ Then configure as you please and choose a command below depending on your disk i Installation via manual configuration: ```sh -sudo nixos-install --flake # --root +sudo nixos-install --flake # --root --option experimental-features "nix-command flakes pipe-operators" #example -#nixos-install --flake ~/config#globi --root /mnt +#nixos-install --flake ~/config#globi --root /mnt --option experimental-features "nix-command flakes pipe-operators" ``` Installation via disko: ```sh -sudo disko-install --flake # --disk +sudo disko-install --flake # --disk --option experimental-features "nix-command flakes pipe-operators" #example -#disko-install -- --flake ~/config#globi --disk main /dev/nvme0n1 +#disko-install -- --flake ~/config#globi --disk main /dev/nvme0n1 --option experimental-features "nix-command flakes pipe-operators" ``` # Modules From 78a3247fb1b773a4cd542d6737ddfe5ad51f48cd Mon Sep 17 00:00:00 2001 From: DashieTM Date: Fri, 7 Nov 2025 17:19:29 +0100 Subject: [PATCH 17/29] chore(git): Update config --- modules/programs/git.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/programs/git.nix b/modules/programs/git.nix index bfcb334..57c1623 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -50,9 +50,14 @@ config = lib.optionalAttrs (options ? programs.git && options ? home.file) { programs.git = { enable = true; - userName = config.mods.git.username; - userEmail = config.mods.git.email; - extraConfig = config.mods.git.additionalConfig; + settings = + { + user = { + name = config.mods.git.username; + inherit (config.mods.git) email; + }; + } + // config.mods.git.additionalConfig; }; home.file.".ssh/config".text = config.mods.git.sshConfig; }; From 1aeb5de333bbccd6b9476d4732fc3831b1ca7afc Mon Sep 17 00:00:00 2001 From: DashieTM Date: Fri, 7 Nov 2025 17:53:21 +0100 Subject: [PATCH 18/29] chore(lutris): broken --- modules/programs/gaming.nix | 3 ++- modules/programs/gpu.nix | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/programs/gaming.nix b/modules/programs/gaming.nix index 6189cce..93c9414 100644 --- a/modules/programs/gaming.nix +++ b/modules/programs/gaming.nix @@ -19,7 +19,8 @@ gamescope gamemode steam - lutris + # TODO broken + # lutris wineWowPackages.stable adwsteamgtk heroic diff --git a/modules/programs/gpu.nix b/modules/programs/gpu.nix index 87305f0..023b462 100644 --- a/modules/programs/gpu.nix +++ b/modules/programs/gpu.nix @@ -91,8 +91,7 @@ (lib.mkIf (config.mods.gpu.intelgpu.enable || config.mods.gpu.amdgpu.enable) pkgs.mesa) ]; rocmPackages = [ - # TODO broken - #pkgs.rocmPackages.clr.icd + pkgs.rocmPackages.clr.icd pkgs.mesa pkgs.mesa.opencl pkgs.vulkan-loader From 0314b75a023d2cc41ec109fe33158e2fa6ac1d9a Mon Sep 17 00:00:00 2001 From: DashieTM Date: Mon, 10 Nov 2025 10:21:27 +0100 Subject: [PATCH 19/29] bugfix(logind): Ensure stable compatibility --- modules/programs/oxi/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/oxi/default.nix b/modules/programs/oxi/default.nix index 942d0d1..83c4f23 100644 --- a/modules/programs/oxi/default.nix +++ b/modules/programs/oxi/default.nix @@ -74,7 +74,7 @@ }; }; } - // lib.optionalAttrs (options ? services.logind) { + // lib.optionalAttrs (options ? services.logind && options ? services.logind.settings) { services.logind.settings.Login.HandleLidSwitchExternalPower = "ignore"; } ); From ac77341f62c3dbc6bd4ee61c7d09ef6e16184c7e Mon Sep 17 00:00:00 2001 From: DashieTM Date: Mon, 10 Nov 2025 11:27:23 +0100 Subject: [PATCH 20/29] bugfix(stylix): Ensure stable compatibility --- modules/programs/browser/zen.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/programs/browser/zen.nix b/modules/programs/browser/zen.nix index d3a9b0a..db32900 100644 --- a/modules/programs/browser/zen.nix +++ b/modules/programs/browser/zen.nix @@ -121,7 +121,7 @@ in { }; }; config = lib.mkIf (config.mods.browser.zen.enable || config.mods.homePackages.browser == "zen") ( - lib.optionalAttrs (options ? home.packages) { + (lib.optionalAttrs (options ? home.packages) { programs.zen-browser = { enable = true; package = @@ -149,7 +149,9 @@ in { }; profiles = builtins.listToAttrs config.mods.browser.zen.profiles; }; + }) + // (lib.optionalAttrs (options ? stylix.targets.zen-browser) { stylix.targets.zen-browser.profileNames = lib.map (profile: profile.name) config.mods.browser.zen.profiles; - } + }) ); } From 3731bd6366dde867812d31ff519ae4d98f18627a Mon Sep 17 00:00:00 2001 From: DashieTM Date: Mon, 10 Nov 2025 11:36:12 +0100 Subject: [PATCH 21/29] bugfix(regreet): Ensure stable compatibility --- modules/programs/homePackages.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/programs/homePackages.nix b/modules/programs/homePackages.nix index c987c94..ce57135 100644 --- a/modules/programs/homePackages.nix +++ b/modules/programs/homePackages.nix @@ -119,7 +119,11 @@ flake-checker gnome-keyring gnutar - regreet + ( + if (options ? regreet) + then regreet + else greetd.regreet + ) killall kitty libnotify From 39e4d182cec1a0c1133e278cb3594481e893434a Mon Sep 17 00:00:00 2001 From: DashieTM Date: Tue, 11 Nov 2025 15:33:10 +0100 Subject: [PATCH 22/29] bugfix(hyprland): Use proper flake url --- flake.nix | 2 +- modules/programs/greetd.nix | 3 ++- modules/programs/hypr/hyprland.nix | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 8033b24..be501b2 100644 --- a/flake.nix +++ b/flake.nix @@ -21,7 +21,7 @@ sops-nix.url = "github:Mic92/sops-nix"; - hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1"; + hyprland.url = "github:hyprwm/Hyprland"; ironbar = { url = "github:JakeStanger/ironbar"; diff --git a/modules/programs/greetd.nix b/modules/programs/greetd.nix index 5c68d7b..fb30782 100644 --- a/modules/programs/greetd.nix +++ b/modules/programs/greetd.nix @@ -5,6 +5,7 @@ inputs, pkgs, options, + system, ... }: { options.mods = { @@ -43,7 +44,7 @@ }; greeterCommand = lib.mkOption { default = "${ - lib.getExe pkgs.hyprland + lib.getExe inputs.hyprland.packages.${system}.hyprland } --config /etc/greetd/hyprgreet.conf"; example = "${ lib.getExe pkgs.cage diff --git a/modules/programs/hypr/hyprland.nix b/modules/programs/hypr/hyprland.nix index f32bc74..bd93fa1 100644 --- a/modules/programs/hypr/hyprland.nix +++ b/modules/programs/hypr/hyprland.nix @@ -241,7 +241,6 @@ in { defaultWindowRules; in { enable = true; - package = mkDashDefault pkgs.hyprland; plugins = [ (lib.mkIf config.mods.hypr.hyprland.hyprspaceEnable pkgs.hyprlandPlugins.hyprspace) From 2a245f9851f278b2acda018e9bb6936e3a793a4a Mon Sep 17 00:00:00 2001 From: DashieTM Date: Wed, 3 Dec 2025 21:34:39 +0100 Subject: [PATCH 23/29] chore(basePackages): Remove preload --- modules/programs/basePackages.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/programs/basePackages.nix b/modules/programs/basePackages.nix index fa10da8..1d1b2b9 100644 --- a/modules/programs/basePackages.nix +++ b/modules/programs/basePackages.nix @@ -87,7 +87,6 @@ if config.mods.basePackages.enable then { - preload.enable = mkDashDefault true; upower.enable = mkDashDefault true; dbus = { enable = mkDashDefault true; From f360e5459002956c243a070155dbd4e02c09b6cd Mon Sep 17 00:00:00 2001 From: DashieTM Date: Thu, 18 Dec 2025 14:23:18 +0100 Subject: [PATCH 24/29] chore(fcp): Replace with fuc --- modules/programs/fish.nix | 2 +- modules/programs/homePackages.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/programs/fish.nix b/modules/programs/fish.nix index f063f35..1d8c8c8 100644 --- a/modules/programs/fish.nix +++ b/modules/programs/fish.nix @@ -70,7 +70,7 @@ in { abbr --add cat 'bat' abbr --add find 'fd' abbr --add rm 'rip' - abbr --add cp 'fcp' + abbr --add cp 'cpz' abbr --add cd 'z' abbr --add y 'yazi' diff --git a/modules/programs/homePackages.nix b/modules/programs/homePackages.nix index ce57135..a8cbb11 100644 --- a/modules/programs/homePackages.nix +++ b/modules/programs/homePackages.nix @@ -136,7 +136,7 @@ pulseaudio libsForQt5.qt5ct qt6Packages.qt6ct - fcp + fuc ripgrep rm-improved system-config-printer From decd0f5110e5490735b68357ef1e01dce3ef6786 Mon Sep 17 00:00:00 2001 From: DashieTM Date: Thu, 18 Dec 2025 14:34:58 +0100 Subject: [PATCH 25/29] chore(cachy): Use external flake and drop chaotic-nyx --- base/common_hardware.nix | 5 ----- example/flake.nix | 2 -- flake.nix | 4 +--- lib/default.nix | 4 +--- lib/importPkgs.nix | 2 +- lib/wm.nix | 13 +++++-------- modules/programs/gaming.nix | 8 ++++---- modules/programs/greetd.nix | 1 + modules/programs/homePackages.nix | 6 +----- modules/programs/hypr/hyprland.nix | 3 ++- 10 files changed, 16 insertions(+), 32 deletions(-) diff --git a/base/common_hardware.nix b/base/common_hardware.nix index 8df238a..9f7ccf1 100644 --- a/base/common_hardware.nix +++ b/base/common_hardware.nix @@ -101,10 +101,6 @@ in { builders-use-substitutes = mkDashDefault true; - substituters = [ - "https://chaotic-nyx.cachix.org/" - ]; - trusted-substituters = [ "https://hyprland.cachix.org" "https://anyrun.cachix.org" @@ -128,7 +124,6 @@ in { "oxicalc.cachix.org-1:qF3krFc20tgSmtR/kt6Ku/T5QiG824z79qU5eRCSBTQ=" "hyprdock.cachix.org-1:HaROK3fBvFWIMHZau3Vq1TLwUoJE8yRbGLk0lEGzv3Y=" "reset.cachix.org-1:LfpnUUdG7QM/eOkN7NtA+3+4Ar/UBeYB+3WH+GjP9Xo=" - "chaotic-nyx.cachix.org-1:HfnXSw4pj95iI/n17rIDy40agHj12WfF+Gqk6SonIT8=" "dashvim.cachix.org-1:uLRdxp1WOWHnsZZtu3SwUWZRsvC7SXo0Gyk3tIefuL0=" ]; diff --git a/example/flake.nix b/example/flake.nix index 129fc20..01ec944 100644 --- a/example/flake.nix +++ b/example/flake.nix @@ -31,7 +31,6 @@ "https://oxicalc.cachix.org" "https://hyprdock.cachix.org" "https://reset.cachix.org" - "https://chaotic-nyx.cachix.org/" "https://dashvim.cachix.org" ]; @@ -46,7 +45,6 @@ "oxicalc.cachix.org-1:qF3krFc20tgSmtR/kt6Ku/T5QiG824z79qU5eRCSBTQ=" "hyprdock.cachix.org-1:HaROK3fBvFWIMHZau3Vq1TLwUoJE8yRbGLk0lEGzv3Y=" "reset.cachix.org-1:LfpnUUdG7QM/eOkN7NtA+3+4Ar/UBeYB+3WH+GjP9Xo=" - "chaotic-nyx.cachix.org-1:HfnXSw4pj95iI/n17rIDy40agHj12WfF+Gqk6SonIT8=" "dashvim.cachix.org-1:uLRdxp1WOWHnsZZtu3SwUWZRsvC7SXo0Gyk3tIefuL0=" ]; }; diff --git a/flake.nix b/flake.nix index be501b2..fbac7c1 100644 --- a/flake.nix +++ b/flake.nix @@ -18,6 +18,7 @@ url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "unstable"; }; + cachy.url = "github:xddxdd/nix-cachyos-kernel?rev=bb7b8aa687464f24dcd452354d9621331d6b0737"; sops-nix.url = "github:Mic92/sops-nix"; @@ -49,9 +50,6 @@ superfreq.url = "github:NotAShelf/superfreq"; - # absolute insanity - chaoticNyx.url = "github:chaotic-cx/nyx/nyxpkgs-unstable"; - compose.url = "github:garnix-io/nixos-compose"; }; diff --git a/lib/default.nix b/lib/default.nix index 0254ba2..265e43f 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -13,8 +13,8 @@ permittedInsecurePackages = permittedPackages; }; overlays = [ + inputs.cachy.overlays.default inputs.nur.overlays.default - inputs.chaoticNyx.overlays.cache-friendly ]; inherit system; }; @@ -76,7 +76,6 @@ in { ../base ../home ../modules - inputs.chaoticNyx.nixosModules.default ]; home = [ inputs.anyrun.homeManagerModules.default @@ -92,7 +91,6 @@ in { inputs.reset.homeManagerModules.default inputs.sops-nix.homeManagerModules.sops inputs.dashvim.homeManagerModules.dashvim - inputs.chaoticNyx.homeManagerModules.default ../modules ]; }, diff --git a/lib/importPkgs.nix b/lib/importPkgs.nix index 77e1299..cfcd413 100644 --- a/lib/importPkgs.nix +++ b/lib/importPkgs.nix @@ -12,6 +12,6 @@ import pkgs { }; overlays = [ inputs.nur.overlays.default - inputs.chaoticNyx.overlays.cache-friendly + inputs.cachy.overlays.default ]; } diff --git a/lib/wm.nix b/lib/wm.nix index a4bfd31..416956a 100644 --- a/lib/wm.nix +++ b/lib/wm.nix @@ -50,14 +50,11 @@ in { ]; hyprland = [ # window rules - "float,class:^(.*)(OxiCalc)(.*)$" - "float,class:^(.*)(winecfg.exe)(.*)$" - "float,class:^(.*)(copyq)(.*)$" - "center,class:^(.*)(swappy)(.*)$" - "workspace 10 silent,class:^(.*)(steam)(.*)$" - - # Otherwise neovide will ignore tiling - "suppressevent fullscreen maximize,class:^(.*)(neovide)(.*)$" + "match:class OxiCalc, float on" + "match:class winecfg.exe, float on" + "match:class copyq, float on" + "match:class swappy, center on" + "match:class steam, workspace 10 silent" ]; }; diff --git a/modules/programs/gaming.nix b/modules/programs/gaming.nix index 93c9414..a96d58c 100644 --- a/modules/programs/gaming.nix +++ b/modules/programs/gaming.nix @@ -34,10 +34,10 @@ description = "Install gaming related packages"; }; kernel = lib.mkOption { - default = true; - example = false; + default = false; + example = true; type = lib.types.bool; - description = "Whether to use the CachyOS kernel"; + description = "Whether to use the CachyOS kernel. WARNING: This is a manual compiled kernel!"; }; steam = lib.mkOption { default = true; @@ -109,7 +109,7 @@ config = lib.mkIf config.mods.gaming.enable ( lib.optionalAttrs (options ? environment.systemPackages) { environment.systemPackages = config.mods.gaming.tools; - boot.kernelPackages = lib.mkForce pkgs.linuxPackages_cachyos; + boot.kernelPackages = lib.mkForce pkgs.cachyosKernels.linuxPackages-cachyos-latest; services.scx = lib.mkIf (config.mods.gaming.scheduler != null) { enable = true; inherit (config.mods.gaming) scheduler; diff --git a/modules/programs/greetd.nix b/modules/programs/greetd.nix index fb30782..e717380 100644 --- a/modules/programs/greetd.nix +++ b/modules/programs/greetd.nix @@ -131,6 +131,7 @@ misc { disable_splash_rendering = false disable_hyprland_logo = true + disable_xdg_env_checks = true } env=STATE_DIR,var/cache/regreet diff --git a/modules/programs/homePackages.nix b/modules/programs/homePackages.nix index a8cbb11..6a995f0 100644 --- a/modules/programs/homePackages.nix +++ b/modules/programs/homePackages.nix @@ -119,11 +119,7 @@ flake-checker gnome-keyring gnutar - ( - if (options ? regreet) - then regreet - else greetd.regreet - ) + regreet killall kitty libnotify diff --git a/modules/programs/hypr/hyprland.nix b/modules/programs/hypr/hyprland.nix index bd93fa1..c8ac9ce 100644 --- a/modules/programs/hypr/hyprland.nix +++ b/modules/programs/hypr/hyprland.nix @@ -310,6 +310,7 @@ in { enable_swallow = mkDashDefault true; disable_splash_rendering = mkDashDefault true; disable_hyprland_logo = mkDashDefault true; + disable_xdg_env_checks = mkDashDefault true; swallow_regex = mkDashDefault "^(.*)(kitty)(.*)$"; initial_workspace_tracking = mkDashDefault 1; # just doesn't work @@ -334,7 +335,7 @@ in { layerrule = [ # layer rules # mainly to disable animations within slurp and grim - "noanim, selection" + "match:namespace selection, no_anim on" ]; workspace = mkWorkspace config.mods.wm.workspaces; From 512d6d2dd4832d835c4feb33e4dc36417acde6de Mon Sep 17 00:00:00 2001 From: DashieTM Date: Fri, 19 Dec 2025 12:58:17 +0100 Subject: [PATCH 26/29] chore(inputs): Modularize modules, inputs and update instructions --- docs/src/README.md | 171 +++++++++++++++++++++--------------- flake.nix | 15 ++++ home/default.nix | 8 +- lib/default.nix | 89 ++++++++++--------- modules/programs/gaming.nix | 6 +- 5 files changed, 168 insertions(+), 121 deletions(-) diff --git a/docs/src/README.md b/docs/src/README.md index 6128784..3658e00 100644 --- a/docs/src/README.md +++ b/docs/src/README.md @@ -23,6 +23,40 @@ dashNix = { You can then configure your systems in your flake outputs with a provided library command: +Please note that overriding inputs will invalidate the cache configuration, this means you will have to add this manually: + +```nix + builders-use-substitutes = true; + + extra-substituters = [ + "https://hyprland.cachix.org" + "https://anyrun.cachix.org" + "https://cache.garnix.io" + "https://oxipaste.cachix.org" + "https://oxinoti.cachix.org" + "https://oxishut.cachix.org" + "https://oxidash.cachix.org" + "https://oxicalc.cachix.org" + "https://hyprdock.cachix.org" + "https://reset.cachix.org" + "https://dashvim.cachix.org" + ]; + + extra-trusted-public-keys = [ + "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" + "anyrun.cachix.org-1:pqBobmOjI7nKlsUMV25u9QHa9btJK65/C8vnO3p346s=" + "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" + "oxipaste.cachix.org-1:n/oA3N3Z+LJP7eIWOwuoLd9QnPyZXqFjLgkahjsdDGc=" + "oxinoti.cachix.org-1:dvSoJl2Pjo5HMaNngdBbSaixK9BSf2N8gzjP2MdGvfc=" + "oxishut.cachix.org-1:axyAGF3XMh1IyMAW4UMbQCdMNovDH0KH6hqLLRJH8jU=" + "oxidash.cachix.org-1:5K2FNHp7AS8VF7LmQkJAUG/dm6UHCz4ngshBVbjFX30=" + "oxicalc.cachix.org-1:qF3krFc20tgSmtR/kt6Ku/T5QiG824z79qU5eRCSBTQ=" + "hyprdock.cachix.org-1:HaROK3fBvFWIMHZau3Vq1TLwUoJE8yRbGLk0lEGzv3Y=" + "reset.cachix.org-1:LfpnUUdG7QM/eOkN7NtA+3+4Ar/UBeYB+3WH+GjP9Xo=" + "dashvim.cachix.org-1:uLRdxp1WOWHnsZZtu3SwUWZRsvC7SXo0Gyk3tIefuL0=" + ]; +``` + ```nix nixosConfigurations = inputs.dashNix.dashNixLib.buildSystems { root = ./.; }; ``` @@ -96,29 +130,29 @@ Here is a minimal required configuration.nix (the TODOs mention a required chang # sddm = { }; # gdm = { }; drives = { - # default assumes ROOT, BOOT, HOME and SWAP labaled drives exist - # for an example without HOME see below - # defaultDrives.enable = false; - # extraDrives = [ - # { - # name = "boot"; - # drive = { - # device = "/dev/disk/by-label/BOOT"; - # fsType = "vfat"; - # options = [ "rw" "fmask=0022" "dmask=0022" "noatime" ]; - # }; - # } - # { - # name = ""; - # drive = { - # device = "/dev/disk/by-label/ROOT"; - # fsType = "ext4"; - # options = [ "noatime" "nodiratime" "discard" ]; - # }; - # } - # ]; - # You can also use disko to format your disks on installation. - # Please refer to the Documentation about the drives module for an example. + # default assumes ROOT, BOOT, HOME and SWAP labaled drives exist + # for an example without HOME see below + # defaultDrives.enable = false; + # extraDrives = [ + # { + # name = "boot"; + # drive = { + # device = "/dev/disk/by-label/BOOT"; + # fsType = "vfat"; + # options = [ "rw" "fmask=0022" "dmask=0022" "noatime" ]; + # }; + # } + # { + # name = ""; + # drive = { + # device = "/dev/disk/by-label/ROOT"; + # fsType = "ext4"; + # options = [ "noatime" "nodiratime" "discard" ]; + # }; + # } + # ]; + # You can also use disko to format your disks on installation. + # Please refer to the Documentation about the drives module for an example. }; }; } @@ -128,48 +162,14 @@ Here is a minimal required configuration.nix (the TODOs mention a required chang After logging in the first time, your password will be set to "firstlogin", please change this to whatever you like. -## Nixos and Home-manager Modules - -You can add additional modules or remove all of them by overriding parameters to the buildSystems command: - -```nix -nixosConfigurations = - let - additionalMods = { - nixos = [ - # your modules - ]; home = [ - # your modules - ]; - } - # passing this parameter will override the existing modules - mods = { - nixos = []; - home = []; - } - in - inputs.dashNix.dashNixLib.buildSystems { root = ./.; inherit mods additionalMods; }; -``` - -## Additional Inputs - -Just like modules, you can add additional inputs to your configuration. - -```nix -nixosConfigurations = - let - additionalInputs = { - something.url = "yoururl" - } - in - inputs.dashNix.dashNixLib.buildSystems { root = ./.; inherit additionalInputs; }; -``` - ## Configuring pkgs -While DashNix offers a default pkgs config, you may want to permit an unsecure packages or add an overlay to them. +While DashNix offers a default pkgs config, you may want to permit an unsecure packages, +add additional modules/inputs, or add an overlay to them. You can configure both stable and unstable pkgs the following way: +Please note that modules and inputs are merged together to ensure functionality. + ```nix currentSystem = "x86_64-linux"; permittedPackages = [ @@ -181,10 +181,21 @@ config = { allowUnfree = true; permittedInsecurePackages = permittedPackages; }; + inputs = { + # Some inputs + } + mods = { + home = [ + # Some home manager module + ]; + nixos = [ + # Some nixos module + ]; +} }; unstableBundle = { pkgs = inputs.unstable; - inherit config; + inherit config mods; }; inputs.dashNix.dashNixLib.buildSystems { root = ./.; @@ -201,24 +212,26 @@ this way however ensures you can also configure the inputs. Sometimes you want to differentiate between systems that are stable and unstable, e.g. for servers and desktops/laptops. This can be done with the overridePkgs flag for the lib function: +(overridePkgs simply inverts the default bundle that is used for the nix standard library as well as NixOS itself) + ```nix - nixosConfigurations = - inputs.dashNix.dashNixLib.buildSystems { - root = ./stable; - inherit additionalInputs; - overridePkgs = true; - } - // inputs.dashNix.dashNixLib.buildSystems { - root = ./unstable; - inherit additionalInputs; - }; +nixosConfigurations = + inputs.dashNix.dashNixLib.buildSystems { + root = ./stable; + inherit stableBundle; + overridePkgs = true; + } + // inputs.dashNix.dashNixLib.buildSystems { + inherit unstableBundle; + root = ./unstable; + }; ``` You can now place your systems in the respective directories. Keep in mind that the hosts directory will still need to exist in each variant. E.g. stable/hosts/yourserver and unstable/hosts/yourdesktop -# Installation +# Installation via ISO You can find a custom ISO in the releases: [Link](https://github.com/Xetibo/DashNix/releases). With this, you will receive the example config in /iso/example alongside the gnome desktop environment, @@ -252,6 +265,17 @@ sudo disko-install --flake # --disk Date: Fri, 19 Dec 2025 14:12:55 +0100 Subject: [PATCH 27/29] chore(lib): Add experimental standalone home-manager option --- lib/default.nix | 229 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 162 insertions(+), 67 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index 7d2c8f2..d8a7402 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -29,7 +29,160 @@ comnbinedConfig = config // {overlays = overlays ++ defaultConfig.overlays;}; in import pkgs comnbinedConfig; -in { +in rec { + mkNixos = { + root, + inputLib, + lib, + stablePkgs, + unstablePkgs, + stableMods, + unstableMods, + overridePkgs, + ... + }: + builtins.listToAttrs ( + map + (name: { + inherit name; + value = let + mod = root + /hosts/${name}/configuration.nix; + additionalNixosConfig = root + /hosts/${name}/hardware.nix; + additionalHomeConfig = root + /hosts/${name}/home.nix; + args = { + inherit + self + inputs + mod + additionalHomeConfig + system + root + dashNixAdditionalProps + lib + ; + stable = stablePkgs; + unstable = unstablePkgs; + pkgs = lib.mkForce ( + if overridePkgs + then stablePkgs + else unstablePkgs + ); + alternativePkgs = + if overridePkgs + then unstablePkgs + else stablePkgs; + hostName = name; + homeMods = + if overridePkgs + then unstableMods.home + else stableMods.home; + mkDashDefault = import ./override.nix {inherit lib;}; + }; + nixosMods = + if overridePkgs + then unstableMods.nixos + else stableMods.nixos; + in + inputLib.nixosSystem { + modules = + [ + {_module.args = args;} + mod + ] + ++ nixosMods + ++ lib.optional (builtins.pathExists additionalNixosConfig) additionalNixosConfig + ++ lib.optional (builtins.pathExists mod) mod; + }; + }) + ( + lib.lists.remove "" ( + lib.attrsets.mapAttrsToList (name: fType: + if fType == "directory" + then name + else "") ( + builtins.readDir (root + /hosts) + ) + ) + ) + ); + + mkHome = { + root, + lib, + stablePkgs, + unstablePkgs, + stableMods, + unstableMods, + overridePkgs, + ... + }: + builtins.listToAttrs ( + map + (name: { + inherit name; + value = let + mod = root + /homes/${name}/configuration.nix; + additionalHomeConfig = root + /homes/${name}/home.nix; + args = { + inherit + self + inputs + mod + additionalHomeConfig + system + root + dashNixAdditionalProps + lib + ; + stable = stablePkgs; + unstable = unstablePkgs; + pkgs = lib.mkForce ( + if overridePkgs + then stablePkgs + else unstablePkgs + ); + alternativePkgs = + if overridePkgs + then unstablePkgs + else stablePkgs; + userName = name; + mkDashDefault = import ./override.nix {inherit lib;}; + }; + homeMods = + if overridePkgs + then unstableMods.home + else stableMods.home; + in + inputs.home-manager.lib.homeManagerConfiguration + { + inherit (args) pkgs; + modules = + [ + {_module.args = args;} + mod + ] + ++ homeMods + ++ [ + ../home/common.nix + ../home/themes + ../home/sync.nix + ./foxwrappers.nix + ] + ++ lib.optional (builtins.pathExists mod) mod; + }; + }) + ( + lib.lists.remove "" ( + lib.attrsets.mapAttrsToList (name: fType: + if fType == "directory" + then name + else "") ( + builtins.readDir (root + /homes) + ) + ) + ) + ); + /* * # buildSystems @@ -58,7 +211,7 @@ in { # ); # in - buildSystems = { + buildFunc = func: { root, unstableBundle ? {}, stableBundle ? {}, @@ -118,73 +271,15 @@ in { pkgs = stableInput; config = stableConfig; }; - inputlib = unstableInput.lib; + inputLib = unstableInput.lib; inherit (unstablePkgs) lib; in - builtins.listToAttrs ( - map - (name: { - inherit name; - value = let - mod = root + /hosts/${name}/configuration.nix; - additionalNixosConfig = root + /hosts/${name}/hardware.nix; - additionalHomeConfig = root + /hosts/${name}/home.nix; - args = { - inherit - self - inputs - mod - additionalHomeConfig - system - root - dashNixAdditionalProps - lib - ; - stable = stablePkgs; - unstable = unstablePkgs; - pkgs = lib.mkForce ( - if overridePkgs - then stablePkgs - else unstablePkgs - ); - alternativePkgs = - if overridePkgs - then unstablePkgs - else stablePkgs; - hostName = name; - homeMods = - if overridePkgs - then unstableMods.home - else stableMods.home; - mkDashDefault = import ./override.nix {inherit lib;}; - }; - nixosMods = - if overridePkgs - then unstableMods.nixos - else stableMods.nixos; - in - inputlib.nixosSystem { - modules = - [ - {_module.args = args;} - mod - ] - ++ nixosMods - ++ lib.optional (builtins.pathExists additionalNixosConfig) additionalNixosConfig - ++ lib.optional (builtins.pathExists mod) mod; - }; - }) - ( - lib.lists.remove "" ( - lib.attrsets.mapAttrsToList (name: fType: - if fType == "directory" - then name - else "") ( - builtins.readDir (root + /hosts) - ) - ) - ) - ); + func { + inherit lib inputLib stablePkgs unstablePkgs stableMods unstableMods stableInputs unstableInputs root overridePkgs; + }; + + buildSystems = buildFunc mkNixos; + buildHome = buildFunc mkHome; buildIso = inputs.unstable.lib.nixosSystem { specialArgs = { From afaba29554356ed26a1efb361b8e97b447ed093d Mon Sep 17 00:00:00 2001 From: DashieTM Date: Fri, 19 Dec 2025 15:48:17 +0100 Subject: [PATCH 28/29] feature(clam): init --- home/default.nix | 2 + modules/programs/clam.nix | 60 ++++++++++++++++++++++++++++++ modules/programs/default.nix | 5 ++- modules/programs/greetd.nix | 1 + modules/programs/hypr/hyprland.nix | 1 + 5 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 modules/programs/clam.nix diff --git a/home/default.nix b/home/default.nix index 4fd4d99..afc0ab3 100644 --- a/home/default.nix +++ b/home/default.nix @@ -5,6 +5,7 @@ homeMods, inputs, lib, + additionalHomeConfig, mod, pkgs, root, @@ -58,6 +59,7 @@ ../lib/foxwrappers.nix ] ++ homeMods + ++ lib.optional (builtins.pathExists additionalHomeConfig) additionalHomeConfig ++ lib.optional (builtins.pathExists mod) mod; }; }; diff --git a/modules/programs/clam.nix b/modules/programs/clam.nix new file mode 100644 index 0000000..e212529 --- /dev/null +++ b/modules/programs/clam.nix @@ -0,0 +1,60 @@ +{ + lib, + config, + options, + pkgs, + ... +}: { + options.mods.clam = { + enable = lib.mkOption { + default = true; + example = false; + type = lib.types.bool; + description = "Enables the clamav program and its daemon"; + }; + scanner = { + enable = lib.mkOption { + default = false; + example = true; + type = lib.types.bool; + description = "Enables the clamav scanner"; + }; + interval = lib.mkOption { + type = lib.types.str; + default = "*-*-* 04:00:00"; + description = '' + How often clamdscan is invoked. + By default this runs using 10 cores at most, be sure to run it at a time of low traffic. + ''; + }; + scanDirectories = lib.mkOption { + type = with lib.types; listOf str; + default = [ + "/home" + "/var/lib" + "/tmp" + "/etc" + "/var/tmp" + ]; + description = ''List of directories to scan''; + }; + }; + }; + config = lib.mkIf config.mods.clam.enable ( + lib.optionalAttrs (options ? services.clamav) { + services.clamav = { + daemon.enable = true; + updater.enable = true; + scanner = { + inherit (config.mods.clam.scanner) enable; + inherit (config.mods.clam.scanner) interval; + inherit (config.mods.clam.scanner) scanDirectories; + }; + }; + environment.systemPackages = [ + pkgs.clamav + ]; + } + // lib.optionalAttrs (options ? home.packages) {home.packages = with pkgs; [clamtk];} + ); +} diff --git a/modules/programs/default.nix b/modules/programs/default.nix index 1c0baa5..08a4a2d 100644 --- a/modules/programs/default.nix +++ b/modules/programs/default.nix @@ -1,11 +1,11 @@ { imports = [ - ./niri.nix ./acpid.nix ./anyrun.nix ./basePackages.nix ./bluetooth.nix ./browser + ./clam.nix ./coding.nix ./containers.nix ./drives.nix @@ -31,6 +31,7 @@ ./mime.nix ./ncspot.nix ./nextcloud.nix + ./niri.nix ./onedrive.nix ./oxi ./piper.nix @@ -47,9 +48,9 @@ ./sway.nix ./teams.nix ./virtmanager.nix + ./wm.nix ./xkb.nix ./xone.nix - ./wm.nix ./yazi ]; } diff --git a/modules/programs/greetd.nix b/modules/programs/greetd.nix index e717380..fe3e455 100644 --- a/modules/programs/greetd.nix +++ b/modules/programs/greetd.nix @@ -132,6 +132,7 @@ disable_splash_rendering = false disable_hyprland_logo = true disable_xdg_env_checks = true + disable_scale_notification = true } env=STATE_DIR,var/cache/regreet diff --git a/modules/programs/hypr/hyprland.nix b/modules/programs/hypr/hyprland.nix index c8ac9ce..442b964 100644 --- a/modules/programs/hypr/hyprland.nix +++ b/modules/programs/hypr/hyprland.nix @@ -311,6 +311,7 @@ in { disable_splash_rendering = mkDashDefault true; disable_hyprland_logo = mkDashDefault true; disable_xdg_env_checks = mkDashDefault true; + disable_scale_notification = mkDashDefault true; swallow_regex = mkDashDefault "^(.*)(kitty)(.*)$"; initial_workspace_tracking = mkDashDefault 1; # just doesn't work From 15b48490baa2dfa0b222751c442208a7a984a9c3 Mon Sep 17 00:00:00 2001 From: DashieTM Date: Sat, 20 Dec 2025 14:41:57 +0100 Subject: [PATCH 29/29] chore(images): Swap to eog --- .github/workflows/docs.yaml | 60 ++++++++++------------------------ modules/programs/media.nix | 2 +- modules/programs/mime.nix | 2 +- modules/programs/yazi/yazi.nix | 2 +- 4 files changed, 21 insertions(+), 45 deletions(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 62524cb..06dc541 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -1,58 +1,34 @@ # by https://github.com/danth/stylix/blob/master/.github/workflows/docs.yml name: Docs - on: push: branches: - main - jobs: build: name: Build - permissions: contents: read - - runs-on: ubuntu-latest - + runs-on: nixos-latest steps: - - name: Install Nix - uses: DeterminateSystems/nix-installer-action@main - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - extra-conf: | - extra-experimental-features = nix-command flakes pipe-operators - - - name: Set up cache - uses: DeterminateSystems/magic-nix-cache-action@main - + - name: Nix Config + run: | + mkdir -p $HOME/.config + mkdir -p $HOME/.config/nix + echo experimental-features = nix-command flakes pipe-operators >> $HOME/.config/nix/nix.conf + echo access-tokens = github.com=${{ secrets.GITHUBTOKEN }} >> $HOME/.config/nix/nix.conf + nix profile install nixpkgs#nodejs - name: Build docs - run: nix -L build github:${{ github.repository }}/${{ github.sha }}#docs --no-write-lock-file - + run: nix -L build git+https://git.dashie.org/${{ forgejo.repository }}.git?rev=${{ forgejo.sha }}#docs --no-write-lock-file - name: Prepare docs for upload run: cp -r --dereference --no-preserve=mode,ownership result/ public/ - - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 + # - name: Upload artifact + # uses: https://data.forgejo.org/forgejo/upload-artifact@v4 + # with: + # path: public/ + - name: Publish Page + uses: https://data.forgejo.org/actions/git-pages@v2 with: - path: public/ - - deploy: - name: Deploy - - needs: build - - permissions: - pages: write - id-token: write - - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - - runs-on: ubuntu-latest - - steps: - - name: Deploy docs to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 + site: https://username.pages.dashie.org/reponame/ + token: ${{ forge.token }} + source: public/ diff --git a/modules/programs/media.nix b/modules/programs/media.nix index e701fb1..c37d62b 100644 --- a/modules/programs/media.nix +++ b/modules/programs/media.nix @@ -87,7 +87,7 @@ # audio control playerctl # images - imv + eog # videos mpv # pdf diff --git a/modules/programs/mime.nix b/modules/programs/mime.nix index 03d04d8..4da7aff 100644 --- a/modules/programs/mime.nix +++ b/modules/programs/mime.nix @@ -85,7 +85,7 @@ in { description = "Applications used for handling browser mime types"; }; imageApplications = lib.mkOption { - default = ["imv"]; + default = ["eog"]; example = []; type = with lib.types; listOf str; description = "Applications used for handling image mime types"; diff --git a/modules/programs/yazi/yazi.nix b/modules/programs/yazi/yazi.nix index 0a6aec6..22e3169 100644 --- a/modules/programs/yazi/yazi.nix +++ b/modules/programs/yazi/yazi.nix @@ -31,7 +31,7 @@ ]; image = [ { - run = ''imv "$@"''; + run = ''eog "$@"''; orphan = true; display_name = "Open"; }