Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d7b18bcb3718
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2c09cfc097da
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Nov 7, 2019

  1. nixos-rebuild: add explicit option to enable (remote) sudo

    Add --use-remote-sudo option. When set, remote commands will be prefixed
    with 'sudo'. This allows using sudo remotely _without_ having to use
    sudo locally (when using --build-host/--taget-host).
    bjornfor committed Nov 7, 2019
    Copy the full SHA
    2c09cfc View commit details
Showing with 19 additions and 4 deletions.
  1. +14 −0 nixos/doc/manual/man-nixos-rebuild.xml
  2. +5 −4 nixos/modules/installer/tools/nixos-rebuild.sh
14 changes: 14 additions & 0 deletions nixos/doc/manual/man-nixos-rebuild.xml
Original file line number Diff line number Diff line change
@@ -494,6 +494,20 @@
</para>
</listitem>
</varlistentry>

<varlistentry>
<term>
<option>--use-remote-sudo</option>
</term>
<listitem>
<para>
When set, nixos-rebuild prefixes remote commands that run on
the <option>--build-host</option> and <option>--target-host</option>
systems with <command>sudo</command>. Setting this option allows
deploying as a non-root user.
</para>
</listitem>
</varlistentry>
</variablelist>

<para>
9 changes: 5 additions & 4 deletions nixos/modules/installer/tools/nixos-rebuild.sh
Original file line number Diff line number Diff line change
@@ -90,17 +90,18 @@ while [ "$#" -gt 0 ]; do
targetHost="$1"
shift 1
;;
--use-remote-sudo)
# note the trailing space
maybeSudo="sudo "
shift 1
;;
*)
echo "$0: unknown option \`$i'"
exit 1
;;
esac
done

if [ -n "$SUDO_USER" ]; then
maybeSudo="sudo "
fi

if [ -z "$buildHost" -a -n "$targetHost" ]; then
buildHost="$targetHost"
fi