mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-06 17:13:24 -05:00
122 lines
4 KiB
Nix
122 lines
4 KiB
Nix
{
|
|
lib,
|
|
stdenv,
|
|
buildGoModule,
|
|
dependabot-cli,
|
|
dockerTools,
|
|
fetchFromGitHub,
|
|
installShellFiles,
|
|
makeWrapper,
|
|
symlinkJoin,
|
|
testers,
|
|
}:
|
|
let
|
|
pname = "dependabot-cli";
|
|
version = "1.89.0";
|
|
|
|
# `tag` is what `dependabot` uses to find the relevant docker images.
|
|
tag = "nixpkgs-dependabot-cli-${version}";
|
|
|
|
# Get these hashes from
|
|
# nix run nixpkgs#nix-prefetch-docker -- --image-name ghcr.io/github/dependabot-update-job-proxy/dependabot-update-job-proxy --image-tag latest --final-image-name dependabot-update-job-proxy --final-image-tag ${tag}
|
|
updateJobProxy.imageDigest = "sha256:70cf9a8f006db9cde732faf9e33a4f60af895532bbe803268fc8fd2f70aa3202";
|
|
updateJobProxy.hash = "sha256-5HeVcMfQn4yLTRxP5lqrnMFRvWIJ5FBh26rP6ln82MY=";
|
|
|
|
# Get these hashes from
|
|
# nix run nixpkgs#nix-prefetch-docker -- --image-name ghcr.io/dependabot/dependabot-updater-github-actions --image-tag latest --final-image-name dependabot-updater-github-actions --final-image-tag ${tag}
|
|
updaterGitHubActions.imageDigest = "sha256:a813afc4a1c03bfc62a5eeff6de7ae738e508bf2eabb3d355f498b9221caab38";
|
|
updaterGitHubActions.hash = "sha256-sEzbD9wKJP3cLMYqpMqIh88UNdEXTzxntHuCOeuBmHY=";
|
|
in
|
|
buildGoModule {
|
|
inherit pname version;
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "dependabot";
|
|
repo = "cli";
|
|
rev = "v${version}";
|
|
hash = "sha256-ALlJ6EC+3Ur89Zt7PNhsYx0KcQ/FQNo+S31uOp2i7x0=";
|
|
};
|
|
|
|
vendorHash = "sha256-mo/OOo+vw2jX0ggeEzNE8Qr5xXg0GEaTH6krdGQyeEE=";
|
|
|
|
ldflags = [
|
|
"-s"
|
|
"-w"
|
|
"-X github.com/dependabot/cli/cmd/dependabot/internal/cmd.version=v${version}"
|
|
];
|
|
|
|
nativeBuildInputs = [
|
|
makeWrapper
|
|
installShellFiles
|
|
];
|
|
|
|
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
|
|
installShellCompletion --cmd dependabot \
|
|
--bash <($out/bin/dependabot completion bash) \
|
|
--fish <($out/bin/dependabot completion fish) \
|
|
--zsh <($out/bin/dependabot completion zsh)
|
|
'';
|
|
|
|
checkFlags = [
|
|
"-skip=TestDependabot"
|
|
];
|
|
|
|
# Some tests fail on *-darwin because they require host port binding or a Docker environment.
|
|
# So, we skip the test entirely on *-darwin.
|
|
doCheck = !stdenv.hostPlatform.isDarwin;
|
|
|
|
doInstallCheck = true;
|
|
installCheckPhase = ''
|
|
$out/bin/dependabot --help
|
|
'';
|
|
|
|
passthru.updateScript = ./update.sh;
|
|
|
|
passthru.withDockerImages = symlinkJoin {
|
|
name = "dependabot-cli-with-docker-images";
|
|
paths = [ dependabot-cli ];
|
|
buildInputs = [ makeWrapper ];
|
|
postBuild =
|
|
let
|
|
updateJobProxyImage = dockerTools.pullImage {
|
|
imageName = "ghcr.io/github/dependabot-update-job-proxy/dependabot-update-job-proxy";
|
|
finalImageName = "dependabot-update-job-proxy";
|
|
finalImageTag = tag;
|
|
inherit (updateJobProxy) imageDigest hash;
|
|
};
|
|
|
|
updaterGitHubActionsImage = dockerTools.pullImage {
|
|
imageName = "ghcr.io/dependabot/dependabot-updater-github-actions";
|
|
finalImageName = "dependabot-updater-github-actions";
|
|
finalImageTag = tag;
|
|
inherit (updaterGitHubActions) imageDigest hash;
|
|
};
|
|
in
|
|
''
|
|
# Create a wrapper that pins the docker images that `dependabot` uses.
|
|
wrapProgram $out/bin/dependabot \
|
|
--run "docker load --input ${updateJobProxyImage} >&2" \
|
|
--add-flags "--proxy-image=dependabot-update-job-proxy:${tag}" \
|
|
--run "docker load --input ${updaterGitHubActionsImage} >&2" \
|
|
--add-flags "--updater-image=dependabot-updater-github-actions:${tag}"
|
|
'';
|
|
};
|
|
|
|
passthru.tests.version = testers.testVersion {
|
|
package = dependabot-cli;
|
|
command = "dependabot --version";
|
|
version = "v${version}";
|
|
};
|
|
|
|
meta = {
|
|
changelog = "https://github.com/dependabot/cli/releases/tag/v${version}";
|
|
description = "Tool for testing and debugging Dependabot update jobs";
|
|
mainProgram = "dependabot";
|
|
homepage = "https://github.com/dependabot/cli";
|
|
license = lib.licenses.mit;
|
|
maintainers = with lib.maintainers; [
|
|
infinisil
|
|
philiptaron
|
|
];
|
|
};
|
|
}
|