]> git.scottworley.com Git - auto-upgrade-with-pinch/commitdiff
When becoming other users, cd to / with pushd, not sudo -D master
authorScott Worley <scottworley@scottworley.com>
Sat, 21 Dec 2024 04:40:25 +0000 (20:40 -0800)
committerScott Worley <scottworley@scottworley.com>
Sat, 21 Dec 2024 04:40:25 +0000 (20:40 -0800)
sudo can complain: "sudo: you are not permitted to use the -D option"

modules/auto-upgrade.nix

index f3089bd7f75ff210017dd574d624b88ef79b9fb2..0977176a8176855b4521ef60dc7b875062fda921 100644 (file)
@@ -183,8 +183,10 @@ let
         # Build
         in_tmpdir hydrate ${config.system.build.nixos-rebuild}/bin/nixos-rebuild build
         while read user;do
-          hydrate /run/wrappers/bin/sudo -u "$user" -D / \
+          pushd /
+          hydrate /run/wrappers/bin/sudo -u "$user" \
             ${pkgs.nix}/bin/nix-build --no-out-link '<nixpkgs>' -A "$(userenv_query "$user" .package)"
+          popd
         done < <( config_query '.userEnvironments | keys []' )
 
         # Install