Add support for rebooting when a newer kernel is detected #27
2 changed files with 13 additions and 1 deletions
|
@ -113,6 +113,11 @@ Connection to itchy.scratchy.com closed.
|
||||||
built a lot of the paths from the previous deployment. However, if the remote
|
built a lot of the paths from the previous deployment. However, if the remote
|
||||||
has a slow upload bandwidth, this would not be a good idea to enable.
|
has a slow upload bandwidth, this would not be a good idea to enable.
|
||||||
|
|
||||||
|
- `reboot` *`bool`*
|
||||||
|
|
||||||
|
Whether to reboot the remote host if a newer kernel is available. Defaults to
|
||||||
|
false.
|
||||||
|
|
||||||
# Project Principles
|
# Project Principles
|
||||||
|
|
||||||
* No Premature Optimization: Make it work, then optimize it later if the
|
* No Premature Optimization: Make it work, then optimize it later if the
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
substituteOnTarget = n.substituteOnTarget or false;
|
substituteOnTarget = n.substituteOnTarget or false;
|
||||||
switch = if dryRun then "dry-activate" else "switch";
|
switch = if dryRun then "dry-activate" else "switch";
|
||||||
nixOptions = concatStringsSep " " (n.nixOptions or []);
|
nixOptions = concatStringsSep " " (n.nixOptions or []);
|
||||||
|
reboot = if ! dryRun then n.reboot or false else false;
|
||||||
|
|
||||||
script =
|
script =
|
||||||
''
|
''
|
||||||
|
@ -64,7 +65,13 @@
|
||||||
echo "🔨 Building system closure locally, copying it to remote store and activating it:"
|
echo "🔨 Building system closure locally, copying it to remote store and activating it:"
|
||||||
( set -x; NIX_SSHOPTS="-t" ${flock} -w 60 /dev/shm/nixinate-${machine} ${nixos-rebuild} ${nixOptions} ${switch} --flake ${flake}#${machine} --target-host ${user}@${host} --use-remote-sudo ${optionalString substituteOnTarget "-s"} )
|
( set -x; NIX_SSHOPTS="-t" ${flock} -w 60 /dev/shm/nixinate-${machine} ${nixos-rebuild} ${nixOptions} ${switch} --flake ${flake}#${machine} --target-host ${user}@${host} --use-remote-sudo ${optionalString substituteOnTarget "-s"} )
|
||||||
|
|
||||||
'');
|
'') + (if reboot then ''
|
||||||
|
( if ! ${openssh} -t ${user}@${host} '[ "$(readlink /run/booted-system/{initrd,kernel,kernel-modules})" = "$(readlink /nix/var/nix/profiles/system/{initrd,kernel,kernel-modules})" ]'
|
||||||
|
then
|
||||||
|
echo "🙈 Rebooting host due to newer kernel:"
|
||||||
|
set -x; ${openssh} -t ${user}@${host} "sudo reboot"
|
||||||
|
fi )
|
||||||
|
'' else "");
|
||||||
in final.writeScript "deploy-${machine}.sh" script;
|
in final.writeScript "deploy-${machine}.sh" script;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue