From 684d79ee797baf51f660e3d4c4b31581ffccf687 Mon Sep 17 00:00:00 2001 From: Jacob Bachmann Date: Thu, 9 May 2024 15:08:32 +0200 Subject: [PATCH] feat: add flake develop zsh hook --- users/gandalf/modules/zsh.nix | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/users/gandalf/modules/zsh.nix b/users/gandalf/modules/zsh.nix index f887449..a407251 100644 --- a/users/gandalf/modules/zsh.nix +++ b/users/gandalf/modules/zsh.nix @@ -1,4 +1,4 @@ -{ config, ... }: { +{ config, pkgs, ... }: { programs.zsh = { enable = true; enableCompletion = true; @@ -12,10 +12,26 @@ "git" ]; }; + history = { path = "${config.xdg.dataHome}/zsh/histfile"; size = 10000; save = 10000; }; + + initExtra = '' + nix_dev_env() { + FLAKE="$PWD/flake.nix" + [[ -z "$CURRENT_FLAKE_ENV" ]] && \ + [[ -f $FLAKE ]] && \ + ZSH_PREFIX="$ZSH_PREFIX(flake)" \ + CURRENT_FLAKE_ENV=$FLAKE \ + nix develop -c $SHELL 2> /dev/null + } + autoload -U add-zsh-hook + add-zsh-hook chpwd nix_dev_env + + export PS1="$ZSH_PREFIX$PS1" + ''; }; }