Created
January 7, 2020 16:15
-
-
Save ocharles/fa4ad515d723108a0e0663b1af383e49 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs, ... }: | |
{ | |
systemd.services.auto-upgrade = { | |
serviceConfig.Type = "oneshot"; | |
startAt = "hourly"; | |
# This is required as otherwise the call to "switch" will stop this very | |
# unit, preventing the upgrade from completing. | |
unitConfig.X-StopOnRemoval = false; | |
script = '' | |
# Fetch the name of the latest output | |
OUT=$( curl --location --silent 'http://hydra/job/<name>/'"$(< /etc/tracking)"'/latest/api/get-info' | jq -r .outPath ) | |
# Realise the output and make it valid. This will fetch the output from | |
# Hydra. | |
nix-store --realise --ignore-unknown "$OUT" | |
# Run "switch" to activate the configuration. If the fetch failed, this | |
# file won't exist and the unit will fail. | |
"$OUT/bin/switch-to-configuration" boot | |
# Add a GC root. | |
nix-env --profile /nix/var/nix/profiles/system --set "$OUT" | |
''; | |
path = with pkgs; [ curl jq nix ]; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment