From b36399875932f014e5eac013172061965cc96baf Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Thu, 30 Nov 2023 10:22:05 +0100 Subject: [PATCH] pinwheel: Add `enable` option for `zsh` module --- hosts/pinwheel/modules/default.nix | 1 + hosts/pinwheel/modules/zsh/default.nix | 117 ++++++++++++++----------- 2 files changed, 65 insertions(+), 53 deletions(-) diff --git a/hosts/pinwheel/modules/default.nix b/hosts/pinwheel/modules/default.nix index 2b31d0a..cb0aecf 100644 --- a/hosts/pinwheel/modules/default.nix +++ b/hosts/pinwheel/modules/default.nix @@ -19,6 +19,7 @@ in foot.enable = true; git.enable = true; + zsh.enable = true; openvpn.enable = true; go.enable = true; rust.enable = true; diff --git a/hosts/pinwheel/modules/zsh/default.nix b/hosts/pinwheel/modules/zsh/default.nix index 8241c8f..9e91717 100644 --- a/hosts/pinwheel/modules/zsh/default.nix +++ b/hosts/pinwheel/modules/zsh/default.nix @@ -1,59 +1,70 @@ -{ pkgs, lib, ... }: +{ pkgs, lib, config, ... }: +let + enabled = config.mod.zsh.enable; +in { - home-manager.users.alex = { - programs.zsh = { - enable = true; - - enableAutosuggestions = true; - enableCompletion = true; - defaultKeymap = "viins"; - - history = { - ignoreDups = true; - size = 100000; - save = 100000; - }; - - plugins = [ - { - name = "powerlevel10k"; - src = pkgs.zsh-powerlevel10k; - file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme"; - } - { - name = "zsh-syntax-highlighting"; - src = pkgs.zsh-syntax-highlighting; - } - { - name = "zsh-autosuggestions"; - src = pkgs.zsh-autosuggestions; - } - { - name = "zsh-syntax-completions"; - src = pkgs.zsh-completions; - } - { - name = "powerlevel10k-config"; - src = ./p10k-config; - file = "p10k.zsh"; - } - ]; - - envExtra = lib.strings.concatStringsSep "\n" [ - "BROWSER=firefox" - ]; - - initExtra = lib.strings.concatStringsSep "\n" [ - "export KEYTIMEOUT=1" - "bindkey -v '^?' backward-delete-char" - "bindkey '^a' beginning-of-line" - "bindkey '^e' end-of-line" - ]; + options = { + mod.zsh = { + enable = lib.mkEnableOption "enable zsh module"; }; }; - users.users.alex.shell = pkgs.zsh; + config = lib.mkIf enabled { + home-manager.users.alex = { + programs.zsh = { + enable = true; - programs.zsh.enable = true; - environment.pathsToLink = [ "/share/zsh" ]; + enableAutosuggestions = true; + enableCompletion = true; + defaultKeymap = "viins"; + + history = { + ignoreDups = true; + size = 100000; + save = 100000; + }; + + plugins = [ + { + name = "powerlevel10k"; + src = pkgs.zsh-powerlevel10k; + file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme"; + } + { + name = "zsh-syntax-highlighting"; + src = pkgs.zsh-syntax-highlighting; + } + { + name = "zsh-autosuggestions"; + src = pkgs.zsh-autosuggestions; + } + { + name = "zsh-syntax-completions"; + src = pkgs.zsh-completions; + } + { + name = "powerlevel10k-config"; + src = ./p10k-config; + file = "p10k.zsh"; + } + ]; + + envExtra = lib.strings.concatStringsSep "\n" [ + "BROWSER=firefox" + ]; + + initExtra = lib.strings.concatStringsSep "\n" [ + "export KEYTIMEOUT=1" + "bindkey -v '^?' backward-delete-char" + "bindkey '^a' beginning-of-line" + "bindkey '^e' end-of-line" + ]; + }; + }; + + users.users.alex.shell = pkgs.zsh; + + programs.zsh.enable = true; + environment.pathsToLink = [ "/share/zsh" ]; + }; }