From a03060743dff73dedf3d6368eebebf58858e8d48 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Sat, 11 Apr 2020 10:56:11 +0530 Subject: [PATCH] nixos/hydra: wrap systemPackages with hydra envvars Leave environment.variables untouched and wrap the utilities that are added to environment.systemPackages. This avoids problems where shells fail to source environment.variables. --- .../continuous-integration/hydra/default.nix | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/continuous-integration/hydra/default.nix b/nixos/modules/services/continuous-integration/hydra/default.nix index 52e4a3aed33061..ae8c2cbdb3a033 100644 --- a/nixos/modules/services/continuous-integration/hydra/default.nix +++ b/nixos/modules/services/continuous-integration/hydra/default.nix @@ -266,9 +266,24 @@ in use-substitutes = ${if cfg.useSubstitutes then "1" else "0"} ''; - environment.systemPackages = [ cfg.package ]; - - environment.variables = hydraEnv; + environment.systemPackages = [ + cfg.package + (pkgs.stdenv.mkDerivation { + name = "hydra-wrappers"; + nativeBuildInputs = [ pkgs.makeWrapper ]; + buildCommand = '' + mkdir -p $out/bin + for b in ${cfg.package}/bin/*; do + makeWrapper "$b" "$out/bin/''${b##*/}" ${ + toString (mapAttrsToList + (name: value: ''--set-default ${name} "${value}"'') hydraEnv) + } + done + ''; + meta.priority = (cfg.package.meta.priority or 0) - 1; + # favor these wrappers over the originals + }) + ]; nix.extraOptions = '' keep-outputs = true