nixos-rebuild: support --upgrade-all and document --upgrade (#83327)
This commit is contained in:
parent
bb33cdd44b
commit
d9a93852d4
@ -53,9 +53,17 @@
|
|||||||
</arg>
|
</arg>
|
||||||
</group>
|
</group>
|
||||||
<sbr />
|
<sbr />
|
||||||
|
|
||||||
<arg>
|
<arg>
|
||||||
|
<group choice='req'>
|
||||||
|
<arg choice='plain'>
|
||||||
<option>--upgrade</option>
|
<option>--upgrade</option>
|
||||||
</arg>
|
</arg>
|
||||||
|
<arg choice='plain'>
|
||||||
|
<option>--upgrade-all</option>
|
||||||
|
</arg>
|
||||||
|
</group>
|
||||||
|
</arg>
|
||||||
|
|
||||||
<arg>
|
<arg>
|
||||||
<option>--install-bootloader</option>
|
<option>--install-bootloader</option>
|
||||||
@ -334,9 +342,23 @@
|
|||||||
<term>
|
<term>
|
||||||
<option>--upgrade</option>
|
<option>--upgrade</option>
|
||||||
</term>
|
</term>
|
||||||
|
<term>
|
||||||
|
<option>--upgrade-all</option>
|
||||||
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Fetch the latest version of NixOS from the NixOS channel.
|
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>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
@ -23,6 +23,7 @@ buildNix=1
|
|||||||
fast=
|
fast=
|
||||||
rollback=
|
rollback=
|
||||||
upgrade=
|
upgrade=
|
||||||
|
upgrade_all=
|
||||||
repair=
|
repair=
|
||||||
profile=/nix/var/nix/profiles/system
|
profile=/nix/var/nix/profiles/system
|
||||||
buildHost=
|
buildHost=
|
||||||
@ -55,6 +56,10 @@ while [ "$#" -gt 0 ]; do
|
|||||||
--upgrade)
|
--upgrade)
|
||||||
upgrade=1
|
upgrade=1
|
||||||
;;
|
;;
|
||||||
|
--upgrade-all)
|
||||||
|
upgrade=1
|
||||||
|
upgrade_all=1
|
||||||
|
;;
|
||||||
--repair)
|
--repair)
|
||||||
repair=1
|
repair=1
|
||||||
extraBuildFlags+=("$i")
|
extraBuildFlags+=("$i")
|
||||||
@ -223,15 +228,22 @@ if [ "$action" = switch -o "$action" = boot -o "$action" = test ]; then
|
|||||||
fi
|
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
|
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
|
for channelpath in /nix/var/nix/profiles/per-user/root/channels/*; do
|
||||||
if [ -e "$channelpath/.update-on-nixos-rebuild" ]; then
|
channel_name=$(basename "$channelpath")
|
||||||
nix-channel --update "$(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
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user