From def1e23be848848400d1d097d4f044e3c401f9dd Mon Sep 17 00:00:00 2001 From: Weijia Wang <9713184+wegank@users.noreply.github.com> Date: Sun, 14 Apr 2024 23:02:32 +0200 Subject: treewide: remove lib.mdDoc --- modules/programs/zsh/default.nix | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'modules/programs/zsh') diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index cce645c..fb928d6 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -19,13 +19,13 @@ in programs.zsh.enable = mkOption { type = types.bool; default = false; - description = lib.mdDoc "Whether to configure zsh as an interactive shell."; + description = "Whether to configure zsh as an interactive shell."; }; programs.zsh.variables = mkOption { type = types.attrsOf (types.either types.str (types.listOf types.str)); default = {}; - description = lib.mdDoc '' + description = '' A set of environment variables used in the global environment. These variables will be set on shell initialisation. The value of each variable can be either a string or a list of @@ -38,44 +38,44 @@ in programs.zsh.shellInit = mkOption { type = types.lines; default = ""; - description = lib.mdDoc "Shell script code called during zsh shell initialisation."; + description = "Shell script code called during zsh shell initialisation."; }; programs.zsh.loginShellInit = mkOption { type = types.lines; default = ""; - description = lib.mdDoc "Shell script code called during zsh login shell initialisation."; + description = "Shell script code called during zsh login shell initialisation."; }; programs.zsh.interactiveShellInit = mkOption { type = types.lines; default = ""; - description = lib.mdDoc "Shell script code called during interactive zsh shell initialisation."; + description = "Shell script code called during interactive zsh shell initialisation."; }; programs.zsh.promptInit = mkOption { type = types.lines; default = "autoload -U promptinit && promptinit && prompt walters && setopt prompt_sp"; - description = lib.mdDoc "Shell script code used to initialise the zsh prompt."; + description = "Shell script code used to initialise the zsh prompt."; }; programs.zsh.enableCompletion = mkOption { type = types.bool; default = true; - description = lib.mdDoc "Enable zsh completion for all interactive zsh shells."; + description = "Enable zsh completion for all interactive zsh shells."; }; programs.zsh.enableBashCompletion = mkOption { type = types.bool; default = true; - description = lib.mdDoc "Enable bash completion for all interactive zsh shells."; + description = "Enable bash completion for all interactive zsh shells."; }; programs.zsh.enableGlobalCompInit = mkOption { type = types.bool; default = cfg.enableCompletion; defaultText = literalExpression "config.${opt.enableCompletion}"; - description = lib.mdDoc '' + description = '' Enable execution of compinit call for all interactive zsh shells. This option can be disabled if the user wants to extend its @@ -87,25 +87,25 @@ in programs.zsh.enableFzfCompletion = mkOption { type = types.bool; default = false; - description = lib.mdDoc "Enable fzf completion."; + description = "Enable fzf completion."; }; programs.zsh.enableFzfGit = mkOption { type = types.bool; default = false; - description = lib.mdDoc "Enable fzf keybindings for C-g git browsing."; + description = "Enable fzf keybindings for C-g git browsing."; }; programs.zsh.enableFzfHistory = mkOption { type = types.bool; default = false; - description = lib.mdDoc "Enable fzf keybinding for Ctrl-r history search."; + description = "Enable fzf keybinding for Ctrl-r history search."; }; programs.zsh.enableSyntaxHighlighting = mkOption { type = types.bool; default = false; - description = lib.mdDoc "Enable zsh-syntax-highlighting."; + description = "Enable zsh-syntax-highlighting."; }; }; -- cgit v1.2.3 From c8a8faedbc2ae80951fe4b5a92fb10de003d6aed Mon Sep 17 00:00:00 2001 From: Dominik Gleich Date: Mon, 20 May 2024 09:48:03 +0200 Subject: Change zsh default prompt --- modules/programs/zsh/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/programs/zsh') diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index fb928d6..bbf8ad9 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -55,7 +55,7 @@ in programs.zsh.promptInit = mkOption { type = types.lines; - default = "autoload -U promptinit && promptinit && prompt walters && setopt prompt_sp"; + default = "autoload -U promptinit && promptinit && prompt suse && setopt prompt_sp"; description = "Shell script code used to initialise the zsh prompt."; }; -- cgit v1.2.3 From 2839ef54aaaa0ca797659a1db45876260b93b1eb Mon Sep 17 00:00:00 2001 From: Trevor Opiyo Date: Wed, 20 Mar 2024 20:12:46 -0500 Subject: Add support for zsh-fast-syntax-highlighting --- modules/programs/zsh/default.nix | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'modules/programs/zsh') diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index bbf8ad9..c7ff47c 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -107,6 +107,12 @@ in default = false; description = "Enable zsh-syntax-highlighting."; }; + + programs.zsh.enableFastSyntaxHighlighting = mkOption { + type = types.bool; + default = false; + description = lib.mdDoc "Enable zsh-fast-syntax-highlighting."; + }; }; config = mkIf cfg.enable { @@ -115,7 +121,8 @@ in [ # Include zsh package pkgs.zsh ] ++ optional cfg.enableCompletion pkgs.nix-zsh-completions - ++ optional cfg.enableSyntaxHighlighting pkgs.zsh-syntax-highlighting; + ++ optional cfg.enableSyntaxHighlighting pkgs.zsh-syntax-highlighting + ++ optional cfg.enableFastSyntaxHighlighting pkgs.zsh-fast-syntax-highlighting; environment.pathsToLink = [ "/share/zsh" ]; @@ -196,6 +203,10 @@ in "source ${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" } + ${optionalString cfg.enableFastSyntaxHighlighting + "source ${pkgs.zsh-fast-syntax-highlighting}/share/zsh-fast-syntax-highlighting/zsh-fast-syntax-highlighting.zsh" + } + ${optionalString cfg.enableFzfCompletion "source ${fzfCompletion}"} ${optionalString cfg.enableFzfGit "source ${fzfGit}"} ${optionalString cfg.enableFzfHistory "source ${fzfHistory}"} -- cgit v1.2.3 From 44c88484c4c386f3eae8a5398e9b22a78d606e43 Mon Sep 17 00:00:00 2001 From: Trevor Opiyo Date: Wed, 29 May 2024 12:23:59 -0500 Subject: add warning for enabling syntax highlighting and fast syntax highlighting --- modules/programs/zsh/default.nix | 3 +++ 1 file changed, 3 insertions(+) (limited to 'modules/programs/zsh') diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index c7ff47c..d3b2f5c 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -117,6 +117,9 @@ in config = mkIf cfg.enable { + warnings = mkIf (cfg.enableFastSyntaxHighlighting && cfg.enableSyntaxHighlighting) [ + "zsh-fast-syntax-highlighting and zsh-syntax-highlighting are mutually exclusive. Disable one of them." + ]; environment.systemPackages = [ # Include zsh package pkgs.zsh -- cgit v1.2.3 From 4d59f660bc41ba35b1f6df829e8e0b7706b35ee7 Mon Sep 17 00:00:00 2001 From: Jan Malakhovski Date: Tue, 10 Sep 2024 21:35:35 +0200 Subject: zsh: move fpath init from /etc/zshrc to /etc/zshenv We want these to be set even when /etc/zshrc loading is disabled. NixOS/nixpkgs@f70e3f3738300ef1e94737c09364cd176893858f --- modules/programs/zsh/default.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'modules/programs/zsh') diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index bbf8ad9..15d5ba7 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -135,6 +135,11 @@ in . ${config.system.build.setEnvironment} fi + # Tell zsh how to find installed completions + for p in ''${(z)NIX_PROFILES}; do + fpath+=($p/share/zsh/site-functions $p/share/zsh/$ZSH_VERSION/functions $p/share/zsh/vendor-completions) + done + ${cfg.shellInit} # Read system-wide modifications. @@ -182,11 +187,6 @@ in ${config.environment.interactiveShellInit} ${cfg.interactiveShellInit} - # Tell zsh how to find installed completions - for p in ''${(z)NIX_PROFILES}; do - fpath+=($p/share/zsh/site-functions $p/share/zsh/$ZSH_VERSION/functions $p/share/zsh/vendor-completions) - done - ${cfg.promptInit} ${optionalString cfg.enableGlobalCompInit "autoload -U compinit && compinit"} -- cgit v1.2.3 From 15f64efcaf936f3b77955018d29b4802be6b144f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Reu=C3=9Fe?= Date: Tue, 10 Sep 2024 21:40:11 +0200 Subject: zsh: prefer Nix completions these from Zsh package Zsh ships some rudimentary completions for programs where upstream also ships their own completions (e.g., curl). So as not to shadow those completions, we need to prepend to the fpath instead of appending. NixOS/nixpkgs@8dad5a22399782a4ef681174219546cb050e580f --- modules/programs/zsh/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/programs/zsh') diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index 15d5ba7..58a3155 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -137,7 +137,7 @@ in # Tell zsh how to find installed completions for p in ''${(z)NIX_PROFILES}; do - fpath+=($p/share/zsh/site-functions $p/share/zsh/$ZSH_VERSION/functions $p/share/zsh/vendor-completions) + fpath=($p/share/zsh/site-functions $p/share/zsh/$ZSH_VERSION/functions $p/share/zsh/vendor-completions $fpath) done ${cfg.shellInit} -- cgit v1.2.3 From 7e6c548eef2372cef1287ef45350e29ca5740159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 11 Sep 2024 13:01:26 +0200 Subject: zsh: let children shells set their fpath Currently zshenv by default only sets fpath without exporting it. A parent shell would also not set those variables usually as they are shell local. It also sources a file called set-environment but this is protected by an environment variable called __NIX_DARWIN_SET_ENVIRONMENT_DONE. Hence any modification done by the parent shell should persist as long as __NIX_DARWIN_SET_ENVIRONMENT_DONE is not unset. This behavior deviates from what we do in bashrc and breaks common setups such as tmux/mosh or screen. NixOS/nixpkgs@55819e6c861f53450030eea832a76583a6786370 --- modules/programs/zsh/default.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'modules/programs/zsh') diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index 58a3155..1f36740 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -124,9 +124,8 @@ in # This file is read for all shells. # Only execute this file once per shell. - # But don't clobber the environment of interactive non-login children! if [ -n "$__ETC_ZSHENV_SOURCED" ]; then return; fi - export __ETC_ZSHENV_SOURCED=1 + __ETC_ZSHENV_SOURCED=1 # Don't execute this file when running in a pure nix-shell. if test -n "$IN_NIX_SHELL"; then return; fi -- cgit v1.2.3 From 6ad463a76421022de6762e6f50128febb970dcfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Reu=C3=9Fe?= Date: Wed, 11 Sep 2024 14:03:57 +0200 Subject: zsh: don't be noisy when scripts are run with -u When a script specifies the shell option "nounset" as part of the shebang (e.g., via "#!/usr/bin/env -S zsh -u"), our initialization scripts would produce error messages of the form: __ETC_FOO_SOURCED: parameter not set These messages could probably be confusing to users when running such scripts. By providing a fall-back in the parameter expansion, we can avoid them. This patch does not address interactive shell start-up, where such messages may (or may not) be less problematic. NixOS/nixpkgs@7d84dbdf5b91439f798363559310d86b21bfa86c --- modules/programs/zsh/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'modules/programs/zsh') diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index 1f36740..7574f8e 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -124,13 +124,13 @@ in # This file is read for all shells. # Only execute this file once per shell. - if [ -n "$__ETC_ZSHENV_SOURCED" ]; then return; fi + if [ -n "''${__ETC_ZSHENV_SOURCED-}" ]; then return; fi __ETC_ZSHENV_SOURCED=1 # Don't execute this file when running in a pure nix-shell. if test -n "$IN_NIX_SHELL"; then return; fi - if [ -z "$__NIX_DARWIN_SET_ENVIRONMENT_DONE" ]; then + if [ -z "''${__NIX_DARWIN_SET_ENVIRONMENT_DONE-}" ]; then . ${config.system.build.setEnvironment} fi @@ -152,7 +152,7 @@ in # This file is read for login shells. # Only execute this file once per shell. - if [ -n "$__ETC_ZPROFILE_SOURCED" ]; then return; fi + if [ -n "''${__ETC_ZPROFILE_SOURCED-}" ]; then return; fi __ETC_ZPROFILE_SOURCED=1 ${concatStringsSep "\n" zshVariables} -- cgit v1.2.3 From 953d02ba5958df017d9682f727d10a75cb8a0391 Mon Sep 17 00:00:00 2001 From: Antoine Cotten Date: Thu, 12 Sep 2024 17:37:56 +0000 Subject: {bash,zsh}: remove nix-shell early return in /etc/{bashrc,zshenv} The condition does not match the comment, and therefore not the original intention. It currently returns early in *any* type of Nix shell, not just pure ones, including 'nix develop'. Besides being unnecessary, this check prevents Nix shells from functioning properly. For instance, it causes the initialization of the Zsh fpath to be skipped, which is critical. The fact that the user is unable to opt out of this behaviour makes this an ever bigger problem since /etc/zshenv is being loaded unconditionally by Zsh. For reference, NixOS does not perform such check, and apparently never did. --- modules/programs/zsh/default.nix | 3 --- 1 file changed, 3 deletions(-) (limited to 'modules/programs/zsh') diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index 7574f8e..bfbfc59 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -127,9 +127,6 @@ in if [ -n "''${__ETC_ZSHENV_SOURCED-}" ]; then return; fi __ETC_ZSHENV_SOURCED=1 - # Don't execute this file when running in a pure nix-shell. - if test -n "$IN_NIX_SHELL"; then return; fi - if [ -z "''${__NIX_DARWIN_SET_ENVIRONMENT_DONE-}" ]; then . ${config.system.build.setEnvironment} fi -- cgit v1.2.3 From 470f87c1827b51169ed4f91cdbdfd48417bfff3d Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Thu, 31 Oct 2024 15:02:36 +1100 Subject: zsh: enable by default as zsh is the default shell on macOS Historically this was a footgun because users would not always have this enabled leading to `darwin-rebuild` and other programs not being found. --- modules/programs/zsh/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/programs/zsh') diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index bfbfc59..1665fcd 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -18,7 +18,7 @@ in options = { programs.zsh.enable = mkOption { type = types.bool; - default = false; + default = true; description = "Whether to configure zsh as an interactive shell."; }; -- cgit v1.2.3 From 897fc37c47d2592c475f8732f3f1a4fbc9f18f9e Mon Sep 17 00:00:00 2001 From: Trevor Opiyo Date: Tue, 5 Nov 2024 08:16:35 -0600 Subject: Update default.nix Co-authored-by: Michael Hoang --- modules/programs/zsh/default.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'modules/programs/zsh') diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index d3b2f5c..6555bac 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -117,8 +117,11 @@ in config = mkIf cfg.enable { - warnings = mkIf (cfg.enableFastSyntaxHighlighting && cfg.enableSyntaxHighlighting) [ - "zsh-fast-syntax-highlighting and zsh-syntax-highlighting are mutually exclusive. Disable one of them." + assertions = [ + { + assertion = !(cfg.enableSyntaxHighlighting && cfg.enableFastSyntaxHighlighting); + message = "zsh-syntax-highlighting and zsh-fast-syntax-highlighting are mutually exclusive, please disable one of them."; + } ]; environment.systemPackages = [ # Include zsh package -- cgit v1.2.3 From 48e5c8de1a4575441b46cb174afebfa02732c0ff Mon Sep 17 00:00:00 2001 From: Trevor Opiyo Date: Wed, 6 Nov 2024 01:10:24 -0600 Subject: Update modules/programs/zsh/default.nix Changes added by Enzime Co-authored-by: Michael Hoang --- modules/programs/zsh/default.nix | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'modules/programs/zsh') diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index 6555bac..652ba58 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -108,11 +108,7 @@ in description = "Enable zsh-syntax-highlighting."; }; - programs.zsh.enableFastSyntaxHighlighting = mkOption { - type = types.bool; - default = false; - description = lib.mdDoc "Enable zsh-fast-syntax-highlighting."; - }; + programs.zsh.enableFastSyntaxHighlighting = mkEnableOption "zsh-fast-syntax-highlighting"; }; config = mkIf cfg.enable { -- cgit v1.2.3 From 5fbb7b7637307c89e52d7e73ed6c848353bda6a0 Mon Sep 17 00:00:00 2001 From: Sam <30577766+Samasaur1@users.noreply.github.com> Date: Thu, 7 Nov 2024 20:29:35 -0800 Subject: zsh: only run shell initialization in /etc/zshenv when RCs are enabled --- modules/programs/zsh/default.nix | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'modules/programs/zsh') diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index a9ffbd8..c6ec917 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -136,16 +136,18 @@ in if [ -n "''${__ETC_ZSHENV_SOURCED-}" ]; then return; fi __ETC_ZSHENV_SOURCED=1 - if [ -z "''${__NIX_DARWIN_SET_ENVIRONMENT_DONE-}" ]; then - . ${config.system.build.setEnvironment} - fi + if [[ -o rcs ]]; then + if [ -z "''${__NIX_DARWIN_SET_ENVIRONMENT_DONE-}" ]; then + . ${config.system.build.setEnvironment} + fi - # Tell zsh how to find installed completions - for p in ''${(z)NIX_PROFILES}; do - fpath=($p/share/zsh/site-functions $p/share/zsh/$ZSH_VERSION/functions $p/share/zsh/vendor-completions $fpath) - done + # Tell zsh how to find installed completions + for p in ''${(z)NIX_PROFILES}; do + fpath=($p/share/zsh/site-functions $p/share/zsh/$ZSH_VERSION/functions $p/share/zsh/vendor-completions $fpath) + done - ${cfg.shellInit} + ${cfg.shellInit} + fi # Read system-wide modifications. if test -f /etc/zshenv.local; then -- cgit v1.2.3 From daf9d9fe5d5a7a5ef25aa446582f8c656aab2b9b Mon Sep 17 00:00:00 2001 From: Xingquan Liu Date: Tue, 17 Dec 2024 23:03:57 +0800 Subject: fix(zsh): correct the path of zsh-fast-syntax-highlighting --- modules/programs/zsh/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/programs/zsh') diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index c6ec917..65689ba 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -204,7 +204,7 @@ in } ${optionalString cfg.enableFastSyntaxHighlighting - "source ${pkgs.zsh-fast-syntax-highlighting}/share/zsh-fast-syntax-highlighting/zsh-fast-syntax-highlighting.zsh" + "source ${pkgs.zsh-fast-syntax-highlighting}/share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh" } ${optionalString cfg.enableFzfCompletion "source ${fzfCompletion}"} -- cgit v1.2.3