1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-05 08:17:01 +00:00

zsh: add test for most options

This commit is contained in:
Daiderd Jordan 2018-01-20 23:00:24 +01:00
parent 02a8d469da
commit b761ee79a3
No known key found for this signature in database
GPG key ID: D02435D05B810C96
3 changed files with 54 additions and 13 deletions

View file

@ -96,13 +96,13 @@ let
tests.networking-hostname = makeTest ./tests/networking-hostname.nix;
tests.networking-networkservices = makeTest ./tests/networking-networkservices.nix;
tests.nixpkgs-overlays = makeTest ./tests/nixpkgs-overlays.nix;
tests.programs-zsh = makeTest ./tests/programs-zsh.nix;
tests.services-activate-system = makeTest ./tests/services-activate-system.nix;
tests.system-defaults-write = makeTest ./tests/system-defaults-write.nix;
tests.system-keyboard-mapping = makeTest ./tests/system-keyboard-mapping.nix;
tests.system-packages = makeTest ./tests/system-packages.nix;
tests.system-path-bash = makeTest ./tests/system-path-bash.nix;
tests.system-path-fish = makeTest ./tests/system-path-fish.nix;
tests.system-path-zsh = makeTest ./tests/system-path-zsh.nix;
tests.system-shells = makeTest ./tests/system-shells.nix;
tests.users-groups = makeTest ./tests/users-groups.nix;

53
tests/programs-zsh.nix Normal file
View file

@ -0,0 +1,53 @@
{ 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-daemon init in /etc/zshenv"
grep '! -w /nix/var/nix/db' ${config.out}/etc/zshenv
grep 'export NIX_REMOTE=daemon' ${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
'';
}

View file

@ -1,12 +0,0 @@
{ config, pkgs, ... }:
{
environment.systemPath = [ pkgs.hello ];
programs.zsh.enable = true;
test = ''
echo checking systemPath in /etc/zshenv >&2
grep 'export PATH=${pkgs.hello}/bin' ${config.out}/etc/zshenv
'';
}