# SPDX-FileCopyrightText: 2020 Luke Granger-Brown <depot@lukegb.com>
#
# SPDX-License-Identifier: Apache-2.0

{ pkgs, depot, ... }:
let
  version = "hpd-0.4.0";
  newSrc = pkgs.fetchhg {
    url = "https://mirror.octobus.net/heptapod/heptapod-runner";
    rev = "8b729b09e365";
    sha256 = "1769kcpgmhnibdmhvsdnylsdk8w08c7mgxi23vrx7vjfxgij1bdr";
  };
in
{
  heptapod-runner = pkgs.gitlab-runner.overrideAttrs (oldAttrs: rec {
    inherit version;
    buildInputs = oldAttrs.buildInputs ++ [ pkgs.makeWrapper ];
    src = newSrc;
    patches = [ ./fix-shell-path.patch ];
  });
  heptapod-runner-mercurial = pkgs.symlinkJoin {
    name = pkgs.mercurial.name;
    paths = [ pkgs.mercurial ];
    postBuild = ''
      mkdir -p "$out/etc/mercurial"
      cp "${newSrc}/dockerfiles/runner-helper/runner.hgrc" "$out/etc/mercurial/hgrc"
    '';
  };
}