Nixos-rebuild: Difference between revisions
Correct position of references and categories |
nixos-rebuild-ng is the new default |
||
| (One intermediate revision by one other user not shown) | |||
| Line 3: | Line 3: | ||
'''nixos-rebuild''' is the NixOS command used to apply changes made to the system configuration. It can also be used for a variety of other tasks related to managing the state of a NixOS system. | '''nixos-rebuild''' is the NixOS command used to apply changes made to the system configuration. It can also be used for a variety of other tasks related to managing the state of a NixOS system. | ||
<code>nixos-rebuild-ng</code> is a rewrite of <code>nixos-rebuild</code> in Python instead of Bash which has better performance and more features, and | <code>nixos-rebuild-ng</code> is a rewrite of <code>nixos-rebuild</code> in Python instead of Bash which has better performance and more features, and is the default in NixOS 25.11. | ||
== Usage == | == Usage == | ||
| Line 40: | Line 40: | ||
<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>- | If you are rebuilding a remote host as a non-root user, use the <code>--sudo</code> option to elevate on the remote machine during the rebuilding process: | ||
< | <syntaxhighlight lang="console"> | ||
$ nixos-rebuild --target-host user@example.com - | $ nixos-rebuild --target-host user@example.com --sudo switch | ||
</ | </syntaxhighlight> | ||
To enter a password while using remote sudo, | To enter a password while using remote sudo, add the flag <code>--ask-sudo-password</code>. | ||
{{Note|When rebuilding a remote host, you may see similar errors to the following: | {{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 signature by a trusted key</blockquote> | <blockquote>error: cannot add path '/nix/store/...' because it lacks a signature by a trusted key</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.}} | 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. Please note that this is equivalent to having root access, [https://nix.dev/manual/nix/2.34/command-ref/conf-file.html#conf-trusted-users as described in the Nix manual].}} | ||
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. | ||