pkgs/nixfiles: add script for installing the last system successfully built by hydra
This commit is contained in:
		
							
								
								
									
										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" | ||||
		Reference in New Issue
	
	Block a user