From 84ad11d543203695d7df9909bfe986cfd5bb4513 Mon Sep 17 00:00:00 2001 From: Martin Pander Date: Sat, 7 Feb 2026 14:23:51 +0100 Subject: [PATCH] Make config more configurable --- nix/README.md | 3 +- nix/hosts/home/common.nix | 22 ++++++ nix/hosts/home/nix/home.nix | 12 +-- nix/hosts/home/nixos/home.nix | 2 +- nix/hosts/work/common.nix | 25 ++++++ nix/hosts/work/nix/home.nix | 17 ++-- nix/hosts/work/nixos/home.nix | 21 +---- nix/modules/home/dev.nix | 55 +++++++++++-- nix/modules/home/llm.nix | 10 --- nix/modules/home/tmux.nix | 142 ++++++++++++++++++---------------- 10 files changed, 180 insertions(+), 129 deletions(-) create mode 100644 nix/hosts/home/common.nix create mode 100644 nix/hosts/work/common.nix delete mode 100644 nix/modules/home/llm.nix diff --git a/nix/README.md b/nix/README.md index 86553e9..06203f6 100644 --- a/nix/README.md +++ b/nix/README.md @@ -117,8 +117,7 @@ sudo nix-collect-garbage -d - **nvim.nix**: Personalized Neovim setup. - **tmux.nix**: Terminal multiplexer configuration. - **git.nix**: Git, Lazygit, and Jujutsu settings. -- **dev.nix**: Development tools and language runtimes. -- **llm.nix**: Local and API-based LLM tool configurations. +- **dev.nix**: Development tools, language runtimes, and LLM tool configurations. - **task.nix**: Taskwarrior and productivity tools. ### NixOS Modules (`modules/nixos/`) diff --git a/nix/hosts/home/common.nix b/nix/hosts/home/common.nix new file mode 100644 index 0000000..d0a39bf --- /dev/null +++ b/nix/hosts/home/common.nix @@ -0,0 +1,22 @@ +{ config, pkgs, ... }: + +{ + imports = [ + ../../modules/home/common.nix + ]; + + programs.git.settings.user = { + name = "Martin Pander"; + email = "git@pander-on.de"; + }; + + programs.jujutsu.settings.user = { + name = "Martin Pander"; + email = "git@pander-on.de"; + }; + + dot.llm = { + enable = true; + gemini-cli.enable = true; + }; +} diff --git a/nix/hosts/home/nix/home.nix b/nix/hosts/home/nix/home.nix index b3370ff..3776e83 100644 --- a/nix/hosts/home/nix/home.nix +++ b/nix/hosts/home/nix/home.nix @@ -2,21 +2,11 @@ { imports = [ - ../../../modules/home/common.nix + ../common.nix ]; home.username = "martin"; home.homeDirectory = "/Users/martin"; home.stateVersion = "24.05"; - - programs.git.settings.user = { - name = "Martin Pander"; - email = "git@pander-on.de"; - }; - - programs.jujutsu.settings.user = { - name = "Martin Pander"; - email = "git@pander-on.de"; - }; } diff --git a/nix/hosts/home/nixos/home.nix b/nix/hosts/home/nixos/home.nix index 3cb77d4..8ce0c4f 100644 --- a/nix/hosts/home/nixos/home.nix +++ b/nix/hosts/home/nixos/home.nix @@ -2,7 +2,7 @@ { imports = [ - ../../../modules/home/common.nix + ../common.nix ]; # User details diff --git a/nix/hosts/work/common.nix b/nix/hosts/work/common.nix new file mode 100644 index 0000000..9031385 --- /dev/null +++ b/nix/hosts/work/common.nix @@ -0,0 +1,25 @@ +{ config, pkgs, ... }: + +{ + imports = [ + ../../modules/home/common.nix + ]; + + programs.git.settings.user = { + name = "Martin Pander"; + email = "martin.pander@knowtion.de"; + }; + + programs.jujutsu.settings.user = { + name = "Martin Pander"; + email = "martin.pander@knowtion.de"; + }; + + dot.llm = { + enable = true; + claude-code.enable = true; + opencode.enable = true; + }; + + dot.tmux.workMode = true; +} diff --git a/nix/hosts/work/nix/home.nix b/nix/hosts/work/nix/home.nix index a6dd15d..1dfb128 100644 --- a/nix/hosts/work/nix/home.nix +++ b/nix/hosts/work/nix/home.nix @@ -2,25 +2,18 @@ { imports = [ - ../../../modules/home/common.nix - ../../../modules/home/llm.nix + ../common.nix ]; home.username = "pan"; home.homeDirectory = "/home/pan"; + home.packages = with pkgs; [ + nix-ld + ]; + home.stateVersion = "23.11"; - programs.git.settings.user = { - name = "Martin Pander"; - email = "martin.pander@knowtion.de"; - }; - - programs.jujutsu.settings.user = { - name = "Martin Pander"; - email = "martin.pander@knowtion.de"; - }; - programs.zsh.profileExtra = '' source $HOME/.profile ''; diff --git a/nix/hosts/work/nixos/home.nix b/nix/hosts/work/nixos/home.nix index fd36068..c74ae5c 100644 --- a/nix/hosts/work/nixos/home.nix +++ b/nix/hosts/work/nixos/home.nix @@ -2,30 +2,13 @@ { imports = [ - ../../../modules/home/common.nix + ../common.nix ]; # User details home.username = "pan"; home.homeDirectory = "/home/pan"; - # Git and Jujutsu user configuration - programs.git.settings.user = { - name = "Martin Pander"; - email = "martin.pander@knowtion.de"; - }; - - programs.jujutsu.settings.user = { - name = "Martin Pander"; - email = "martin.pander@knowtion.de"; - }; - - home.packages = with pkgs; [ - nix-ld - ]; - - # This value determines the Home Manager release which the configuration is - # compatible with. This helps avoid breakage when a new Home Manager release - # introduces backwards incompatible changes. + # Home Manager release version home.stateVersion = "25.05"; } \ No newline at end of file diff --git a/nix/modules/home/dev.nix b/nix/modules/home/dev.nix index 384df76..b9e4573 100644 --- a/nix/modules/home/dev.nix +++ b/nix/modules/home/dev.nix @@ -1,13 +1,52 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: +let + cfg = config.dot.llm; +in { - programs.direnv = { - enable = true; - enableZshIntegration = true; - nix-direnv.enable = true; + options.dot.llm = { + enable = lib.mkEnableOption "LLM tools"; + claude-code.enable = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Enable claude-code"; + }; + opencode.enable = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Enable opencode"; + }; + gemini-cli.enable = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Enable gemini-cli"; + }; + bubblewrap.enable = lib.mkOption { + type = lib.types.bool; + default = pkgs.stdenv.isLinux; + description = "Enable bubblewrap (Linux only)"; + }; }; - home.packages = with pkgs; [ - visidata + config = lib.mkMerge [ + { + programs.direnv = { + enable = true; + enableZshIntegration = true; + nix-direnv.enable = true; + }; + + home.packages = with pkgs; [ + visidata + ]; + } + + (lib.mkIf cfg.enable { + home.packages = + (lib.optional cfg.claude-code.enable pkgs.claude-code) ++ + (lib.optional cfg.opencode.enable pkgs.opencode) ++ + (lib.optional cfg.gemini-cli.enable pkgs.gemini-cli) ++ + (lib.optional (cfg.bubblewrap.enable && pkgs.stdenv.isLinux) pkgs.bubblewrap); + }) ]; -} +} \ No newline at end of file diff --git a/nix/modules/home/llm.nix b/nix/modules/home/llm.nix deleted file mode 100644 index 81493b0..0000000 --- a/nix/modules/home/llm.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ config, pkgs, ... }: - -{ - home.packages = with pkgs; [ - bubblewrap - claude-code - opencode - gemini-cli - ]; -} diff --git a/nix/modules/home/tmux.nix b/nix/modules/home/tmux.nix index 81774b0..71dba7b 100644 --- a/nix/modules/home/tmux.nix +++ b/nix/modules/home/tmux.nix @@ -1,73 +1,83 @@ { config, pkgs, lib, ... }: +let + cfg = config.dot.tmux; +in { - programs.tmux = { - enable = true; - shortcut = "a"; - mouse = true; - keyMode = "vi"; - escapeTime = 0; - terminal = "screen-256color"; - tmuxp.enable = true; - extraConfig = '' - set -g display-time 1500 - - unbind S - bind S command-prompt "switch -t %1" - - bind-key -n M-K switch-client -p - bind-key -n M-J switch-client -n - - bind-key -n M-L next-window - bind-key -n M-H previous-window - - bind '"' split-window -c "#{pane_current_path}" - bind % split-window -h -c "#{pane_current_path}" - bind c new-window -a -c "#{pane_current_path}" - - bind C-s display-popup -E "zsh ~/bin/tmuxp_selector.sh" - bind C-g display-popup -E -d "#{pane_current_path}" -xC -yC -w 95% -h 95% "lazygit" - bind C-t display-popup -E -xC -yC -w 95% -h 95% "tasksquire" - # Note: The following keybindings had hard-coded WSL paths that were removed. - # Adjust the paths below to match your NixOS environment: - # bind C-n display-popup -E -xC -yC -w 95% -h 95% -d "~/Documents/notes/Work/" "vim quick_notes.md" - # bind C-p display-popup -E -xC -yC -w 95% -h 95% -d "~/Documents/notes/Work/development/" "vim mbpr.md" - - ####################################### - # status line - ####################################### - set -g status-justify centre - - set -g status-left "#[bg=#808080,fg=#ffffff,bold] #S #[default]#[bg=#BCBCBC] #{-30:pane_title} " - set -g status-left-length 40 - - set -g status-right "#[bg=#BCBCBC] %H:%M #[bg=#808080,fg=#ffffff] %d.%m.%y " - - # setw -g window-status-format " #W#F " - # setw -g window-status-current-format " #W#F " - setw -g window-status-format " #W " - setw -g window-status-current-format " #W " - setw -g window-status-separator "" - - ####################################### - # colors, taken from vim-lucius - ####################################### - set -g status-style "bg=#DADADA,fg=#000000" - - setw -g window-status-style "bg=#BCBCBC,fg=#000000" - setw -g window-status-current-style "bg=#808080,fg=#ffffff" - - setw -g window-status-activity-style "bg=#AFD7AF,fg=#000000" - setw -g window-status-bell-style "bg=#AFD7AF,fg=#000000" - #setw -g window-status-content-style "bg=#AFD7AF,fg=#000000" - - set -g pane-active-border-style "bg=#eeeeee,fg=#006699" - set -g pane-border-style "bg=#eeeeee,fg=#999999" - ''; + options.dot.tmux = { + workMode = lib.mkEnableOption "work-specific tmux configuration"; }; - home.shellAliases = { - "o" = "tmuxp"; - "ol" = "tmuxp load"; + config = { + programs.tmux = { + enable = true; + shortcut = "a"; + mouse = true; + keyMode = "vi"; + escapeTime = 0; + terminal = "screen-256color"; + tmuxp.enable = true; + extraConfig = '' + set -g display-time 1500 + + unbind S + bind S command-prompt "switch -t %1" + + bind-key -n M-K switch-client -p + bind-key -n M-J switch-client -n + + bind-key -n M-L next-window + bind-key -n M-H previous-window + + bind '"' split-window -c "#{pane_current_path}" + bind % split-window -h -c "#{pane_current_path}" + bind c new-window -a -c "#{pane_current_path}" + + bind C-g display-popup -E -d "#{pane_current_path}" -xC -yC -w 95% -h 95% "lazygit" + bind C-t display-popup -E -xC -yC -w 95% -h 95% "tasksquire" + + ${lib.optionalString cfg.workMode '' + bind C-s display-popup -E "zsh ~/bin/tmuxp_selector.sh" + bind C-n display-popup -E -xC -yC -w 95% -h 95% -d "~/Documents/notes/Work/" "vim quick_notes.md" + bind C-p display-popup -E -xC -yC -w 95% -h 95% -d "~/Documents/notes/Work/development/" "vim mbpr.md" + ''} + + ####################################### + # status line + ####################################### + set -g status-justify centre + + set -g status-left "#[bg=#808080,fg=#ffffff,bold] #S #[default]#[bg=#BCBCBC] #{-30:pane_title} " + set -g status-left-length 40 + + set -g status-right "#[bg=#BCBCBC] %H:%M #[bg=#808080,fg=#ffffff] %d.%m.%y " + + # setw -g window-status-format " #W#F " + # setw -g window-status-current-format " #W#F " + setw -g window-status-format " #W " + setw -g window-status-current-format " #W " + setw -g window-status-separator "" + + ####################################### + # colors, taken from vim-lucius + ####################################### + set -g status-style "bg=#DADADA,fg=#000000" + + setw -g window-status-style "bg=#BCBCBC,fg=#000000" + setw -g window-status-current-style "bg=#808080,fg=#ffffff" + + setw -g window-status-activity-style "bg=#AFD7AF,fg=#000000" + setw -g window-status-bell-style "bg=#AFD7AF,fg=#000000" + #setw -g window-status-content-style "bg=#AFD7AF,fg=#000000" + + set -g pane-active-border-style "bg=#eeeeee,fg=#006699" + set -g pane-border-style "bg=#eeeeee,fg=#999999" + ''; + }; + + home.shellAliases = { + "o" = "tmuxp"; + "ol" = "tmuxp load"; + }; }; }