# -*-sh-*-
# https://github.com/nix-community/nix-direnv/wiki/Shell-integration

nixify() {
  if [ ! -e ./.envrc ]; then
    echo "use nix" > .envrc
    direnv allow
  fi
  if [[ ! -e shell.nix ]] && [[ ! -e default.nix ]]; then
    cat > shell.nix <<'EOF'
with import <nixpkgs> {};
mkShell {
  packages = [
    bashInteractive
  ];
}
EOF
    ${EDITOR:-vim} shell.nix
  fi
}
flakify() {
  if [ ! -e flake.nix ]; then
    nix flake new -t github:nix-community/nix-direnv .
  elif [ ! -e .envrc ]; then
    echo "use flake" > .envrc
    direnv allow
  fi
  ${EDITOR:-vim} flake.nix
}
