pull-update: update and reboot
Some checks failed
Build / build (push) Failing after 3m42s
Some checks failed
Build / build (push) Failing after 3m42s
This commit is contained in:
@@ -2,18 +2,20 @@
|
|||||||
# CI builds the system closure on muffin (which Harmonia serves), then
|
# CI builds the system closure on muffin (which Harmonia serves), then
|
||||||
# records the output store path at /deploy/<hostname>. On boot this
|
# records the output store path at /deploy/<hostname>. On boot this
|
||||||
# service fetches that path, pulls the closure from the binary cache,
|
# service fetches that path, pulls the closure from the binary cache,
|
||||||
# and activates it.
|
# sets it as the boot profile, and reboots into it.
|
||||||
{ pkgs, hostname, ... }:
|
{ pkgs, hostname, ... }:
|
||||||
let
|
let
|
||||||
deploy-url = "https://nix-cache.sigkill.computer/deploy/${hostname}";
|
deploy-url = "https://nix-cache.sigkill.computer/deploy/${hostname}";
|
||||||
|
|
||||||
pull-update = pkgs.writeShellScript "pull-update" ''
|
pull-update = pkgs.writeShellScript "pull-update" ''
|
||||||
set -euo pipefail
|
set -uo pipefail
|
||||||
export PATH=${
|
export PATH=${
|
||||||
pkgs.lib.makeBinPath [
|
pkgs.lib.makeBinPath [
|
||||||
pkgs.curl
|
pkgs.curl
|
||||||
pkgs.coreutils
|
pkgs.coreutils
|
||||||
pkgs.nix
|
pkgs.nix
|
||||||
|
pkgs.systemd
|
||||||
|
pkgs.util-linux
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,14 +41,15 @@ let
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Pulling update: $CURRENT -> $STORE_PATH"
|
echo "Update available: $CURRENT -> $STORE_PATH"
|
||||||
nix-store -r "$STORE_PATH"
|
|
||||||
if ! nix-env -p /nix/var/nix/profiles/system --set "$STORE_PATH"; then
|
nix-store -r "$STORE_PATH" || { echo "Failed to fetch closure"; exit 1; }
|
||||||
echo "Profile locked (concurrent switch?), skipping"
|
nix-env -p /nix/var/nix/profiles/system --set "$STORE_PATH" || { echo "Failed to set profile"; exit 1; }
|
||||||
exit 0
|
"$STORE_PATH/bin/switch-to-configuration" boot || { echo "Failed to install boot entry"; exit 1; }
|
||||||
fi
|
|
||||||
"$STORE_PATH/bin/switch-to-configuration" switch
|
wall "System update installed. Rebooting in 10 seconds..."
|
||||||
echo "Update applied"
|
sleep 10
|
||||||
|
systemctl reboot
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
@@ -55,7 +58,6 @@ in
|
|||||||
after = [ "network-online.target" ];
|
after = [ "network-online.target" ];
|
||||||
wants = [ "network-online.target" ];
|
wants = [ "network-online.target" ];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
# don't restart when deploying a new config via nixos-rebuild
|
|
||||||
restartIfChanged = false;
|
restartIfChanged = false;
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
|
|||||||
Reference in New Issue
Block a user