zsh: Add (nix-)direnv

legacy
Simon Bruder 2020-08-18 16:38:34 +02:00
parent a6c090e675
commit d9de00e665
No known key found for this signature in database
GPG Key ID: 6F03E0000CC5B62F
5 changed files with 27 additions and 0 deletions

3
.gitmodules vendored
View File

@ -22,3 +22,6 @@
[submodule "zsh-nix-shell"]
path = zsh-nix-shell
url = https://github.com/chisui/zsh-nix-shell
[submodule "nix-direnv"]
path = nix-direnv
url = https://github.com/nix-community/nix-direnv

1
home/.gitignore vendored
View File

@ -1,2 +1,3 @@
*.swp
.direnv
Session.vim

1
home/.nix-direnv Symbolic link
View File

@ -0,0 +1 @@
../nix-direnv

View File

@ -52,6 +52,27 @@ alias dynamic-colors="~/.dynamic-colors/bin/dynamic-colors"
## Support for nix-shell
source $HOME/.zsh/zsh-nix-shell/nix-shell.plugin.zsh
# Per-directory environment
command -v direnv >/dev/null && eval "$(direnv hook zsh)"
nixify() {
if [ ! -e ./.envrc ]; then
echo "use nix" > .envrc
direnv allow
fi
if [[ ! -e shell.nix ]] && [[ ! -e default.nix ]]; then
cat > default.nix << EOF
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
nativeBuildInputs = with pkgs; [
];
}
EOF
${EDITOR:-vim} default.nix
fi
}
## Timer
function timer() (
if [ -z "$1" ] || [ -z "$2" ]; then

1
nix-direnv Submodule

@ -0,0 +1 @@
Subproject commit 300258e2bded28c284451f4fac8475b2240b46f6