1
1
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-09-11 12:49:18 +03:00

fixup! buildkite-agent: fix variable expansion in hook scripts

Addresses PR review comment.
This commit is contained in:
Rodney Lorrimar 2018-05-10 11:43:46 +01:00
parent 80baf76185
commit 6d6d11fdad
2 changed files with 15 additions and 13 deletions

View File

@ -16,18 +16,16 @@ let
mkHookOptions = hooks: listToAttrs (map mkHookOption hooks);
hooksDir = let
mkHookEntry = name: value: ''
cat > $out/${name} <<'EOF'
#! ${pkgs.stdenv.shell}
set -e
${value}
EOF
chmod 755 $out/${name}
'';
in pkgs.runCommand "buildkite-agent-hooks" {} ''
mkdir $out
${concatStringsSep "\n" (mapAttrsToList mkHookEntry (filterAttrs (n: v: v != null) cfg.hooks))}
'';
mkHookEntry = name: value: {
inherit name;
path = pkgs.writeScript "buildkite-agent-hook-${name}" ''
#! ${pkgs.stdenv.shell}
set -e
${value}
'';
};
in pkgs.linkFarm "buildkite-agent-hooks"
(mapAttrsToList mkHookEntry (filterAttrs (n: v: v != null) cfg.hooks));
in

View File

@ -12,7 +12,7 @@ in
extraConfig = "yolo=1";
openssh.privateKeyPath = "/dev/null";
openssh.publicKeyPath = "/dev/null";
hooks.command = "echo test";
hooks.command = "echo test hook";
inherit tokenPath;
};
@ -24,5 +24,9 @@ in
script=$(cat ${config.out}/Library/LaunchDaemons/org.nixos.buildkite-agent.plist | awk -F'[< ]' '$3 ~ "^/nix/store/.*" {print $3}')
grep "yolo=1" "$script"
grep "${tokenPath}" "$script"
echo "checking that a buildkite-agent hook works" >&2
hooks_path=$(cat $script | awk -F'"' '/^hooks-path/ {print $2;}')
$hooks_path/command | grep test
'';
}