add test and push mode to nixos-edit

This commit is contained in:
Daniella / Tove 2024-10-19 18:15:16 +02:00
parent 86098a3122
commit c6e4552e50
Signed by: TudbuT
GPG key ID: B3CF345217F202D3

View file

@ -9,6 +9,8 @@ pkgs.writeShellScriptBin "nixos-edit" ''
echo "supports commands:"
echo " - pull -- pulls the changes and switches to them"
echo " - edit -- edits the OS, pushes it, and switches"
echo " - test -- edits the OS and switches"
echo " - push -- commits edits from test and pushes them"
echo " - update -- update the system"
echo " - init -- initialize the system (only run once)"
echo
@ -72,18 +74,25 @@ pkgs.writeShellScriptBin "nixos-edit" ''
exec sudo -iu tudbut nixos-edit $1 || exit 1
fi
[ "$1" = "edit" ] || [ "$1" = "" ] || [ "$1" = "push" ]
PUSH=$?
cd /etc/nixos
if [ "$1" = "pull" ] ; then
git pull
fi
if [ "$1" = "edit" ] || [ "$1" = "" ] ; then
if [ "$1" = "edit" ] || [ "$1" = "" ] || [ "$1" = "test" ] ; then
sudo hx .
fi
if [ $PUSH = 0 ] ; then
git add .
EDITOR=hx git commit -a
git push
if [ "$1" = "push" ] ; then
exit 0
fi
fi
if [ "$1" = "update" ] ; then
git push
sudo nixos-rebuild switch --upgrade
else
sudo nixos-rebuild switch