1
0
Fork 0

Bin: use sudo wrappers in nos script

This commit is contained in:
Aires 2024-09-30 15:32:49 -04:00
parent e95e31a46f
commit 14c4629461

View file

@ -29,13 +29,6 @@ function usage() {
exit 2 exit 2
} }
function run_operation {
options="--flake $flakeDir $remainingArgs --use-remote-sudo --log-format multiline-with-logs"
echo "Running this operation: nixos-rebuild $1 $options"
nixos-rebuild $operation $options
}
# Argument processing logic shamelessly stolen from https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash # Argument processing logic shamelessly stolen from https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash
POSITIONAL_ARGS=() POSITIONAL_ARGS=()
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
@ -81,16 +74,19 @@ fi
cd $flakeDir cd $flakeDir
echo "Pulling the latest version of the repository..." echo "Pulling the latest version of the repository..."
sudo -u $user git pull /run/wrappers/bin/sudo -u $user git pull
if [ $update = true ]; then if [ $update = true ]; then
echo "Checking for updates..." echo "Checking for updates..."
sudo -u $user nix flake update --commit-lock-file /run/wrappers/bin/sudo -u $user nix flake update --commit-lock-file
sudo -u $user git push /run/wrappers/bin/sudo -u $user git push
else else
echo "Skipping 'nix flake update'..." echo "Skipping 'nix flake update'..."
fi fi
run_operation $operation options="--flake $flakeDir $remainingArgs --use-remote-sudo --log-format multiline-with-logs"
echo "Running this operation: nixos-rebuild $operation $options"
nixos-rebuild $operation $options
exit 0 exit 0