1
0
Fork 0

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

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

View File

@ -109,6 +109,7 @@
nixfiles-auto-install
nixfiles-generate-backup-secrets
nixfiles-generate-config
nixfiles-system-sync-to-hydra
nixfiles-updated-inputs
nixfiles-update-ssh-host-keys
nixos-firewall-tool

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"

View File

@ -6,6 +6,7 @@ self: super: {
nixfiles-auto-install = self.callPackage ./nixfiles/nixfiles-auto-install.nix {};
nixfiles-generate-backup-secrets = self.callPackage ./nixfiles/nixfiles-generate-backup-secrets.nix {};
nixfiles-generate-config = self.callPackage ./nixfiles/nixfiles-generate-config.nix {};
nixfiles-system-sync-to-hydra = self.callPackage ./nixfiles/nixfiles-system-sync-to-hydra.nix {};
nixfiles-updated-inputs = self.callPackage ./nixfiles/nixfiles-updated-inputs.nix {};
nixfiles-update-ssh-host-keys = self.callPackage ./nixfiles/nixfiles-update-ssh-host-keys.nix {};
nixos-firewall-tool = self.callPackage ./nixos-firewall-tool {};