pkgs/update-from-hydra: Add script that updates paths based on hydra builds
This commit is contained in:
@@ -8,6 +8,7 @@ self: super: {
|
||||
nixfiles-update-ssh-host-keys = self.callPackage ./nixfiles/nixfiles-update-ssh-host-keys.nix {};
|
||||
pyexcel-xlsx = self.python3.pkgs.callPackage ./pyexcel-xlsx {};
|
||||
pyexcel-webio = self.python3.pkgs.callPackage ./pyexcel-webio {};
|
||||
update-from-hydra = self.callPackage ./update-from-hydra {};
|
||||
uptimestatus = self.python3.pkgs.callPackage ./uptimestatus {};
|
||||
wetter = self.python3.pkgs.callPackage ./wetter {
|
||||
inherit (self) pkg-config libsass;
|
||||
|
12
pkgs/update-from-hydra/default.nix
Normal file
12
pkgs/update-from-hydra/default.nix
Normal file
@@ -0,0 +1,12 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "update-from-hydra";
|
||||
text = builtins.readFile ./update-from-hydra.sh;
|
||||
runtimeInputs = with pkgs; [
|
||||
curl
|
||||
jq
|
||||
nix
|
||||
];
|
||||
}
|
||||
|
74
pkgs/update-from-hydra/update-from-hydra.sh
Normal file
74
pkgs/update-from-hydra/update-from-hydra.sh
Normal file
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--hydra-url)
|
||||
HYDRA_URL="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
--hydra-project)
|
||||
HYDRA_PROJECT="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
--hydra-jobset)
|
||||
HYDRA_JOBSET="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
--hydra-job)
|
||||
HYDRA_JOB="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
--nix-store-uri)
|
||||
NIX_STORE_URI="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
--gcroot-name)
|
||||
GCROOT_NAME="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
-*)
|
||||
echo "Unknown option $1"
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
ARGS+=("$1")
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
set -- "${ARGS[@]}"
|
||||
|
||||
HYDRA_JOB_URL="${HYDRA_URL}/job/${HYDRA_PROJECT}/${HYDRA_JOBSET}/${HYDRA_JOB}/latest-finished"
|
||||
RESULT_PATH="$1"
|
||||
|
||||
echo "Updating ${RESULT_PATH} from ${HYDRA_PROJECT}:${HYDRA_JOBSET}:${HYDRA_JOB}"
|
||||
|
||||
echo "Make sure symlink directory exist"
|
||||
mkdir -p "$(dirname "${RESULT_PATH}")"
|
||||
|
||||
echo "Fetching job output"
|
||||
STORE_PATH="$(curl -s -L -H "Accept: application/json" "${HYDRA_JOB_URL}" | jq -r .buildoutputs.out.path)"
|
||||
|
||||
echo "Copying path"
|
||||
nix copy --from "${NIX_STORE_URI}" "${STORE_PATH}"
|
||||
|
||||
echo "Activate path"
|
||||
ln -fsn "${STORE_PATH}" "${RESULT_PATH}"
|
||||
|
||||
if [[ -n $GCROOT_NAME ]]; then
|
||||
GCROOT_PATH="/nix/var/nix/gcroots/update-from-hydra/${GCROOT_NAME}"
|
||||
echo "Add to gcroot ${GCROOT_PATH}"
|
||||
mkdir -p "$(dirname "${GCROOT_PATH}")"
|
||||
|
||||
ln -fsn "${RESULT_PATH}" "${GCROOT_PATH}"
|
||||
fi
|
||||
|
Reference in New Issue
Block a user