with import {}; pkgs.writeShellScriptBin "nixos-edit" '' #!/bin/sh if [ "$1" = "init" ] ; then if [ "$(whoami)" = root ] ; then echo "re-executing as tudbut" echo -n "set password for tudbut? (Y/n) " read yn if [ "$yn" != "n" ] ; then passwd tudbut || exit 1 fi sleep 2 echo please make sure xorg is running echo -n enter when ready read exec sudo -iu tudbut nixos-edit init || exit 1 fi if [ "$DISPLAY" = "" ] ; then export DISPLAY=:0 fi sudo chown -R tudbut: /etc/nixos echo dir setup done echo "> setting up ssh" echo ssh setup if ! [ -e ~/.ssh/id_*.pub ] ; then ssh-keygen || exit fi echo ssh key created cat ~/.ssh/id_*.pub | xclip -selection clipboard echo "-> copied to clipboard for later" echo adding it to syncfs echo "-> you will need to input your password" ssh root@tudbut.de "ssh -p 23 localhost 'echo -e \"# $(cat /etc/hostname)\n$(cat ~/.ssh/id_*.pub)\n\" >> .ssh/authorized_keys'" || exit 1 echo "> ssh setup done" echo "> setting up git" git config --global user.name "TudbuT" git config --global user.email "forge-public@mail.tudbut.de" git config --global init.defaultBranch main git config --global push.default current echo configs set echo mounting syncfs mkdir ~/sync 2> /dev/null startsync > /dev/null 2>&1 & echo opening git key add page echo "-> close firefox when complete." firefox "https://git.tudbut.de/user/login?redirect_to=%2fuser%2fsettings%2fkeys" > /dev/null 2>&1 echo correcting remote cd /etc/nixos git remote set-url origin 'ssh://git@tudbut.de:222/TudbuT/nix-setup.git' echo 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 ''