# modules/home/shell.nix — zsh as the shell, configured by the dotfiles.
#
# dotfiles/home/.dotfiles in this repo (carried from the old
# ~/git/daemon-sec-dotfiles checkout) is a complete zsh setup: a ZDOTDIR tree
# with core.zsh (history, cached compinit, the plugin loader, zoxide/atuin/fzf
# hooks), the leaf modules (aliases, fzf verbs, ripgrep, cheats, music, jj,
# …), theme.zsh (starship with a transient prompt) and animations.zsh (the
# login splash). The plugins it loads — zsh-autosuggestions,
# zsh-syntax-highlighting, zsh-completions, fzf-tab, history-substring-search,
# you-should-use — are vendored in .dotfiles/config/plugins, so the config is
# used as-is rather than rewritten as home-manager options. This module only
# supplies what the Omarchy install had and NixOS does not:
#
# ~/.zshenv sets ZDOTDIR (home-manager owns this one file)
# ~/.dotfiles → ~/NixDaemon/dotfiles/home/.dotfiles (edits are live)
# ~/.fzf.zsh fzf's key bindings from the Nix store (core.zsh looks
# in /usr/share/fzf, which does not exist here)
# ~/.zsh/completions generated completions for tools without shipped ones
# tmux plugins from nixpkgs (~/.tmux.conf expects TPM; a shim loads them)
# ~/.config/tmux/palette.conf tmux colours from theme.nix (~/.tmux.conf sources it)
# ~/.config/secretspec the keyring provider
#
# The dotfiles themselves (~/.dotfiles, ~/.tmux.conf, the tool configs under
# ~/.config: starship, bat theme, atuin, fastfetch, cheats, …) are linked by
# modules/home/dotfiles.nix. NixOS side (modules/hosts/laptop/configuration.nix): programs.zsh with the global compinit
# and prompt off (core.zsh and theme.zsh do those), users.<user>.shell.
{ ... }:
let theme = import ../_palette.nix; in
{
flake.homeModules.shell =
{ config, pkgs, lib, ... }:
let
# Completions for tools that do not ship their own under share/zsh.
# (uv, jj, gh, atuin, zoxide, eza, bat, fd, rg do; /etc/zshrc puts the
# profiles' site-functions on fpath before core.zsh runs compinit.)
generatedCompletions = pkgs.runCommand "nixdaemon-zsh-completions" { } ''
mkdir -p $out
export HOME=$TMPDIR
${pkgs.secretspec}/bin/secretspec completions zsh > $out/_secretspec
'';
# ~/.tmux.conf ends with `run '~/.tmux/plugins/tpm/tpm'` and lists plugins
# for TPM to clone. nixpkgs has the plugins but not TPM, so each plugin is
# linked where TPM would have put it and this stand-in sources them.
tpmShim = ''
#!${pkgs.bash}/bin/bash
# Stand-in for tmux-plugin-manager (NixDaemon modules/home/shell.nix): the
# plugins come from nixpkgs and are linked into ~/.tmux/plugins; this runs
# each plugin's entry script the way TPM would. prefix+I/U do nothing here;
# add plugins in shell.nix instead.
for f in "$HOME"/.tmux/plugins/*/*.tmux; do
case "$f" in */tpm/*) continue ;; esac
[ -x "$f" ] && "$f"
done
exit 0
'';
tmuxPlugin = name: pkg: {
name = ".tmux/plugins/${name}";
value.source = "${pkg}/share/tmux-plugins/${pkg.pluginName}";
};
in
{
home.packages = with pkgs; [
zsh
tmux
ansifilter # tmux-logging strips colour codes from pane logs with it
secretspec
];
sops.secrets."private-env" = {
sopsFile = ../../secrets/private-env.sh;
format = "binary";
};
home.file = {
# zsh: hand over to the dotfiles' ZDOTDIR tree.
".zshenv".text = ''
# Managed by home-manager (NixDaemon modules/home/shell.nix). The shell
# configuration lives in ~/.dotfiles (→ ~/NixDaemon/dotfiles/home/.dotfiles).
export ZDOTDIR="$HOME/.dotfiles"
# home.sessionVariables (PASSAGE_*, XDG_*, …); programs.zsh is off, so
# nothing else sources this.
[[ -r "${config.home.profileDirectory}/etc/profile.d/hm-session-vars.sh" ]] \
&& . "${config.home.profileDirectory}/etc/profile.d/hm-session-vars.sh"
[[ -r "$HOME/.cargo/env" ]] && . "$HOME/.cargo/env"
# Private variables (secrets/private-env.sh, decrypted by sops-nix).
[[ -r "${config.sops.secrets."private-env".path}" ]] \
&& . "${config.sops.secrets."private-env".path}"
'';
".fzf.zsh".text = ''
# fzf key bindings (Ctrl-T, Alt-C, Ctrl-R) and completion from the Nix
# store; sourced by ~/.dotfiles/config/core.zsh. Quiet when there is no
# tty (the scripts restore `zle`, which fails outside a terminal).
if [[ -t 0 ]]; then
source ${pkgs.fzf}/share/fzf/key-bindings.zsh
source ${pkgs.fzf}/share/fzf/completion.zsh
else
{ source ${pkgs.fzf}/share/fzf/key-bindings.zsh; source ${pkgs.fzf}/share/fzf/completion.zsh; } 2>/dev/null
fi
'';
".zsh/completions".source = generatedCompletions;
# Loaded after the dotfiles' key bindings, in config/core.zsh.
".zsh/autopair.zsh".source = "${pkgs.zsh-autopair}/share/zsh/zsh-autopair/autopair.zsh";
".tmux/plugins/tpm/tpm" = {
text = tpmShim;
executable = true;
};
}
// builtins.listToAttrs [
(tmuxPlugin "tmux-resurrect" pkgs.tmuxPlugins.resurrect)
(tmuxPlugin "tmux-continuum" pkgs.tmuxPlugins.continuum)
(tmuxPlugin "tmux-yank" pkgs.tmuxPlugins.yank)
(tmuxPlugin "tmux-open" pkgs.tmuxPlugins.open)
# pentest additions (2026-10-14); keys and options are in ~/.tmux.conf
(tmuxPlugin "tmux-logging" pkgs.tmuxPlugins.logging) # pane logs and history dumps as evidence
(tmuxPlugin "extrakto" pkgs.tmuxPlugins.extrakto) # fzf over pane text: hashes, IPs, paths
(tmuxPlugin "tmux-fingers" pkgs.tmuxPlugins.fingers) # hint-copy IPs, hashes, URLs on screen
(tmuxPlugin "tmux-fzf" pkgs.tmuxPlugins.tmux-fzf) # fzf session/window/pane/process menu
(tmuxPlugin "tmux-sessionist" pkgs.tmuxPlugins.sessionist) # session create/switch/kill keys
(tmuxPlugin "tmux-prefix-highlight" pkgs.tmuxPlugins.prefix-highlight) # prefix/copy-mode indicator
];
xdg.configFile = {
# tmux colours from theme.nix; ~/.tmux.conf sources this.
"tmux/palette.conf".text = with theme.palette; ''
# Generated by NixDaemon modules/home/shell.nix (theme: ${theme.name}).
thm_bg="${base}"
thm_fg="${text}"
thm_surface0="${overlay}"
thm_blue="${foam}"
thm_green="${pine}"
thm_red="${love}"
thm_yellow="${gold}"
thm_mauve="${iris}"
thm_teal="${rose}"
thm_lavender="${subtle}"
'';
# secretspec (https://secretspec.dev): secrets in the system keyring, which
# gnome-keyring provides and PAM unlocks at login. Per-project
# secretspec.toml files declare what a project needs; `secretspec check`
# prompts for anything missing, `secretspec run -- cmd` injects them.
"secretspec/config.toml".text = ''
[defaults]
provider = "keyring"
profile = "default"
'';
};
# bat only sees a theme after its cache is rebuilt from ~/.config/bat/themes.
home.activation.batCache = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
if [ -d "$HOME/.config/bat/themes/" ]; then
run ${pkgs.bat}/bin/bat cache --build >/dev/null 2>&1 || true
fi
'';
}
;
}