[shell/nixos] add script to check for nixos-config changes

This commit is contained in:
Felix Buehler 2021-02-16 17:25:00 +01:00
parent 27f503340a
commit fa35a75d51
2 changed files with 20 additions and 0 deletions

View file

@ -28,6 +28,7 @@
~/.liquidprompt: bash/liquidprompt ~/.liquidprompt: bash/liquidprompt
~/.gitconfig: git/gitconfig ~/.gitconfig: git/gitconfig
~/.profile.d/load: shell/load ~/.profile.d/load: shell/load
~/.profile.d/09-nixos-commited.sh: shell/nixos-commited.sh
~/.profile.d/10-vars.sh: shell/vars.sh ~/.profile.d/10-vars.sh: shell/vars.sh
~/.profile.d/10-paths.sh: shell/paths.sh ~/.profile.d/10-paths.sh: shell/paths.sh
~/.profile.d/10-gitrepo-commited.sh: shell/gitrepo-commited.sh ~/.profile.d/10-gitrepo-commited.sh: shell/gitrepo-commited.sh

19
shell/nixos-commited.sh Executable file
View file

@ -0,0 +1,19 @@
#!/bin/sh
case "$-" in
*i*)
# This shell is interactive, if not ignore this part
# If printing this in non-interactive shells, it'll may prevent scp to work
if [ -d "/etc/nixos" ]; then
changes=`git -C /etc/nixos status --porcelain | wc -l`
if [ $changes -gt 0 ]; then
echo -e '\e[01;31m' >&2
echo -e '######################################' >&2
echo -e '# NixOS-config-Repo is not commited! #' >&2
echo -e '######################################' >&2
echo -e '\e[0m' >&2
fi
fi
;;
esac