nix-setup/nixos-edit.script.nix

30 lines
472 B
Nix
Raw Normal View History

with import <nixpkgs> {};
pkgs.writeShellScriptBin "nixos-edit" ''
#!/bin/sh
2024-10-19 02:39:35 +02:00
if [ "$1" = "init" ] ; then
sudo chown -R tudbut: /etc/nixos
echo dir setup done
exit 0
fi
cd /etc/nixos
if [ "$1" = "pull" ] ; then
git pull
fi
if [ "$1" = "edit" ] || [ "$1" = "" ] ; then
sudo hx .
git add .
EDITOR=hx git commit -a
git push
fi
if [ "$1" = "update" ] ; then
git push
sudo nixos-rebuild switch --upgrade
else
sudo nixos-rebuild switch
fi
''