pkgs/nixfiles: add script for installing the last system successfully built by hydra
This commit is contained in:
parent
8e98e29e97
commit
e711bc69a1
@ -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
|
||||
|
11
pkgs/nixfiles/nixfiles-system-sync-to-hydra.nix
Normal file
11
pkgs/nixfiles/nixfiles-system-sync-to-hydra.nix
Normal 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
|
||||
];
|
||||
}
|
19
pkgs/nixfiles/nixfiles-system-sync-to-hydra.sh
Executable file
19
pkgs/nixfiles/nixfiles-system-sync-to-hydra.sh
Executable 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"
|
@ -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 {};
|
||||
|
Loading…
Reference in New Issue
Block a user