From d1b678f69e35a07a9bc8d54b3ce5cb2e647f01e5 Mon Sep 17 00:00:00 2001 From: Andre Date: Tue, 6 Aug 2024 09:32:21 -0400 Subject: [PATCH] Services: fix (hopefully) autoupgrade script per https://discourse.nixos.org/t/sudo-uid-issues/9133 --- modules/services/autoupgrade.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/services/autoupgrade.nix b/modules/services/autoupgrade.nix index 4869951..710bc1b 100644 --- a/modules/services/autoupgrade.nix +++ b/modules/services/autoupgrade.nix @@ -63,12 +63,12 @@ in cd ${cfg.configDir} # Check if there are changes from Git. echo "Pulling latest version..." - sudo -u ${cfg.user} git fetch - sudo -u ${cfg.user} git diff --quiet --exit-code ${cfg.branches.local} ${cfg.branches.remoteName}/${cfg.branches.remote} || true + /run/wrappers/bin/sudo -u ${cfg.user} git fetch + /run/wrappers/bin/sudo -u ${cfg.user} git diff --quiet --exit-code ${cfg.branches.local} ${cfg.branches.remoteName}/${cfg.branches.remote} || true # If we have changes (git diff returns 1), pull changes and run the update if [ $? -eq 1 ]; then echo "Updates found, running nixos-rebuild..." - sudo -u ${cfg.user} git pull --recurse-submodules + /run/wrappers/bin/sudo -u ${cfg.user} git pull --recurse-submodules nixos-rebuild switch --flake . else echo "No updates found. Exiting." @@ -99,9 +99,9 @@ in cd ${cfg.configDir} # Make sure we're up-to-date echo "Pulling the latest version..." - sudo -u ${cfg.user} git pull --recurse-submodules - sudo -u ${cfg.user} nix flake update --commit-lock-file - sudo -u ${cfg.user} git push + /run/wrappers/bin/sudo -u ${cfg.user} git pull --recurse-submodules + /run/wrappers/bin/sudo -u ${cfg.user} nix flake update --commit-lock-file + /run/wrappers/bin/sudo -u ${cfg.user} git push ''; };