config/.envrc

37 lines
977 B
Bash

#!/usr/bin/env bash
git config --local core.hooksPath "$PWD"/.githooks
test -d .direnv || mkdir -p .direnv
now="$(date +%Y-%m-%d)"
if ! test -s .direnv/pull-date || test "$now" != "$(cat .direnv/pull-date)"; then
git checkout -- flake.lock
git pull --rebase --autostash
nix flake lock \
--update-input nixpkgs \
--update-input unstable \
--update-input home-manager \
--update-input pbsds-papers
#--update-input nixos-hardware
echo "$now" > .direnv/pull-date
fi
if command -v nixos-rebuild >/dev/null; then
use flake .#nixos-rebuild-nom
elif ! command -v nixos-rebuild >/dev/null; then
use flake .#non-nixos
fi
if test -s .remote.toml; then
if ! command -v remote-init >/dev/null; then
use flake .#remote
fi
echo
echo "Current remote: $(remote-host)"
tomlq <.remote.toml '.hosts | to_entries[] | "remote-set \(.key+1) # -> \(.value.host)"' -r
echo
fi
if rg 'TODO' -q ; then
echo "There are $(rg 'TODO' | wc -l ) 'TODO'"
fi