Closed wrdls closed 10 months ago
@wrdls
.zshenv
and .zshrc
located? ZDOTDIR
?I notice Devbox doesn't respect ZDOTDIR when linking the zsh startup files to the devbox shell. I suspect that is the cause here, but wanted confirmation. Thanks!
❯ ls -la ~/.zsh*
-rw------- 1 wardloos 374430 Oct 25 08:48 /Users/wardloos/.zsh_history
lrwxr-xr-x 1 wardloos 70 Oct 24 13:59 /Users/wardloos/.zshenv -> /nix/store/c719kah6r377splyz4x0cy4gx30d8b6l-home-manager-files/.zshenv
lrwxr-xr-x 1 wardloos 69 Oct 24 13:59 /Users/wardloos/.zshrc -> /nix/store/c719kah6r377splyz4x0cy4gx30d8b6l-home-manager-files/.zshrc
ZDOTDIR
is not set.
I tried enabling programs.zsh.dotDir like this:
dotDir = ".config/zsh";
Which results in
❯ echo $ZDOTDIR
/Users/wardloos/.config/zsh
❯ ls -la ~/.zsh*
-rw------- 1 wardloos 372406 Oct 25 09:10 /Users/wardloos/.zsh_history
lrwxr-xr-x 1 wardloos 70 Oct 25 08:58 /Users/wardloos/.zshenv -> /nix/store/rrfynsc54n6j25p9pyqgkaimichnvh52-home-manager-files/.zshenv
❯ ls -la ~/.config/zsh
-rw-r--r-- 1 wardloos 53362 Oct 25 09:06 '.zcompdump-Ward’s MacBook Pro-5.9'
lrwxr-xr-x 1 wardloos 84 Oct 25 08:58 .zprofile -> /nix/store/rrfynsc54n6j25p9pyqgkaimichnvh52-home-manager-files/.config/zsh/.zprofile
drwx------ 4 wardloos 128 Oct 25 09:00 .zsh_sessions
lrwxr-xr-x 1 wardloos 82 Oct 25 08:58 .zshenv -> /nix/store/rrfynsc54n6j25p9pyqgkaimichnvh52-home-manager-files/.config/zsh/.zshenv
lrwxr-xr-x 1 wardloos 81 Oct 25 08:58 .zshrc -> /nix/store/rrfynsc54n6j25p9pyqgkaimichnvh52-home-manager-files/.config/zsh/.zshrc
❯ cat ~/.zshenv
source $HOME/.config/zsh/.zshenv
But that makes my experience worse as not even starship is loaded now when entering the devbox shell.
When I try it on my mac using the compiled Devbox from main
, it seems to work for me:
My setup:
❯ ls -al ~/.zshenv
lrwxr-xr-x 1 savil staff 29 Oct 25 16:59 /Users/savil/.zshenv -> /Users/savil/zsh-test/.zshenv
devbox on main [$] via 🐹 v1.21.1 via ❄️ impure (nix-shell-env) on ☁️ (us-east-2)
❯ cat /Users/savil/zsh-test/.zshenv
...
export FOO_ENV=bar
FOO_ENV_UNEXPORTED=bar
> cat ~/.zshrc
...
echo "FOO_ENV is $FOO_ENV"
echo "FOO_ENV_UNEXPORTED is $FOO_ENV_UNEXPORTED"
...
Opening a new devbox shell
, I see this:
❯ devbox shell
Starting a devbox shell...
FOO_ENV is bar
FOO_ENV_UNEXPORTED is bar
(devbox)
Are you sure nothing is writing to ZSH
in your .zshrc
prior to that line source $ZSH/oh-my-zsh.sh
?
This is my complete $ZDOTDIR/.zshrc
as generated by home-manager up until source $ZSH/oh-my-zsh.sh
:
typeset -U path cdpath fpath manpath
for profile in ${(z)NIX_PROFILES}; do
fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions)
done
HELPDIR="/nix/store/plsnpw0blig4nfdvcm2rghgyc7s0xdkw-zsh-5.9/share/zsh/$ZSH_VERSION/help"
eval $(/nix/store/g9pvwpwpgkhzlq0kv4bbllclm18kv0gj-coreutils-9.3/bin/dircolors -b ~/.dir_colors)
## home-manager/antidote begin :
source /nix/store/lja5zc06brg08cw2ril80ijxi76g1d8b-antidote-1.9.2/share/antidote/antidote.zsh
bundlefile=/nix/store/7y55jn6jdgrj8qq0rgp7cv595g614s5l-hm_antidote-files
zstyle ':antidote:bundle' file $bundlefile
staticfile=/tmp/tmp_hm_zsh_plugins.zsh-7y55jn6jdgrj8qq0rgp7cv595g614s5l
zstyle ':antidote:static' file $staticfile
antidote load $bundlefile $staticfile
## home-manager/antidote end
# Oh-My-Zsh/Prezto calls compinit during initialization,
# calling it twice causes slight start up slowdown
# as all $fpath entries will be traversed again.
# oh-my-zsh extra settings for plugins
# oh-my-zsh configuration generated by NixOS
plugins=(git sudo colored-man-pages command-not-found docker)
source $ZSH/oh-my-zsh.sh
...
And $ZDOTDIR/.zshenv
# Environment variables
. "/Users/wardloos/.nix-profile/etc/profile.d/hm-session-vars.sh"
# Only source this once
if [[ -z "$__HM_ZSH_SESS_VARS_SOURCED" ]]; then
export __HM_ZSH_SESS_VARS_SOURCED=1
fi
ZDOTDIR=$HOME/.config/zsh
ZSH="/nix/store/2rg6fplzz5klibd6cw8nm5vikpw71sig-oh-my-zsh-2023-06-26/share/oh-my-zsh";
ZSH_CACHE_DIR="/Users/wardloos/.cache/oh-my-zsh";
The shell related parts of my user.nix
in fleek.
{ pkgs, misc, ... }: {
# FEEL FREE TO EDIT: This file is NOT managed by fleek.
# See https://nix-community.github.io/home-manager/options.html
programs.atuin.enable = true;
programs.bat.enable = true;
programs.direnv.enable = true;
programs.fzf.enable = true;
programs.starship = {
enable = true;
settings = {
cmd_duration = {
show_notifications = true;
};
kubernetes = {
disabled = false;
format = "[$symbol$context(/$namespace)]($style) | ";
};
line_break = {
disabled = false;
};
status = {
disabled = false;
};
};
};
programs.zsh = {
antidote = {
enable = true;
plugins = [
"zsh-users/zsh-autosuggestions"
"zsh-users/zsh-syntax-highlighting"
"zsh-users/zsh-history-substring-search"
"kubermatic/fubectl"
];
};
dotDir = ".config/zsh";
oh-my-zsh = {
enable = true;
plugins = [
"git"
"sudo"
"colored-man-pages"
"command-not-found"
"docker"
];
};
};
}
I tried https://github.com/jetpack-io/devbox/pull/1587 and that seems to work 👍
☸ devbox on savil/zdotdir via 🐹 v1.20.8 took 5s
❯ devbox shell
Starting a devbox shell...
(devbox) wardloos@Wards-MacBook-Pro devbox % exit
☸ devbox on savil/zdotdir via 🐹 v1.20.8 took 2s
❯ ./dist/devbox shell
Ensuring packages are installed.
✓ Computed the Devbox environment.
Starting a devbox shell...
☸ devbox on savil/zdotdir via 🐹 v1.21.1 via ❄️ impure (nix-shell-env)
❯
@wrdls I'm glad to hear that. I still don't understand why its now working. Nothing about the zsh config files you shared stand out as being problematic :/
Current Behavior (bug)
.zshenv
doesn't seem to be sourced which breaks my oh-my-zsh install.Oh-my-zsh is installed with home-manager (with fleek) which adds the following lines:
.zshenv
.zshrc
From the output
/oh-my-zsh.sh
it seems like$ZSH
is unset which makes me believe.zshenv
is not sourced properly.Expected Behavior (fix)
.zshenv
is sourced properly.Additional context