Nixos-rebuild: Difference between revisions

imported>Alyaeanyx
mNo edit summary
imported>Williamvds
Add --use-remote-sudo option and hints
Line 32: Line 32:
Note that this will often require using a different configuration than the one in <code>/etc/nixos</code>. See the '''Specifying a different configuration location''' section for details.
Note that this will often require using a different configuration than the one in <code>/etc/nixos</code>. See the '''Specifying a different configuration location''' section for details.
<code>--build-host</code> and <code>--target-host</code> can be used simultaneously, even with different hosts.
<code>--build-host</code> and <code>--target-host</code> can be used simultaneously, even with different hosts.
If you are rebuilding a remote host as a non-root user, use the <code>--use-remote-sudo</code> option to elevate on the remote machine during the rebuilding process:
<syntaxHighlight lang=console>
$ nixos-rebuild --target-host user@example.com --use-remote-sudo switch
</syntaxHighlight>
{{Note|When rebuilding a remote host, you may see similar errors to the following:
<blockquote>error: cannot add path '/nix/store/...' because it lacks a valid signature</blockquote>
If this occurs, add your non-root user or group to the <code>trusted-users</code> list in <code>/etc/nix/nix.conf</code>, which is the <code>nix.settings.trusted-users</code> option in NixOS.}}


For a full list of sub-commands and options, see the <code>nixos-rebuild</code> man page.
For a full list of sub-commands and options, see the <code>nixos-rebuild</code> man page.