Compare commits
5 Commits
d937ce3c5c
...
8cbed24e1e
Author | SHA1 | Date | |
---|---|---|---|
|
8cbed24e1e | ||
|
6860ae0f1e | ||
b0259542e4 | |||
491a4c2632 | |||
437e0f4a35 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,2 @@
|
||||
result
|
||||
result*
|
||||
.Trash-1000
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
{
|
||||
|
||||
fonts.enableDefaultFonts = true;
|
||||
fonts.fonts = with pkgs; [
|
||||
fonts.enableDefaultPackages = true;
|
||||
fonts.packages = with pkgs; [
|
||||
roboto
|
||||
roboto-mono
|
||||
noto-fonts
|
||||
|
18
flake.lock
18
flake.lock
@ -215,11 +215,11 @@
|
||||
},
|
||||
"nixpkgs-krypton": {
|
||||
"locked": {
|
||||
"lastModified": 1693471703,
|
||||
"narHash": "sha256-0l03ZBL8P1P6z8MaSDS/MvuU8E75rVxe5eE1N6gxeTo=",
|
||||
"lastModified": 1693565476,
|
||||
"narHash": "sha256-ya00zHt7YbPo3ve/wNZ/6nts61xt7wK/APa6aZAfey0=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "3e52e76b70d5508f3cec70b882a29199f4d1ee85",
|
||||
"rev": "aa8aa7e2ea35ce655297e8322dc82bf77a31d04b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -231,11 +231,11 @@
|
||||
},
|
||||
"nixpkgs-schule": {
|
||||
"locked": {
|
||||
"lastModified": 1693471703,
|
||||
"narHash": "sha256-0l03ZBL8P1P6z8MaSDS/MvuU8E75rVxe5eE1N6gxeTo=",
|
||||
"lastModified": 1693565476,
|
||||
"narHash": "sha256-ya00zHt7YbPo3ve/wNZ/6nts61xt7wK/APa6aZAfey0=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "3e52e76b70d5508f3cec70b882a29199f4d1ee85",
|
||||
"rev": "aa8aa7e2ea35ce655297e8322dc82bf77a31d04b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -247,11 +247,11 @@
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1693471703,
|
||||
"narHash": "sha256-0l03ZBL8P1P6z8MaSDS/MvuU8E75rVxe5eE1N6gxeTo=",
|
||||
"lastModified": 1693565476,
|
||||
"narHash": "sha256-ya00zHt7YbPo3ve/wNZ/6nts61xt7wK/APa6aZAfey0=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "3e52e76b70d5508f3cec70b882a29199f4d1ee85",
|
||||
"rev": "aa8aa7e2ea35ce655297e8322dc82bf77a31d04b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -106,6 +106,7 @@
|
||||
nixfiles-update-ssh-host-keys
|
||||
pyexcel-xlsx
|
||||
pyexcel-webio
|
||||
update-from-hydra
|
||||
uptimestatus
|
||||
wetter;
|
||||
};
|
||||
|
@ -13,6 +13,7 @@
|
||||
./monitoring
|
||||
./nginx-port-forward
|
||||
./nixfiles
|
||||
./update-from-hydra
|
||||
./wg-clerie
|
||||
];
|
||||
}
|
||||
|
95
modules/update-from-hydra/default.nix
Normal file
95
modules/update-from-hydra/default.nix
Normal file
@ -0,0 +1,95 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.services.update-from-hydra;
|
||||
|
||||
repositoryOpts = { config, ... }@moduleAttrs: {
|
||||
options = {
|
||||
|
||||
enable = mkEnableOption "Make a hydra build output availiable with a symlink and keep it up to date";
|
||||
|
||||
resultPath = mkOption {
|
||||
type = types.path;
|
||||
description = ''
|
||||
Path to the symlink pointing to the hydra build output store path
|
||||
'';
|
||||
};
|
||||
|
||||
hydraUrl = mkOption {
|
||||
type = types.str;
|
||||
description = ''
|
||||
'';
|
||||
};
|
||||
|
||||
hydraProject = mkOption {
|
||||
type = types.str;
|
||||
description = ''
|
||||
Hydra project name
|
||||
'';
|
||||
};
|
||||
|
||||
hydraJobset = mkOption {
|
||||
type = types.str;
|
||||
description = ''
|
||||
Hydra jobset name
|
||||
'';
|
||||
};
|
||||
|
||||
hydraJob = mkOption {
|
||||
type = types.str;
|
||||
description = ''
|
||||
Hydra job name
|
||||
'';
|
||||
};
|
||||
|
||||
nixStoreUri = mkOption {
|
||||
type = types.str;
|
||||
description = ''
|
||||
'';
|
||||
};
|
||||
|
||||
startAt = mkOption {
|
||||
type = with types; either str (listOf str);
|
||||
default = "hourly";
|
||||
description = ''
|
||||
How often the directory should be updated.
|
||||
Formatspecified by `systemd.time 7`.
|
||||
This value can also be a list of `systemd.time 7` formatted
|
||||
strings, in which case the service will be started on multiple
|
||||
schedules.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
in {
|
||||
options = {
|
||||
services.update-from-hydra = {
|
||||
|
||||
paths = mkOption {
|
||||
type = with types; attrsOf (submodule repositoryOpts);
|
||||
default = {};
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
systemd.services = (mapAttrs' (name: path: nameValuePair "update-from-hydra-${name}" (mkIf path.enable {
|
||||
inherit (path) startAt;
|
||||
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
script = ''
|
||||
${pkgs.update-from-hydra}/bin/update-from-hydra --hydra-url "${path.hydraUrl}" --hydra-project "${path.hydraProject}" --hydra-jobset "${path.hydraJobset}" --hydra-job "${path.hydraJob}" --nix-store-uri "${path.nixStoreUri}" --gcroot-name "${name}" "${path.resultPath}"
|
||||
'';
|
||||
})
|
||||
) cfg.paths);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user