Compare commits

..

3 Commits

Author SHA1 Message Date
20df895312 pull-update: update and reboot
Some checks failed
Build / build (push) Failing after 3m42s
2026-04-16 00:50:13 -04:00
4542a5002c fix pull-update 2026-04-16 00:15:29 -04:00
d0d8d5b9d2 ci: prevent gc from deleting 2026-04-15 23:25:45 -04:00
2 changed files with 39 additions and 8 deletions

View File

@@ -24,11 +24,19 @@ jobs:
run: | run: |
mkdir -p /var/lib/dotfiles-deploy mkdir -p /var/lib/dotfiles-deploy
readlink -f result > /var/lib/dotfiles-deploy/yarn readlink -f result > /var/lib/dotfiles-deploy/yarn
nix-store --add-root /var/lib/dotfiles-deploy/yarn-gcroot -r "$(readlink -f result)"
- name: Build NixOS configuration (mreow) - name: Build NixOS configuration (mreow)
run: | run: |
nix build .#nixosConfigurations.mreow.config.system.build.toplevel -L nix build .#nixosConfigurations.mreow.config.system.build.toplevel -L
- name: Record mreow store path
continue-on-error: true
run: |
mkdir -p /var/lib/dotfiles-deploy
readlink -f result > /var/lib/dotfiles-deploy/mreow
nix-store --add-root /var/lib/dotfiles-deploy/mreow-gcroot -r "$(readlink -f result)"
- name: Notify success - name: Notify success
if: success() if: success()
run: | run: |

View File

@@ -2,15 +2,33 @@
# 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=${
pkgs.lib.makeBinPath [
pkgs.curl
pkgs.coreutils
pkgs.nix
pkgs.systemd
pkgs.util-linux
]
}
STORE_PATH=$(${pkgs.lib.getExe pkgs.curl} -sf --max-time 30 "${deploy-url}" || true) # wait for actual connectivity, not just networkd "up"
for i in $(seq 1 30); do
if curl -sf --max-time 5 "${deploy-url}" >/dev/null; then
break
fi
echo "Waiting for network... ($i/30)"
sleep 2
done
STORE_PATH=$(curl -sf --max-time 30 "${deploy-url}" || true)
if [ -z "$STORE_PATH" ]; then if [ -z "$STORE_PATH" ]; then
echo "Server unreachable or no deployment available, skipping" echo "Server unreachable or no deployment available, skipping"
@@ -23,11 +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"
nix-env -p /nix/var/nix/profiles/system --set "$STORE_PATH" nix-store -r "$STORE_PATH" || { echo "Failed to fetch closure"; exit 1; }
"$STORE_PATH/bin/switch-to-configuration" switch nix-env -p /nix/var/nix/profiles/system --set "$STORE_PATH" || { echo "Failed to set profile"; exit 1; }
echo "Update applied" "$STORE_PATH/bin/switch-to-configuration" boot || { echo "Failed to install boot entry"; exit 1; }
wall "System update installed. Rebooting in 10 seconds..."
sleep 10
systemctl reboot
''; '';
in in
{ {
@@ -36,6 +58,7 @@ 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" ];
restartIfChanged = false;
serviceConfig = { serviceConfig = {
Type = "oneshot"; Type = "oneshot";
ExecStart = pull-update; ExecStart = pull-update;