From ff6d082fc3de78fc783ecf3ab4be570facc95db6 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 22 May 2019 19:21:40 +0800 Subject: [PATCH] Revert "nixbld: refactor hydra-www-outputs to generate etags for nginx" This reverts commit 8e3f1cc5a0ffe313ceb58a6789a0e2ad66884153. --- nixbld-etc-nixos/configuration.nix | 35 ++++++---- nixbld-etc-nixos/hydra-www-hook.sh | 26 ------- nixbld-etc-nixos/hydra-www-outputs.nix | 94 -------------------------- 3 files changed, 22 insertions(+), 133 deletions(-) delete mode 100755 nixbld-etc-nixos/hydra-www-hook.sh delete mode 100644 nixbld-etc-nixos/hydra-www-outputs.nix diff --git a/nixbld-etc-nixos/configuration.nix b/nixbld-etc-nixos/configuration.nix index 8501e9c..706b64c 100644 --- a/nixbld-etc-nixos/configuration.nix +++ b/nixbld-etc-nixos/configuration.nix @@ -4,12 +4,14 @@ { config, pkgs, ... }: +let + hydraWwwOutputs = "/var/www/hydra-outputs"; +in { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix ./homu/nixos-module.nix - ./hydra-www-outputs.nix ]; # Use the systemd-boot EFI boot loader. @@ -137,20 +139,25 @@ ACTION=="add", SUBSYSTEM=="tty", \ '' binary_cache_secret_key_file = /etc/nixos/secret/nixbld.m-labs.hk-1 max_output_size = 5500000000 + + + job = artiq:main:artiq-manual-html + command = ln -sf $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-manual-html-beta + + + job = artiq:main:artiq-manual-latexpdf + command = ln -sf $(jq -r '.outputs[0].path' < $HYDRA_JSON) ${hydraWwwOutputs}/artiq-manual-latexpdf-beta + ''; }; - services.hydraWwwOutputs = { - "m-labs.hk" = { - "artiq-manual-beta-html" = { - job = "artiq:main:artiq-manual-html"; - httpPath = "/artiq/manual-beta"; - outputPath = "share/doc/artiq-manual/html"; - }; - "artiq-manual-beta-latexpdf" = { - job = "artiq:main:artiq-manual-latexpdf"; - httpPath = "/artiq/manual-beta.pdf"; - outputPath = "share/doc/artiq-manual/ARTIQ.pdf"; - }; + 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}" ]; }; }; @@ -223,6 +230,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; diff --git a/nixbld-etc-nixos/hydra-www-hook.sh b/nixbld-etc-nixos/hydra-www-hook.sh deleted file mode 100755 index 2506e3c..0000000 --- a/nixbld-etc-nixos/hydra-www-hook.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# Argument 1: -CONF=$1 -# Argument 2: HTTP location -LOCATION=$2 -# Argument 3: HTTP alias target within the derivation output -HTTP_PATH=$3 -# Get path of first output -OUTPUT=$(jq -r '.outputs[0].path' < $HYDRA_JSON) -HASH=${OUTPUT:11:32} -ROOT="$OUTPUT/$HTTP_PATH" - -cat > $CONF < - job = ${cfg.job} - command = ${hook}/bin/hydra-www-hook.sh ${hydraWwwOutputs}/${name}.conf ${cfg.httpPath} ${cfg.outputPath} - - '') cfg.${vhost} - )) (builtins.attrNames cfg) - ); - }; - - config.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}" - ] ++ - (builtins.concatMap (vhost: - map (name: - "${pkgs.coreutils}/bin/touch ${hydraWwwOutputs}/${name}.conf" - ) (builtins.attrNames cfg.${vhost}) - ) (builtins.attrNames cfg)) ++ [ - "${pkgs.coreutils}/bin/chown -R hydra-queue-runner:hydra ${hydraWwwOutputs}" - ]; - }; - }; - - # Allow the hook to reload nginx - config.security.sudo.extraRules = [ { - users = [ "hydra-queue-runner" ]; - commands = [ { - command = "${config.systemd.package}/bin/systemctl reload nginx"; - options = [ "NOPASSWD" ]; - } ]; - } ]; - - config.services.nginx = { - virtualHosts = builtins.mapAttrs (vhost: cfg': { - extraConfig = builtins.concatStringsSep "\n" ( - map (name: - "include ${hydraWwwOutputs}/${name}.conf;" - ) (builtins.attrNames cfg') - ); - }) cfg; - }; -}