116 lines
2.9 KiB
Nix
Raw Permalink Normal View History

2024-12-23 11:14:18 -05:00
{
config,
lib,
pkgs,
...
}:
2024-12-23 15:44:53 -05:00
let
zshrc = pkgs.writeTextFile {
name = ".zshrc";
text = ''
# Lines configured by zsh-newuser-install
HISTFILE=~/.zhistory
HISTSIZE=100000
SAVEHIST=100000
setopt appendhistory notify
unsetopt beep
bindkey -e
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
#
# Use menu complete immediately instead of after the first tab
setopt MENU_COMPLETE
zstyle :compinstall filename "$HOME/.zshrc"
autoload -Uz compinit
compinit
# End of lines added by compinstall
# Enable the 2d menu for tab completion
zstyle ':completion:*' menu select
autoload colors zsh/terminfo
if [[ "$terminfo[colors]" -ge 8 ]]; then
colors
fi
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
eval PR_$color='%{$terminfo[bold]$fg[''${(L)color}]%}'
eval PR_LIGHT_$color='%{$fg[''${(L)color}]%}'
(( count = $count + 1 ))
done
PR_NO_COLOR="%{$terminfo[sgr0]%}"
PS1="[$PR_BLUE%n$PR_WHITE@$PR_GREEN%U%m%u$PR_NO_COLOR:$PR_RED%2c$PR_NO_COLOR]%(!.#.$) "
source ${pkgs.zsh-histdb}/share/zsh/plugins/zsh-histdb/sqlite-history.zsh
autoload -Uz add-zsh-hook
source ${pkgs.zsh-histdb}/share/zsh/plugins/zsh-histdb/histdb-interactive.zsh
bindkey '^r' _histdb-isearch
2025-07-13 16:07:25 -04:00
${lib.concatMapStringsSep "\n" (item: "source ${item}") config.me.zsh.includes}
2024-12-23 15:44:53 -05:00
'';
};
in
2024-12-23 11:14:18 -05:00
{
imports = [ ];
2025-01-23 21:55:22 -05:00
options.me = {
zsh.enable = lib.mkOption {
type = lib.types.bool;
default = false;
example = true;
description = "Whether we want to install zsh.";
};
2025-07-13 16:07:25 -04:00
zsh.includes = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [ ];
example = lib.literalExpression ''
[ (pkgs.writeTextFile {
name = "launch-kanshi.conf";
text = "exec kanshi";
}) ]'';
description = "List of zshrc files to import.";
};
2025-01-23 21:55:22 -05:00
};
2024-12-23 11:14:18 -05:00
2025-01-23 21:55:22 -05:00
config = lib.mkIf config.me.zsh.enable (
lib.mkMerge [
{
environment.systemPackages = with pkgs; [
zsh
];
2024-12-23 15:44:53 -05:00
2025-01-23 21:55:22 -05:00
users.users.talexander.shell = pkgs.zsh;
environment.shells = with pkgs; [ zsh ];
2024-12-23 15:44:53 -05:00
2025-01-23 21:55:22 -05:00
programs.zsh = {
enable = true;
};
2024-12-23 15:44:53 -05:00
2025-08-10 15:34:29 -04:00
me.install.user.talexander.file = {
".zshrc" = {
source = "${zshrc}";
2025-01-23 21:55:22 -05:00
};
2025-08-10 15:34:29 -04:00
};
2025-01-23 21:55:22 -05:00
environment.persistence."/persist" = lib.mkIf (!config.me.buildingIso) {
hideMounts = true;
users.talexander = {
directories = [
{
directory = ".histdb";
user = "talexander";
group = "talexander";
mode = "0700";
}
];
};
};
}
]
);
2024-12-23 11:14:18 -05:00
}