mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-26 23:52:33 +00:00
nixos-rebuild: support --upgrade-all and document --upgrade (#83327)
This commit is contained in:
parent
bb33cdd44b
commit
d9a93852d4
|
@ -52,10 +52,18 @@
|
|||
<option>build-vm-with-bootloader</option>
|
||||
</arg>
|
||||
</group>
|
||||
<sbr />
|
||||
<arg>
|
||||
<option>--upgrade</option>
|
||||
</arg>
|
||||
<sbr />
|
||||
|
||||
<arg>
|
||||
<group choice='req'>
|
||||
<arg choice='plain'>
|
||||
<option>--upgrade</option>
|
||||
</arg>
|
||||
<arg choice='plain'>
|
||||
<option>--upgrade-all</option>
|
||||
</arg>
|
||||
</group>
|
||||
</arg>
|
||||
|
||||
<arg>
|
||||
<option>--install-bootloader</option>
|
||||
|
@ -334,9 +342,23 @@
|
|||
<term>
|
||||
<option>--upgrade</option>
|
||||
</term>
|
||||
<term>
|
||||
<option>--upgrade-all</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Fetch the latest version of NixOS from the NixOS channel.
|
||||
<para>
|
||||
Update the root user's channel named <literal>nixos</literal>
|
||||
before rebuilding the system.
|
||||
</para>
|
||||
<para>
|
||||
In addition to the <literal>nixos</literal> channel, the root
|
||||
user's channels which have a file named
|
||||
<literal>.update-on-nixos-rebuild</literal> in their base
|
||||
directory will also be updated.
|
||||
</para>
|
||||
<para>
|
||||
Passing <option>--upgrade-all</option> updates all of the root
|
||||
user's channels.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
|
|
@ -23,6 +23,7 @@ buildNix=1
|
|||
fast=
|
||||
rollback=
|
||||
upgrade=
|
||||
upgrade_all=
|
||||
repair=
|
||||
profile=/nix/var/nix/profiles/system
|
||||
buildHost=
|
||||
|
@ -55,6 +56,10 @@ while [ "$#" -gt 0 ]; do
|
|||
--upgrade)
|
||||
upgrade=1
|
||||
;;
|
||||
--upgrade-all)
|
||||
upgrade=1
|
||||
upgrade_all=1
|
||||
;;
|
||||
--repair)
|
||||
repair=1
|
||||
extraBuildFlags+=("$i")
|
||||
|
@ -223,15 +228,22 @@ if [ "$action" = switch -o "$action" = boot -o "$action" = test ]; then
|
|||
fi
|
||||
|
||||
|
||||
# If ‘--upgrade’ is given, run ‘nix-channel --update nixos’.
|
||||
# If ‘--upgrade’ or `--upgrade-all` is given,
|
||||
# run ‘nix-channel --update nixos’.
|
||||
if [[ -n $upgrade && -z $_NIXOS_REBUILD_REEXEC && -z $flake ]]; then
|
||||
nix-channel --update nixos
|
||||
# If --upgrade-all is passed, or there are other channels that
|
||||
# contain a file called ".update-on-nixos-rebuild", update them as
|
||||
# well. Also upgrade the nixos channel.
|
||||
|
||||
# If there are other channels that contain a file called
|
||||
# ".update-on-nixos-rebuild", update them as well.
|
||||
for channelpath in /nix/var/nix/profiles/per-user/root/channels/*; do
|
||||
if [ -e "$channelpath/.update-on-nixos-rebuild" ]; then
|
||||
nix-channel --update "$(basename "$channelpath")"
|
||||
channel_name=$(basename "$channelpath")
|
||||
|
||||
if [[ "$channel_name" == "nixos" ]]; then
|
||||
nix-channel --update "$channel_name"
|
||||
elif [ -e "$channelpath/.update-on-nixos-rebuild" ]; then
|
||||
nix-channel --update "$channel_name"
|
||||
elif [[ -n $upgrade_all ]] ; then
|
||||
nix-channel --update "$channel_name"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue