push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,111 @@
# Oh my ZSH {#module-programs-zsh-ohmyzsh}
[`oh-my-zsh`](https://ohmyz.sh/) is a framework to manage your [ZSH](https://www.zsh.org/)
configuration including completion scripts for several CLI tools or custom
prompt themes.
## Basic usage {#module-programs-oh-my-zsh-usage}
The module uses the `oh-my-zsh` package with all available
features. The initial setup using Nix expressions is fairly similar to the
configuration format of `oh-my-zsh`.
```nix
{
programs.zsh.ohMyZsh = {
enable = true;
plugins = [
"git"
"python"
"man"
];
theme = "agnoster";
};
}
```
For a detailed explanation of these arguments please refer to the
[`oh-my-zsh` docs](https://github.com/robbyrussell/oh-my-zsh/wiki).
The expression generates the needed configuration and writes it into your
`/etc/zshrc`.
## Custom additions {#module-programs-oh-my-zsh-additions}
Sometimes third-party or custom scripts such as a modified theme may be
needed. `oh-my-zsh` provides the
[`ZSH_CUSTOM`](https://github.com/robbyrussell/oh-my-zsh/wiki/Customization#overriding-internals)
environment variable for this which points to a directory with additional
scripts.
The module can do this as well:
```nix
{ programs.zsh.ohMyZsh.custom = "~/path/to/custom/scripts"; }
```
## Custom environments {#module-programs-oh-my-zsh-environments}
There are several extensions for `oh-my-zsh` packaged in
`nixpkgs`. One of them is
[nix-zsh-completions](https://github.com/spwhitt/nix-zsh-completions)
which bundles completion scripts and a plugin for `oh-my-zsh`.
Rather than using a single mutable path for `ZSH_CUSTOM`,
it's also possible to generate this path from a list of Nix packages:
```nix
{ pkgs, ... }:
{
programs.zsh.ohMyZsh.customPkgs = [
pkgs.nix-zsh-completions
# and even more...
];
}
```
Internally a single store path will be created using
`buildEnv`. Please refer to the docs of
[`buildEnv`](https://nixos.org/nixpkgs/manual/#sec-building-environment)
for further reference.
*Please keep in mind that this is not compatible with
`programs.zsh.ohMyZsh.custom` as it requires an immutable
store path while `custom` shall remain mutable! An
evaluation failure will be thrown if both `custom` and
`customPkgs` are set.*
## Package your own customizations {#module-programs-oh-my-zsh-packaging-customizations}
If third-party customizations (e.g. new themes) are supposed to be added to
`oh-my-zsh` there are several pitfalls to keep in mind:
- To comply with the default structure of `ZSH` the entire
output needs to be written to `$out/share/zsh.`
- Completion scripts are supposed to be stored at
`$out/share/zsh/site-functions`. This directory is part of the
[`fpath`](https://zsh.sourceforge.io/Doc/Release/Functions.html)
and the package should be compatible with pure `ZSH`
setups. The module will automatically link the contents of
`site-functions` to completions directory in the proper
store path.
- The `plugins` directory needs the structure
`pluginname/pluginname.plugin.zsh` as structured in the
[upstream repo.](https://github.com/robbyrussell/oh-my-zsh/tree/91b771914bc7c43dd7c7a43b586c5de2c225ceb7/plugins)
A derivation for `oh-my-zsh` may look like this:
```nix
{ stdenv, fetchFromGitHub }:
stdenv.mkDerivation rec {
name = "exemplary-zsh-customization-${version}";
version = "1.0.0";
src = fetchFromGitHub {
# path to the upstream repository
};
dontBuild = true;
installPhase = ''
mkdir -p $out/share/zsh/site-functions
cp {themes,plugins} $out/share/zsh
cp completions $out/share/zsh/site-functions
'';
}
```

View File

@@ -0,0 +1,166 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.zsh.ohMyZsh;
mkLinkFarmEntry =
name: dir:
let
env = pkgs.buildEnv {
name = "zsh-${name}-env";
paths = cfg.customPkgs;
pathsToLink = "/share/zsh/${dir}";
};
in
{
inherit name;
path = "${env}/share/zsh/${dir}";
};
mkLinkFarmEntry' = name: mkLinkFarmEntry name name;
custom =
if cfg.custom != null then
cfg.custom
else if builtins.length cfg.customPkgs == 0 then
null
else
pkgs.linkFarm "oh-my-zsh-custom" [
(mkLinkFarmEntry' "themes")
(mkLinkFarmEntry "completions" "site-functions")
(mkLinkFarmEntry' "plugins")
];
in
{
imports = [
(lib.mkRenamedOptionModule
[ "programs" "zsh" "oh-my-zsh" "enable" ]
[ "programs" "zsh" "ohMyZsh" "enable" ]
)
(lib.mkRenamedOptionModule
[ "programs" "zsh" "oh-my-zsh" "theme" ]
[ "programs" "zsh" "ohMyZsh" "theme" ]
)
(lib.mkRenamedOptionModule
[ "programs" "zsh" "oh-my-zsh" "custom" ]
[ "programs" "zsh" "ohMyZsh" "custom" ]
)
(lib.mkRenamedOptionModule
[ "programs" "zsh" "oh-my-zsh" "plugins" ]
[ "programs" "zsh" "ohMyZsh" "plugins" ]
)
];
options = {
programs.zsh.ohMyZsh = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Enable oh-my-zsh.
'';
};
package = lib.mkPackageOption pkgs "oh-my-zsh" { };
plugins = lib.mkOption {
default = [ ];
type = lib.types.listOf (lib.types.str);
description = ''
List of oh-my-zsh plugins
'';
};
custom = lib.mkOption {
default = null;
type = with lib.types; nullOr str;
description = ''
Path to a custom oh-my-zsh package to override config of oh-my-zsh.
(Can't be used along with `customPkgs`).
'';
};
customPkgs = lib.mkOption {
default = [ ];
type = lib.types.listOf lib.types.package;
description = ''
List of custom packages that should be loaded into `oh-my-zsh`.
'';
};
theme = lib.mkOption {
default = "";
type = lib.types.str;
description = ''
Name of the theme to be used by oh-my-zsh.
'';
};
cacheDir = lib.mkOption {
default = "$HOME/.cache/oh-my-zsh";
type = lib.types.str;
description = ''
Cache directory to be used by `oh-my-zsh`.
Without this option it would default to the read-only nix store.
'';
};
preLoaded = lib.mkOption {
type = lib.types.lines;
default = "";
description = ''
Shell commands executed before the `oh-my-zsh` is loaded.
For example, to disable async git prompt write `zstyle ':omz:alpha:lib:git' async-prompt no` (more information <https://github.com/ohmyzsh/ohmyzsh?tab=readme-ov-file#async-git-prompt>)
'';
};
};
};
config = lib.mkIf cfg.enable {
# Prevent zsh from overwriting oh-my-zsh's prompt
programs.zsh.promptInit = lib.mkDefault "";
environment.systemPackages = [ cfg.package ];
programs.zsh.interactiveShellInit = ''
# oh-my-zsh configuration generated by NixOS
export ZSH=${cfg.package}/share/oh-my-zsh
${lib.optionalString (
builtins.length (cfg.plugins) > 0
) "plugins=(${builtins.concatStringsSep " " cfg.plugins})"}
${lib.optionalString (custom != null) "ZSH_CUSTOM=\"${custom}\""}
${lib.optionalString (builtins.stringLength (cfg.theme) > 0) "ZSH_THEME=\"${cfg.theme}\""}
${lib.optionalString (cfg.cacheDir != null) ''
if [[ ! -d "${cfg.cacheDir}" ]]; then
mkdir -p "${cfg.cacheDir}"
fi
ZSH_CACHE_DIR=${cfg.cacheDir}
''}
${cfg.preLoaded}
source $ZSH/oh-my-zsh.sh
'';
assertions = [
{
assertion = cfg.custom != null -> cfg.customPkgs == [ ];
message = "If `cfg.custom` is set for `ZSH_CUSTOM`, `customPkgs` can't be used!";
}
];
};
meta.doc = ./oh-my-zsh.md;
}

View File

@@ -0,0 +1,42 @@
# Stolen from ArchWiki
# create a zkbd compatible hash;
# to add other keys to this hash, see: man 5 terminfo
typeset -A key
key[Home]=${terminfo[khome]}
key[End]=${terminfo[kend]}
key[Insert]=${terminfo[kich1]}
key[Delete]=${terminfo[kdch1]}
key[Up]=${terminfo[kcuu1]}
key[Down]=${terminfo[kcud1]}
key[Left]=${terminfo[kcub1]}
key[Right]=${terminfo[kcuf1]}
key[PageUp]=${terminfo[kpp]}
key[PageDown]=${terminfo[knp]}
# setup key accordingly
[[ -n "${key[Home]}" ]] && bindkey "${key[Home]}" beginning-of-line
[[ -n "${key[End]}" ]] && bindkey "${key[End]}" end-of-line
[[ -n "${key[Insert]}" ]] && bindkey "${key[Insert]}" overwrite-mode
[[ -n "${key[Delete]}" ]] && bindkey "${key[Delete]}" delete-char
[[ -n "${key[Up]}" ]] && bindkey "${key[Up]}" up-line-or-history
[[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" down-line-or-history
[[ -n "${key[Left]}" ]] && bindkey "${key[Left]}" backward-char
[[ -n "${key[Right]}" ]] && bindkey "${key[Right]}" forward-char
[[ -n "${key[PageUp]}" ]] && bindkey "${key[PageUp]}" beginning-of-buffer-or-history
[[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" end-of-buffer-or-history
# Finally, make sure the terminal is in application mode, when zle is
# active. Only then are the values from $terminfo valid.
if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
function zle-line-init () {
printf '%s' "${terminfo[smkx]}"
}
function zle-line-finish () {
printf '%s' "${terminfo[rmkx]}"
}
zle -N zle-line-init
zle -N zle-line-finish
fi

View File

@@ -0,0 +1,24 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.zsh.zsh-autoenv;
in
{
options = {
programs.zsh.zsh-autoenv = {
enable = lib.mkEnableOption "zsh-autoenv";
package = lib.mkPackageOption pkgs "zsh-autoenv" { };
};
};
config = lib.mkIf cfg.enable {
programs.zsh.interactiveShellInit = ''
source ${cfg.package}/share/zsh-autoenv/autoenv.zsh
'';
};
}

View File

@@ -0,0 +1,87 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.programs.zsh.autosuggestions;
in
{
imports = [
(lib.mkRenamedOptionModule
[ "programs" "zsh" "enableAutosuggestions" ]
[ "programs" "zsh" "autosuggestions" "enable" ]
)
];
options.programs.zsh.autosuggestions = {
enable = lib.mkEnableOption "zsh-autosuggestions";
highlightStyle = lib.mkOption {
type = lib.types.str;
default = "fg=8"; # https://github.com/zsh-users/zsh-autosuggestions/tree/v0.4.3#suggestion-highlight-style
description = "Highlight style for suggestions ({fore,back}ground color)";
example = "fg=cyan";
};
strategy = lib.mkOption {
type = lib.types.listOf (
lib.types.enum [
"history"
"completion"
"match_prev_cmd"
]
);
default = [ "history" ];
description = ''
`ZSH_AUTOSUGGEST_STRATEGY` is an array that specifies how suggestions should be generated.
The strategies in the array are tried successively until a suggestion is found.
There are currently three built-in strategies to choose from:
- `history`: Chooses the most recent match from history.
- `completion`: Chooses a suggestion based on what tab-completion would suggest. (requires `zpty` module)
- `match_prev_cmd`: Like `history`, but chooses the most recent match whose preceding history item matches
the most recently executed command. Note that this strategy won't work as expected with ZSH options that
don't preserve the history order such as `HIST_IGNORE_ALL_DUPS` or `HIST_EXPIRE_DUPS_FIRST`.
'';
};
async = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Whether to fetch suggestions asynchronously";
example = false;
};
extraConfig = lib.mkOption {
type = lib.types.attrsOf lib.types.str;
default = { };
description = "Attribute set with additional configuration values";
example = lib.literalExpression ''
{
"ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE" = "20";
}
'';
};
};
config = lib.mkIf cfg.enable {
programs.zsh.interactiveShellInit = ''
source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh
export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="${cfg.highlightStyle}"
export ZSH_AUTOSUGGEST_STRATEGY=(${builtins.concatStringsSep " " cfg.strategy})
${lib.optionalString (!cfg.async) "unset ZSH_AUTOSUGGEST_USE_ASYNC"}
${builtins.concatStringsSep "\n" (
lib.mapAttrsToList (key: value: ''export ${key}="${value}"'') cfg.extraConfig
)}
'';
};
}

View File

@@ -0,0 +1,128 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.zsh.syntaxHighlighting;
in
{
imports = [
(lib.mkRenamedOptionModule
[ "programs" "zsh" "enableSyntaxHighlighting" ]
[ "programs" "zsh" "syntaxHighlighting" "enable" ]
)
(lib.mkRenamedOptionModule
[ "programs" "zsh" "syntax-highlighting" "enable" ]
[ "programs" "zsh" "syntaxHighlighting" "enable" ]
)
(lib.mkRenamedOptionModule
[ "programs" "zsh" "syntax-highlighting" "highlighters" ]
[ "programs" "zsh" "syntaxHighlighting" "highlighters" ]
)
(lib.mkRenamedOptionModule
[ "programs" "zsh" "syntax-highlighting" "patterns" ]
[ "programs" "zsh" "syntaxHighlighting" "patterns" ]
)
];
options = {
programs.zsh.syntaxHighlighting = {
enable = lib.mkEnableOption "zsh-syntax-highlighting";
highlighters = lib.mkOption {
default = [ "main" ];
# https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
type = lib.types.listOf (
lib.types.enum [
"main"
"brackets"
"pattern"
"cursor"
"regexp"
"root"
"line"
]
);
description = ''
Specifies the highlighters to be used by zsh-syntax-highlighting.
The following defined options can be found here:
https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
'';
};
patterns = lib.mkOption {
default = { };
type = lib.types.attrsOf lib.types.str;
example = lib.literalExpression ''
{
"rm -rf *" = "fg=white,bold,bg=red";
}
'';
description = ''
Specifies custom patterns to be highlighted by zsh-syntax-highlighting.
Please refer to the docs for more information about the usage:
https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/pattern.md
'';
};
styles = lib.mkOption {
default = { };
type = lib.types.attrsOf lib.types.str;
example = lib.literalExpression ''
{
"alias" = "fg=magenta,bold";
}
'';
description = ''
Specifies custom styles to be highlighted by zsh-syntax-highlighting.
Please refer to the docs for more information about the usage:
https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/main.md
'';
};
};
};
config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.zsh-syntax-highlighting ];
assertions = [
{
assertion =
builtins.length (builtins.attrNames cfg.patterns) > 0 -> builtins.elem "pattern" cfg.highlighters;
message = ''
When highlighting patterns, "pattern" needs to be included in the list of highlighters.
'';
}
];
programs.zsh.interactiveShellInit = lib.mkAfter (
lib.concatStringsSep "\n" (
[
"source ${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
]
++ lib.optional (
builtins.length (cfg.highlighters) > 0
) "ZSH_HIGHLIGHT_HIGHLIGHTERS=(${builtins.concatStringsSep " " cfg.highlighters})"
++ lib.optionals (builtins.length (builtins.attrNames cfg.patterns) > 0) (
lib.mapAttrsToList (
pattern: design: "ZSH_HIGHLIGHT_PATTERNS+=('${pattern}' '${design}')"
) cfg.patterns
)
++ lib.optionals (builtins.length (builtins.attrNames cfg.styles) > 0) (
lib.mapAttrsToList (styles: design: "ZSH_HIGHLIGHT_STYLES[${styles}]='${design}'") cfg.styles
)
)
);
};
}

View File

@@ -0,0 +1,325 @@
# This module defines global configuration for the zshell.
{
config,
lib,
options,
pkgs,
...
}:
let
cfge = config.environment;
cfg = config.programs.zsh;
opt = options.programs.zsh;
zshAliases = builtins.concatStringsSep "\n" (
lib.mapAttrsToList (k: v: "alias -- ${k}=${lib.escapeShellArg v}") (
lib.filterAttrs (k: v: v != null) cfg.shellAliases
)
);
zshStartupNotes = ''
# Note that generated /etc/zprofile and /etc/zshrc files do a lot of
# non-standard setup to make zsh usable with no configuration by default.
#
# Which means that unless you explicitly meticulously override everything
# generated, interactions between your ~/.zshrc and these files are likely
# to be rather surprising.
#
# Note however, that you can disable loading of the generated /etc/zprofile
# and /etc/zshrc (you can't disable loading of /etc/zshenv, but it is
# designed to not set anything surprising) by setting `no_global_rcs` option
# in ~/.zshenv:
#
# echo setopt no_global_rcs >> ~/.zshenv
#
# See "STARTUP/SHUTDOWN FILES" section of zsh(1) for more info.
'';
in
{
options = {
programs.zsh = {
enable = lib.mkOption {
default = false;
description = ''
Whether to configure zsh as an interactive shell. To enable zsh for
a particular user, use the {option}`users.users.<name?>.shell`
option for that user. To enable zsh system-wide use the
{option}`users.defaultUserShell` option.
'';
type = lib.types.bool;
};
shellAliases = lib.mkOption {
default = { };
description = ''
Set of aliases for zsh shell, which overrides {option}`environment.shellAliases`.
See {option}`environment.shellAliases` for an option format description.
'';
type = with lib.types; attrsOf (nullOr (either str path));
};
shellInit = lib.mkOption {
default = "";
description = ''
Shell script code called during zsh shell initialisation.
'';
type = lib.types.lines;
};
loginShellInit = lib.mkOption {
default = "";
description = ''
Shell script code called during zsh login shell initialisation.
'';
type = lib.types.lines;
};
interactiveShellInit = lib.mkOption {
default = "";
description = ''
Shell script code called during interactive zsh shell initialisation.
'';
type = lib.types.lines;
};
promptInit = lib.mkOption {
default = ''
# Note that to manually override this in ~/.zshrc you should run `prompt off`
# before setting your PS1 and etc. Otherwise this will likely to interact with
# your ~/.zshrc configuration in unexpected ways as the default prompt sets
# a lot of different prompt variables.
autoload -U promptinit && promptinit && prompt suse && setopt prompt_sp
'';
description = ''
Shell script code used to initialise the zsh prompt.
'';
type = lib.types.lines;
};
histSize = lib.mkOption {
default = 2000;
description = ''
Change history size.
'';
type = lib.types.int;
};
histFile = lib.mkOption {
default = "$HOME/.zsh_history";
description = ''
Change history file.
'';
type = lib.types.str;
};
setOptions = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [
"HIST_IGNORE_DUPS"
"SHARE_HISTORY"
"HIST_FCNTL_LOCK"
];
example = [
"EXTENDED_HISTORY"
"RM_STAR_WAIT"
];
description = ''
Configure zsh options. See
{manpage}`zshoptions(1)`.
'';
};
enableCompletion = lib.mkOption {
default = true;
description = ''
Enable zsh completion for all interactive zsh shells.
'';
type = lib.types.bool;
};
enableBashCompletion = lib.mkOption {
default = false;
description = ''
Enable compatibility with bash's programmable completion system.
'';
type = lib.types.bool;
};
enableGlobalCompInit = lib.mkOption {
default = cfg.enableCompletion;
defaultText = lib.literalExpression "config.${opt.enableCompletion}";
description = ''
Enable execution of compinit call for all interactive zsh shells.
This option can be disabled if the user wants to extend its
`fpath` and a custom `compinit`
call in the local config is required.
'';
type = lib.types.bool;
};
enableLsColors = lib.mkOption {
default = true;
description = ''
Enable extra colors in directory listings (used by `ls` and `tree`).
'';
type = lib.types.bool;
};
};
};
config = lib.mkIf cfg.enable {
programs.zsh.shellAliases = builtins.mapAttrs (name: lib.mkDefault) cfge.shellAliases;
environment.etc.zshenv.text = ''
# /etc/zshenv: DO NOT EDIT -- this file has been generated automatically.
# This file is read for all shells.
# Only execute this file once per shell.
if [ -n "''${__ETC_ZSHENV_SOURCED-}" ]; then return; fi
__ETC_ZSHENV_SOURCED=1
if [ -z "''${__NIXOS_SET_ENVIRONMENT_DONE-}" ]; then
. ${config.system.build.setEnvironment}
fi
HELPDIR="${pkgs.zsh}/share/zsh/$ZSH_VERSION/help"
# 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
# Setup custom shell init stuff.
${cfge.shellInit}
${cfg.shellInit}
# Read system-wide modifications.
if test -f /etc/zshenv.local; then
. /etc/zshenv.local
fi
'';
environment.etc.zprofile.text = ''
# /etc/zprofile: DO NOT EDIT -- this file has been generated automatically.
# This file is read for login shells.
#
${zshStartupNotes}
# Only execute this file once per shell.
if [ -n "''${__ETC_ZPROFILE_SOURCED-}" ]; then return; fi
__ETC_ZPROFILE_SOURCED=1
# Setup custom login shell init stuff.
${cfge.loginShellInit}
${cfg.loginShellInit}
# Read system-wide modifications.
if test -f /etc/zprofile.local; then
. /etc/zprofile.local
fi
'';
environment.etc.zshrc.text = ''
# /etc/zshrc: DO NOT EDIT -- this file has been generated automatically.
# This file is read for interactive shells.
#
${zshStartupNotes}
# Only execute this file once per shell.
if [ -n "$__ETC_ZSHRC_SOURCED" -o -n "$NOSYSZSHRC" ]; then return; fi
__ETC_ZSHRC_SOURCED=1
${lib.optionalString (cfg.setOptions != [ ]) ''
# Set zsh options.
setopt ${builtins.concatStringsSep " " cfg.setOptions}
''}
# Alternative method of determining short and full hostname.
HOST=${config.networking.fqdnOrHostName}
# Setup command line history.
# Don't export these, otherwise other shells (bash) will try to use same HISTFILE.
SAVEHIST=${builtins.toString cfg.histSize}
HISTSIZE=${builtins.toString cfg.histSize}
HISTFILE=${cfg.histFile}
# Configure sane keyboard defaults.
. /etc/zinputrc
${lib.optionalString cfg.enableGlobalCompInit ''
# Enable autocompletion.
autoload -U compinit && compinit
''}
${lib.optionalString cfg.enableBashCompletion ''
# Enable compatibility with bash's completion system.
autoload -U bashcompinit && bashcompinit
''}
# Setup custom interactive shell init stuff.
${cfge.interactiveShellInit}
${cfg.interactiveShellInit}
${lib.optionalString cfg.enableLsColors ''
# Extra colors for directory listings.
eval "$(${pkgs.coreutils}/bin/dircolors -b)"
''}
# Setup aliases.
${zshAliases}
# Setup prompt.
${cfg.promptInit}
# Disable some features to support TRAMP.
if [ "$TERM" = dumb ]; then
unsetopt zle prompt_cr prompt_subst
unset RPS1 RPROMPT
PS1='$ '
PROMPT='$ '
fi
# Read system-wide modifications.
if test -f /etc/zshrc.local; then
. /etc/zshrc.local
fi
'';
# Bug in nix flakes:
# If we use `.source` here the path is garbage collected also we point to it with a symlink
# see https://github.com/NixOS/nixpkgs/issues/132732
environment.etc.zinputrc.text = builtins.readFile ./zinputrc;
environment.systemPackages = [
pkgs.zsh
]
++ lib.optional cfg.enableCompletion pkgs.nix-zsh-completions;
environment.pathsToLink = lib.optional cfg.enableCompletion "/share/zsh";
#users.defaultUserShell = lib.mkDefault "/run/current-system/sw/bin/zsh";
environment.shells = [
"/run/current-system/sw/bin/zsh"
"${pkgs.zsh}/bin/zsh"
];
};
}