zsh: Add (nix-)direnv

This commit is contained in:
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