From 39da2abe9c354597c623853c5f27db97a6f504bd Mon Sep 17 00:00:00 2001 From: Leonhard Kost Date: Tue, 27 Jan 2026 15:05:45 +0100 Subject: [PATCH] feat: make options and conditionalize config --- modules/home-manager/default.nix | 2 + modules/home-manager/hyprland.nix | 148 +++++++++++++----------- modules/home-manager/kitty.nix | 29 +++-- modules/home-manager/nixvim/default.nix | 25 ++-- modules/home-manager/rofi/default.nix | 70 ++++++----- modules/nixos/default.nix | 2 + modules/nixos/firefox.nix | 9 +- modules/nixos/hyprland.nix | 9 +- modules/nixos/ly.nix | 9 +- modules/options.nix | 18 +++ 10 files changed, 196 insertions(+), 125 deletions(-) create mode 100644 modules/options.nix diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix index 98bbcbe..acd9e70 100644 --- a/modules/home-manager/default.nix +++ b/modules/home-manager/default.nix @@ -1,5 +1,7 @@ { imports = [ + ../options.nix + ./git.nix ./fish.nix ./nixvim diff --git a/modules/home-manager/hyprland.nix b/modules/home-manager/hyprland.nix index f3c4ff3..ccf6105 100644 --- a/modules/home-manager/hyprland.nix +++ b/modules/home-manager/hyprland.nix @@ -1,80 +1,88 @@ -{ pkgs, ... }: { - home.packages = with pkgs; [ nordzy-cursor-theme ]; + config, + lib, + pkgs, + ... +}: +{ - programs.waybar.enable = true; + config = lib.mkIf config.kekleo.graphical { + home.packages = with pkgs; [ nordzy-cursor-theme ]; - wayland.windowManager.hyprland = - let - # workspaces - # binds $mod/alt + [shift +] {1..9} to [move to] workspace {1..9} - workspaces = builtins.concatLists ( - builtins.genList ( - i: - let - ws = toString (i + 1); - in - [ - "$mod,${ws},workspace,${ws}" - "ALT,${ws},workspace,${ws}" - "$mod SHIFT,${ws},movetoworkspace,${ws}" - "ALTSHIFT,${ws},movetoworkspace,${ws}" + programs.waybar.enable = true; + + wayland.windowManager.hyprland = + let + # workspaces + # binds $mod/alt + [shift +] {1..9} to [move to] workspace {1..9} + workspaces = builtins.concatLists ( + builtins.genList ( + i: + let + ws = toString (i + 1); + in + [ + "$mod,${ws},workspace,${ws}" + "ALT,${ws},workspace,${ws}" + "$mod SHIFT,${ws},movetoworkspace,${ws}" + "ALTSHIFT,${ws},movetoworkspace,${ws}" + ] + ) 9 + ); + in + { + enable = true; + package = pkgs.hyprland; + + xwayland.enable = true; + + settings = { + env = [ + "HYPRCURSOR_THEME,Nordzy-cursors" + "HYPRCURSOR_SIZE,26" + ]; + monitor = [ + ",1920x1080@60,0x0,1" + ]; + "$mod" = "SUPER"; + "$launcher" = "rofi -show drun"; + bind = [ + "ALTSHIFT,Q,killactive," + "ALT,V,togglefloating," + "ALT,F,fullscreen,1" + "ALTSHIFT,F,fullscreen,0" + "$mod,Return,exec,kitty" + "$mod,F,exec,firefox" + "$mod,R,exec,$launcher" + + "ALT,H,movefocus,l" + "ALT,L,movefocus,r" + "ALT,K,movefocus,u" + "ALT,J,movefocus,d" + "ALTSHIFT,H,movewindow,l" + "ALTSHIFT,L,movewindow,r" + "ALTSHIFT,K,movewindow,u" + "ALTSHIFT,J,movewindow,d" ] - ) 9 - ); - in - { - enable = true; - package = pkgs.hyprland; + ++ workspaces; - xwayland.enable = true; + windowrule = "bordersize 0, fullscreen:1"; - settings = { - env = [ - "HYPRCURSOR_THEME,Nordzy-cursors" - "HYPRCURSOR_SIZE,26" - ]; - monitor = [ - ",1920x1080@60,0x0,1" - ]; - "$mod" = "SUPER"; - "$launcher" = "rofi -show drun"; - bind = [ - "ALTSHIFT,Q,killactive," - "ALT,V,togglefloating," - "ALT,F,fullscreen,1" - "ALTSHIFT,F,fullscreen,0" - "$mod,Return,exec,kitty" - "$mod,F,exec,firefox" - "$mod,R,exec,$launcher" + general = { + gaps_in = 2; + gaps_out = 2; + "col.active_border" = "0xff888888"; + }; + animations.animation = [ + "windows,1,4,default" + "border,1,5,default" + "fadeIn,1,5,default" + "workspaces,1,3,default" + ]; - "ALT,H,movefocus,l" - "ALT,L,movefocus,r" - "ALT,K,movefocus,u" - "ALT,J,movefocus,d" - "ALTSHIFT,H,movewindow,l" - "ALTSHIFT,L,movewindow,r" - "ALTSHIFT,K,movewindow,u" - "ALTSHIFT,J,movewindow,d" - ] - ++ workspaces; - - windowrule = "bordersize 0, fullscreen:1"; - - general = { - gaps_in = 2; - gaps_out = 2; - "col.active_border" = "0xff888888"; + dwindle.force_split = 2; + cursor.no_warps = true; }; - animations.animation = [ - "windows,1,4,default" - "border,1,5,default" - "fadeIn,1,5,default" - "workspaces,1,3,default" - ]; - - dwindle.force_split = 2; - cursor.no_warps = true; }; - }; + }; } diff --git a/modules/home-manager/kitty.nix b/modules/home-manager/kitty.nix index f708855..8a86ed2 100644 --- a/modules/home-manager/kitty.nix +++ b/modules/home-manager/kitty.nix @@ -1,15 +1,22 @@ -{ pkgs, ... }: { - programs.kitty = { - enable = true; - themeFile = "tokyo_night_night"; - font = { - package = pkgs.nerd-fonts.jetbrains-mono; - name = "JetBrainsMono NF"; - size = 14; - }; - keybindings = { - "ctrl+alt+enter" = "launch --cwd=current"; + config, + lib, + pkgs, + ... +}: +{ + config = lib.mkIf config.kekleo.graphical { + programs.kitty = { + enable = true; + themeFile = "tokyo_night_night"; + font = { + package = pkgs.nerd-fonts.jetbrains-mono; + name = "JetBrainsMono NF"; + size = 14; + }; + keybindings = { + "ctrl+alt+enter" = "launch --cwd=current"; + }; }; }; } diff --git a/modules/home-manager/nixvim/default.nix b/modules/home-manager/nixvim/default.nix index 8e10bb3..534e886 100644 --- a/modules/home-manager/nixvim/default.nix +++ b/modules/home-manager/nixvim/default.nix @@ -1,3 +1,8 @@ +{ + config, + lib, + ... +}: { imports = [ ./opts.nix @@ -5,17 +10,19 @@ ./plugins ]; - programs.nixvim = { - enable = true; - viAlias = true; - vimAlias = true; - vimdiffAlias = true; - defaultEditor = true; + config = lib.mkIf config.kekleo.neovim { + programs.nixvim = { + enable = true; + viAlias = true; + vimAlias = true; + vimdiffAlias = true; + defaultEditor = true; - colorschemes.tokyonight.enable = true; + colorschemes.tokyonight.enable = true; - clipboard.providers.wl-copy.enable = true; + clipboard.providers.wl-copy.enable = true; - globals.mapleader = " "; + globals.mapleader = " "; + }; }; } diff --git a/modules/home-manager/rofi/default.nix b/modules/home-manager/rofi/default.nix index c7ef89d..b05898b 100644 --- a/modules/home-manager/rofi/default.nix +++ b/modules/home-manager/rofi/default.nix @@ -1,38 +1,44 @@ -{ ... }: { - programs.rofi = { - enable = true; - font = "JetBrainsMono Nerd Font 11"; - theme = ./tokyonight.rasi; - extraConfig = { - modi = [ - "drun" - "window" - "run" - ]; - icon-theme = "Papirus-Dark"; - show-icons = true; - terminal = "kitty"; - drun-display-format = "{icon} {name}"; - location = 0; - disable-history = false; - sidebar-mode = false; - display-drun = " "; - display-run = " "; - display-window = " "; + config, + lib, + ... +}: +{ + config = lib.mkIf config.kekleo.graphical { + programs.rofi = { + enable = true; + font = "JetBrainsMono Nerd Font 11"; + theme = ./tokyonight.rasi; + extraConfig = { + modi = [ + "drun" + "window" + "run" + ]; + icon-theme = "Papirus-Dark"; + show-icons = true; + terminal = "kitty"; + drun-display-format = "{icon} {name}"; + location = 0; + disable-history = false; + sidebar-mode = false; + display-drun = " "; + display-run = " "; + display-window = " "; - kb-row-up = "Up,Control+k"; - kb-row-left = "Left,Control+h"; - kb-row-right = "Right,Control+l"; - kb-row-down = "Down,Control+j"; + kb-row-up = "Up,Control+k"; + kb-row-left = "Left,Control+h"; + kb-row-right = "Right,Control+l"; + kb-row-down = "Down,Control+j"; - kb-accept-entry = "Return"; - # remove clashing keybinds - kb-remove-to-eol = ""; - kb-move-char-back = "Control+b"; - kb-remove-char-back = "BackSpace"; - kb-move-char-forward = "Control+f"; - kb-mode-complete = "Control+o"; + kb-accept-entry = "Return"; + # remove clashing keybinds + kb-remove-to-eol = ""; + kb-move-char-back = "Control+b"; + kb-remove-char-back = "BackSpace"; + kb-move-char-forward = "Control+f"; + kb-mode-complete = "Control+o"; + }; }; }; } diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index fc9ade2..0dfad01 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -1,5 +1,7 @@ { imports = [ + ../options.nix + ./fish.nix ./firefox.nix ./hyprland.nix diff --git a/modules/nixos/firefox.nix b/modules/nixos/firefox.nix index e3b556b..f396c45 100644 --- a/modules/nixos/firefox.nix +++ b/modules/nixos/firefox.nix @@ -1,3 +1,10 @@ { - programs.firefox.enable = true; + config, + lib, + ... +}: +{ + config = lib.mkIf config.kekleo.graphical { + programs.firefox.enable = true; + }; } diff --git a/modules/nixos/hyprland.nix b/modules/nixos/hyprland.nix index 98dfe35..a751783 100644 --- a/modules/nixos/hyprland.nix +++ b/modules/nixos/hyprland.nix @@ -1,3 +1,10 @@ { - programs.hyprland.enable = true; + config, + lib, + ... +}: +{ + config = lib.mkIf config.kekleo.graphical { + programs.hyprland.enable = true; + }; } diff --git a/modules/nixos/ly.nix b/modules/nixos/ly.nix index 2efa817..fd581f7 100644 --- a/modules/nixos/ly.nix +++ b/modules/nixos/ly.nix @@ -1,3 +1,10 @@ { - services.displayManager.ly.enable = true; + config, + lib, + ... +}: +{ + config = lib.mkIf config.kekleo.graphical { + services.displayManager.ly.enable = true; + }; } diff --git a/modules/options.nix b/modules/options.nix new file mode 100644 index 0000000..06bde43 --- /dev/null +++ b/modules/options.nix @@ -0,0 +1,18 @@ +{ + lib, + ... +}: +{ + options.kekleo = { + graphical = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Enable GUI features and programs"; + }; + neovim = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Enable neovim"; + }; + }; +}