From 82419f9b62caeec9348ee48cab73e986ec133064 Mon Sep 17 00:00:00 2001 From: Joshua Yuen Date: Sat, 26 Jul 2025 03:34:15 -0400 Subject: [PATCH] Add zsh module options --- hosts/vm/default.nix | 4 ++++ modules/core/user.nix | 11 ++++++++++- modules/home/zsh/default.nix | 8 ++++++-- modules/home/zsh/zshrc-personal.nix | 16 ++++++++++++---- modules/options/default.nix | 1 + modules/options/zsh.nix | 18 ++++++++++++++++++ 6 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 modules/options/zsh.nix diff --git a/hosts/vm/default.nix b/hosts/vm/default.nix index 830a185..dbbb98b 100644 --- a/hosts/vm/default.nix +++ b/hosts/vm/default.nix @@ -13,4 +13,8 @@ ]; modules.hyprland.enable = true; + modules.zsh = { + enable = false; + defaultShell = true; + }; } \ No newline at end of file diff --git a/modules/core/user.nix b/modules/core/user.nix index 1e7636e..b4b89f4 100644 --- a/modules/core/user.nix +++ b/modules/core/user.nix @@ -1,11 +1,17 @@ { + config, host, inputs, + lib, pkgs, profile, username, ... }: +with lib; +let + zshCfg = config.modules.zsh; +in { imports = [ inputs.home-manager.nixosModules.home-manager ]; home-manager = { @@ -30,7 +36,10 @@ extraGroups = [ "wheel" ]; - shell = pkgs.zsh; + shell = mkMerge [ + (mkIf (zshCfg.enable && zshCfg.defaultShell) pkgs.zsh) + (mkIf (!zshCfg.enable || !zshCfg.defaultShell) pkgs.bash) + ]; ignoreShellProgramCheck = true; }; diff --git a/modules/home/zsh/default.nix b/modules/home/zsh/default.nix index b58f5dd..105ab29 100644 --- a/modules/home/zsh/default.nix +++ b/modules/home/zsh/default.nix @@ -1,17 +1,21 @@ { - config, lib, + osConfig, pkgs, profile, ... }: +with lib; +let + cfg = osConfig.modules.zsh; +in { imports = [ ./zshrc-personal.nix ]; programs.zsh = { - enable = true; + enable = cfg.enable; autosuggestion.enable = true; syntaxHighlighting = { enable = true; diff --git a/modules/home/zsh/zshrc-personal.nix b/modules/home/zsh/zshrc-personal.nix index bee5a8b..333b0bc 100644 --- a/modules/home/zsh/zshrc-personal.nix +++ b/modules/home/zsh/zshrc-personal.nix @@ -1,11 +1,19 @@ { + lib, + osConfig, pkgs, ... }: +with lib; +let + cfg = osConfig.modules.zsh; +in { - home.packages = with pkgs; [zsh]; + config = mkIf cfg.enable { + home.packages = with pkgs; [ zsh ]; - home.file."./.zshrc-personal".text = '' - export EDITOR=vim - ''; + home.file."./.zshrc-personal".text = '' + export EDITOR=vim + ''; + }; } \ No newline at end of file diff --git a/modules/options/default.nix b/modules/options/default.nix index 86cd777..c648c53 100644 --- a/modules/options/default.nix +++ b/modules/options/default.nix @@ -4,5 +4,6 @@ { imports = [ ./hyprland.nix + ./zsh.nix ]; } \ No newline at end of file diff --git a/modules/options/zsh.nix b/modules/options/zsh.nix new file mode 100644 index 0000000..797ffde --- /dev/null +++ b/modules/options/zsh.nix @@ -0,0 +1,18 @@ +{ + config, + lib, + ... +}: +with lib; +let + cfg = config.modules.zsh; +in +{ + options.modules.zsh = { + enable = mkEnableOption "Install ZSH"; + defaultShell = mkEnableOption { + description = "Set ZSH as the default shell"; + default = true; + }; + }; +} \ No newline at end of file