From 71d631d416db09fa229f859f9cb5c1a1a7ff9545 Mon Sep 17 00:00:00 2001 From: Stephan Maka Date: Mon, 20 May 2019 18:55:47 +0200 Subject: [PATCH] nixbld: gather and serve artiq-manual from hydra outputs Should resolve Gitea issue #12. --- nixbld-etc-nixos/configuration.nix | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/nixbld-etc-nixos/configuration.nix b/nixbld-etc-nixos/configuration.nix index 1d25390..a5415c6 100644 --- a/nixbld-etc-nixos/configuration.nix +++ b/nixbld-etc-nixos/configuration.nix @@ -4,6 +4,9 @@ { config, pkgs, ... }: +let + hydraWwwOutputs = "/var/www/hydra-outputs"; +in { imports = [ # Include the results of the hardware scan. @@ -143,14 +146,25 @@ ACTION=="add", SUBSYSTEM=="tty", \ job = artiq:main:artiq-manual-html - command = echo Build $(jq -r .build $HYDRA_JSON) \($(jq -r .project $HYDRA_JSON):$(jq -r .jobset $HYDRA_JSON):$(jq -r .job $HYDRA_JSON)\) finished: $(jq -r .products[0].path $HYDRA_JSON) + command = ln -sf $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-manual-html-beta job = artiq:main:artiq-manual-latexpdf - command = echo Build $(jq -r .build $HYDRA_JSON) \($(jq -r .project $HYDRA_JSON):$(jq -r .jobset $HYDRA_JSON):$(jq -r .job $HYDRA_JSON)\) finished: $(jq -r .products[0].path $HYDRA_JSON) + command = ln -sf $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-manual-latexpdf-beta ''; }; + systemd.services.hydra-www-outputs-init = { + description = "Set up a hydra-owned directory for build outputs"; + wantedBy = [ "multi-user.target" ]; + requiredBy = [ "hydra-queue-runner.service" ]; + before = [ "hydra-queue-runner.service" ]; + serviceConfig = { + Type = "oneshot"; + ExecStart = [ "${pkgs.coreutils}/bin/mkdir -p ${hydraWwwOutputs}" "${pkgs.coreutils}/bin/chown hydra-queue-runner:hydra ${hydraWwwOutputs}" ]; + }; + }; + nix.extraOptions = '' secret-key-files = /etc/nixos/secret/nixbld.m-labs.hk-1 @@ -213,6 +227,8 @@ ACTION=="add", SUBSYSTEM=="tty", \ locations."/gateware.html".extraConfig = '' return 301 /migen/; ''; + locations."/artiq/manual-beta".alias = "${hydraWwwOutputs}/artiq-manual-html-beta/share/doc/artiq-manual/html"; + locations."/artiq/manual-beta.pdf".alias = "${hydraWwwOutputs}/artiq-manual-latexpdf-beta/share/doc/artiq-manual/ARTIQ.pdf"; }; "www.m-labs.hk" = { addSSL = true;