1
0

pkgs/nixfiles: add script for installing the last system successfully built by hydra

This commit is contained in:
2023-11-05 17:24:27 +01:00
parent 8e98e29e97
commit e711bc69a1
4 changed files with 32 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
{ pkgs, ... }:
pkgs.writeShellApplication {
name = "nixfiles-system-sync-to-hydra";
text = builtins.readFile ./nixfiles-system-sync-to-hydra.sh;
runtimeInputs = with pkgs; [
curl
jq
nix
];
}

View File

@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -euo pipefail
HYDRA_JOB_URL="https://hydra.clerie.de/job/nixfiles/nixfiles/nixosConfigurations.$(hostname)/latest-finished"
echo "Fetching job output from ${HYDRA_JOB_URL}"
STORE_PATH="$(curl --fail -s -L -H "Accept: application/json" "${HYDRA_JOB_URL}" | jq -r ".buildoutputs.out.path")"
echo "Download ${STORE_PATH}"
nix copy --from "https://nix-cache.clerie.de" "${STORE_PATH}"
echo "Add to system profile"
nix-env -p "/nix/var/nix/profiles/system" --set "${STORE_PATH}"
echo "Activate system"
/nix/var/nix/profiles/system/bin/switch-to-configuration switch
echo "Finished system upgrade"