1 <chapter xmlns="http://docbook.org/ns/docbook"
2 xmlns:xlink="http://www.w3.org/1999/xlink"
3 xmlns:xi="http://www.w3.org/2001/XInclude"
5 xml:id="module-programs-zsh-ohmyzsh">
6 <title>Oh my ZSH</title>
8 <literal><link xlink:href="https://ohmyz.sh/">oh-my-zsh</link></literal> is a
9 framework to manage your <link xlink:href="https://www.zsh.org/">ZSH</link>
10 configuration including completion scripts for several CLI tools or custom
13 <section xml:id="module-programs-oh-my-zsh-usage">
14 <title>Basic usage</title>
17 The module uses the <literal>oh-my-zsh</literal> package with all available
18 features. The initial setup using Nix expressions is fairly similar to the
19 configuration format of <literal>oh-my-zsh</literal>.
22 programs.zsh.ohMyZsh = {
24 plugins = [ "git" "python" "man" ];
29 For a detailed explanation of these arguments please refer to the
30 <link xlink:href="https://github.com/robbyrussell/oh-my-zsh/wiki"><literal>oh-my-zsh</literal>
35 The expression generates the needed configuration and writes it into your
36 <literal>/etc/zshrc</literal>.
39 <section xml:id="module-programs-oh-my-zsh-additions">
40 <title>Custom additions</title>
43 Sometimes third-party or custom scripts such as a modified theme may be
44 needed. <literal>oh-my-zsh</literal> provides the
45 <link xlink:href="https://github.com/robbyrussell/oh-my-zsh/wiki/Customization#overriding-internals"><literal>ZSH_CUSTOM</literal></link>
46 environment variable for this which points to a directory with additional
51 The module can do this as well:
54 programs.zsh.ohMyZsh.custom = "~/path/to/custom/scripts";
59 <section xml:id="module-programs-oh-my-zsh-environments">
60 <title>Custom environments</title>
63 There are several extensions for <literal>oh-my-zsh</literal> packaged in
64 <literal>nixpkgs</literal>. One of them is
65 <link xlink:href="https://github.com/spwhitt/nix-zsh-completions">nix-zsh-completions</link>
66 which bundles completion scripts and a plugin for
67 <literal>oh-my-zsh</literal>.
71 Rather than using a single mutable path for <literal>ZSH_CUSTOM</literal>,
72 it's also possible to generate this path from a list of Nix packages:
76 programs.zsh.ohMyZsh.customPkgs = [
77 pkgs.nix-zsh-completions
82 Internally a single store path will be created using
83 <literal>buildEnv</literal>. Please refer to the docs of
84 <link xlink:href="https://nixos.org/nixpkgs/manual/#sec-building-environment"><literal>buildEnv</literal></link>
85 for further reference.
89 <emphasis>Please keep in mind that this is not compatible with
90 <literal>programs.zsh.ohMyZsh.custom</literal> as it requires an immutable
91 store path while <literal>custom</literal> shall remain mutable! An
92 evaluation failure will be thrown if both <literal>custom</literal> and
93 <literal>customPkgs</literal> are set.</emphasis>
96 <section xml:id="module-programs-oh-my-zsh-packaging-customizations">
97 <title>Package your own customizations</title>
100 If third-party customizations (e.g. new themes) are supposed to be added to
101 <literal>oh-my-zsh</literal> there are several pitfalls to keep in mind:
107 To comply with the default structure of <literal>ZSH</literal> the entire
108 output needs to be written to <literal>$out/share/zsh.</literal>
113 Completion scripts are supposed to be stored at
114 <literal>$out/share/zsh/site-functions</literal>. This directory is part
116 <literal><link xlink:href="http://zsh.sourceforge.net/Doc/Release/Functions.html">fpath</link></literal>
117 and the package should be compatible with pure <literal>ZSH</literal>
118 setups. The module will automatically link the contents of
119 <literal>site-functions</literal> to completions directory in the proper
125 The <literal>plugins</literal> directory needs the structure
126 <literal>pluginname/pluginname.plugin.zsh</literal> as structured in the
127 <link xlink:href="https://github.com/robbyrussell/oh-my-zsh/tree/91b771914bc7c43dd7c7a43b586c5de2c225ceb7/plugins">upstream
134 A derivation for <literal>oh-my-zsh</literal> may look like this:
136 { stdenv, fetchFromGitHub }:
138 stdenv.mkDerivation rec {
139 name = "exemplary-zsh-customization-${version}";
141 src = fetchFromGitHub {
142 # path to the upstream repository
147 mkdir -p $out/share/zsh/site-functions
148 cp {themes,plugins} $out/share/zsh
149 cp completions $out/share/zsh/site-functions