mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-31 04:04:45 +00:00
Merge pull request #75 from rvl/buildkite-agent-fixes
buildkite-agent fixes
This commit is contained in:
commit
192e2b40e0
2 changed files with 26 additions and 15 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
|
||||
|
||||
|
@ -221,11 +219,20 @@ in
|
|||
'';
|
||||
|
||||
serviceConfig = {
|
||||
KeepAlive = true;
|
||||
RunAtLoad = true;
|
||||
ProcessType = "Interactive";
|
||||
ThrottleInterval = 30;
|
||||
|
||||
# The combination of KeepAlive.NetworkState and WatchPaths
|
||||
# will ensure that buildkite-agent is started on boot, but
|
||||
# after networking is available (so the hostname is
|
||||
# correct).
|
||||
RunAtLoad = true;
|
||||
KeepAlive.NetworkState = true;
|
||||
WatchPaths = [
|
||||
"/etc/resolv.conf"
|
||||
"/Library/Preferences/SystemConfiguration/NetworkInterfaces.plist"
|
||||
];
|
||||
|
||||
GroupName = "buildkite-agent";
|
||||
UserName = "buildkite-agent";
|
||||
WorkingDirectory = config.users.users.buildkite-agent.home;
|
||||
|
|
|
@ -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