27 lines
802 B
Nix
27 lines
802 B
Nix
{
|
|
programs = {
|
|
direnv = {
|
|
enable = true;
|
|
enableZshIntegration = true;
|
|
# export_function needed for per directory function/alias with direnv: https://github.com/direnv/direnv/issues/73
|
|
stdlib = ''
|
|
export_function() {
|
|
local name=$1
|
|
local alias_dir=$PWD/.direnv/aliases
|
|
mkdir -p "$alias_dir"
|
|
PATH_add "$alias_dir"
|
|
local target="$alias_dir/$name"
|
|
if declare -f "$name" >/dev/null; then
|
|
echo "#!$SHELL" > "$target"
|
|
declare -f "$name" >> "$target" 2>/dev/null
|
|
# notice that we add shell variables to the function trigger.
|
|
echo "$name \$*" >> "$target"
|
|
chmod +x "$target"
|
|
fi
|
|
}
|
|
'';
|
|
nix-direnv.enable = true;
|
|
};
|
|
};
|
|
}
|