nixos-rebuild: Allow local builds when --target-host is used again

This is a followup of #148921, to allow local builds when
`--target-host` is used again. It also documents the change in
behavior, regarding the specialty of the `localhost` value.

By removing the special handling of an empty `buildHost` and non empty
`targetHost`, this change also slightly alters the behavior of
`nixos-rebuild`.

Originally by specifying `--target-host target --build-host ""`, the
now removed special case would transform those arguments to
`--target-host target --build-host target`.
Now the empty `--build-host` would result in a local build.
This commit is contained in:
Fabian Möller 2023-01-13 10:16:46 +01:00
parent 16b20a5c98
commit cc4de1aa3a
No known key found for this signature in database
GPG key ID: 70B29D65DD8A7E31
4 changed files with 14 additions and 7 deletions

View file

@ -256,6 +256,15 @@
been changed to <literal>null</literal>.
</para>
</listitem>
<listitem>
<para>
The <literal>--target-host</literal> and
<literal>--build-host</literal> options of
<literal>nixos-rebuild</literal> no longer treat the
<literal>localhost</literal> value specially to build
on/deploy to local machine, omit the relevant flag.
</para>
</listitem>
<listitem>
<para>
The <literal>nix.readOnlyStore</literal> option has been

View file

@ -532,15 +532,15 @@
<listitem>
<para>
Specifies the NixOS target host. By setting this to something other than
<replaceable>localhost</replaceable>, the system activation will happen
an empty string, the system activation will happen
on the remote host instead of the local machine. The remote host needs to
be accessible over ssh, and for the commands <option>switch</option>,
<option>boot</option> and <option>test</option> you need root access.
</para>
<para>
If <option>--build-host</option> is not explicitly specified, building
will take place locally.
If <option>--build-host</option> is not explicitly specified or empty,
building will take place locally.
</para>
<para>

View file

@ -67,6 +67,8 @@ In addition to numerous new and upgraded packages, this release has the followin
- In `mastodon` it is now necessary to specify location of file with `PostgreSQL` database password. In `services.mastodon.database.passwordFile` parameter default value `/var/lib/mastodon/secrets/db-password` has been changed to `null`.
- The `--target-host` and `--build-host` options of `nixos-rebuild` no longer treat the `localhost` value specially to build on/deploy to local machine, omit the relevant flag.
- The `nix.readOnlyStore` option has been renamed to `boot.readOnlyNixStore` to clarify that it configures the NixOS boot process, not the Nix daemon.
## Other Notable Changes {#sec-release-23.05-notable-changes}

View file

@ -148,10 +148,6 @@ if [[ -n "$SUDO_USER" || -n $remoteSudo ]]; then
maybeSudo=(sudo --preserve-env="$preservedSudoVars" --)
fi
if [[ -z "$buildHost" && -n "$targetHost" ]]; then
buildHost="$targetHost"
fi
# log the given argument to stderr if verbose mode is on
logVerbose() {
if [ -n "$verboseScript" ]; then