nixos-rebuild: fix --install-bootloader
nixos-rebuild relies on setting an environment variable to change behaviour during nixos-rebuild boot/switch between calling update or install via systemd bootctl. Adding sudo -- as a prefix to various exec calls does not preserve the environment breaking this mechanism. This is a some what ugly fix that works. Closes https://github.com/NixOS/nixpkgs/pull/144429
This commit is contained in:
parent
19781e6663
commit
bc5a610cb7
@ -29,7 +29,9 @@ upgrade_all=
|
|||||||
profile=/nix/var/nix/profiles/system
|
profile=/nix/var/nix/profiles/system
|
||||||
buildHost=localhost
|
buildHost=localhost
|
||||||
targetHost=
|
targetHost=
|
||||||
maybeSudo=()
|
remoteSudo=
|
||||||
|
# comma separated list of vars to preserve when using sudo
|
||||||
|
preservedSudoVars=NIXOS_INSTALL_BOOTLOADER
|
||||||
|
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
i="$1"; shift 1
|
i="$1"; shift 1
|
||||||
@ -100,7 +102,7 @@ while [ "$#" -gt 0 ]; do
|
|||||||
shift 1
|
shift 1
|
||||||
;;
|
;;
|
||||||
--use-remote-sudo)
|
--use-remote-sudo)
|
||||||
maybeSudo=(sudo --)
|
remoteSudo=1
|
||||||
;;
|
;;
|
||||||
--flake)
|
--flake)
|
||||||
flake="$1"
|
flake="$1"
|
||||||
@ -126,8 +128,8 @@ while [ "$#" -gt 0 ]; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -n "$SUDO_USER" ]; then
|
if [[ -n "$SUDO_USER" || -n $remoteSudo ]]; then
|
||||||
maybeSudo=(sudo --)
|
maybeSudo=(sudo --preserve-env="$preservedSudoVars" --)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$buildHost" -a -n "$targetHost" ]; then
|
if [ -z "$buildHost" -a -n "$targetHost" ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user