summaryrefslogtreecommitdiff
path: root/tests/programs-zsh.nix
blob: 97afe47b0dd30f60791dfc67c1f11cab053c5b97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{ config, pkgs, ... }:

{
   environment.systemPath = [ pkgs.hello ];
   environment.shellAliases.ls = "ls -G";
   environment.interactiveShellInit = "source /etc/environment.d/*.conf";

   programs.zsh.enable = true;
   programs.zsh.enableCompletion = true;
   programs.zsh.enableBashCompletion = false;

   programs.zsh.shellInit = "source /etc/zshenv.d/*.conf";
   programs.zsh.interactiveShellInit = "source /etc/zshrc.d/*.conf";
   programs.zsh.loginShellInit = "source /etc/zprofile.d/*.conf";
   programs.zsh.promptInit = "autoload -U promptinit && promptinit && prompt off";

   programs.zsh.variables.FOO = "42";

   test = ''
     echo >&2 "checking for share/zsh in /sw"
     test -e ${config.out}/sw/share/zsh

     echo >&2 "checking environment.systemPath in /etc/zshenv"
     grep 'export PATH=${pkgs.hello}/bin' ${config.out}/etc/zshenv
     echo >&2 "checking SHELL in /etc/zshenv"
     grep 'export SHELL="${pkgs.zsh}/bin/zsh"' ${config.out}/etc/zshenv
     echo >&2 "checking nix-shell return /etc/zshenv"
     grep 'if test -n "$IN_NIX_SHELL"; then return; fi' ${config.out}/etc/zshenv
     echo >&2 "checking zshenv.d in /etc/zshenv"
     grep 'source /etc/zshenv.d/\*.conf' ${config.out}/etc/zshenv

     echo >&2 "checking environment.d in /etc/zshrc"
     grep 'source /etc/environment.d/\*.conf' ${config.out}/etc/zshrc
     echo >&2 "checking zshrc.d in /etc/zshrc"
     grep 'source /etc/zshrc.d/\*.conf' ${config.out}/etc/zshrc
     echo >&2 "checking prompt off in /etc/zshrc"
     grep 'prompt off' ${config.out}/etc/zshrc
     echo >&2 "checking compinit in /etc/zshrc"
     grep 'autoload -U compinit && compinit' ${config.out}/etc/zshrc
     echo >&2 "checking bashcompinit in /etc/zshrc"
     grep -vq 'bashcompinit' ${config.out}/etc/zshrc

     echo >&2 "checking zprofile.d in /etc/zprofile"
     grep 'source /etc/zprofile.d/\*.conf' ${config.out}/etc/zprofile
     echo >&2 "checking zsh variables in /etc/zprofile"
     grep 'FOO="42"' ${config.out}/etc/zprofile
     echo >&2 "checking shell aliases in /etc/zprofile"
     grep 'alias ls="ls -G"' ${config.out}/etc/zprofile
   '';
}