mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-05 08:17:01 +00:00
fixup! buildkite-agent: fix variable expansion in hook scripts
Addresses PR review comment.
This commit is contained in:
parent
80baf76185
commit
6d6d11fdad
2 changed files with 15 additions and 13 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
'';
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue