From ae1ba47a679903e6a1b98a5b1e00f65e32b082a3 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Fri, 31 Oct 2025 07:10:25 +0100 Subject: feat(workstation): add (nix-)direnv --- user/direnv/direnv.toml | 4 ++++ user/direnv/direnvrc | 12 ++++++++++++ user/zsh/zshrc-workstation.sh | 2 ++ 3 files changed, 18 insertions(+) create mode 100644 user/direnv/direnv.toml create mode 100644 user/direnv/direnvrc (limited to 'user') diff --git a/user/direnv/direnv.toml b/user/direnv/direnv.toml new file mode 100644 index 0000000..1573479 --- /dev/null +++ b/user/direnv/direnv.toml @@ -0,0 +1,4 @@ +[global] +# direnv by default prints which environment variables are being exported +# Since nix-direnv sets quite a lot I'm filtering this out. +log_filter = "^(un)?loading" diff --git a/user/direnv/direnvrc b/user/direnv/direnvrc new file mode 100644 index 0000000..f64197b --- /dev/null +++ b/user/direnv/direnvrc @@ -0,0 +1,12 @@ +# direnv by default puts its cache in .direnv/ next to the .envrc. +# I rather have my caches in ~/.cache. +: "${XDG_CACHE_HOME:="${HOME}/.cache"}" +declare -A direnv_layout_dirs +direnv_layout_dir() { + local hash path + echo "${direnv_layout_dirs[$PWD]:=$( + hash="$(sha1sum - <<< "$PWD" | head -c40)" + path="${PWD//[^a-zA-Z0-9]/-}" + echo "${XDG_CACHE_HOME}/direnv/layouts/${hash}${path}" + )}" +} diff --git a/user/zsh/zshrc-workstation.sh b/user/zsh/zshrc-workstation.sh index 9a255a7..b7458b0 100644 --- a/user/zsh/zshrc-workstation.sh +++ b/user/zsh/zshrc-workstation.sh @@ -17,6 +17,8 @@ path+=$CARGO_HOME/bin path+=$GOPATH/bin path+=$NPM_CONFIG_PREFIX/bin +eval "$(direnv hook zsh)" + function ssh() { # In my ~/.ssh/config I configure host-specific background colors, for example: # -- cgit v1.2.3