mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-10-03 21:40:12 +00:00
96 lines
2.5 KiB
Nix
96 lines
2.5 KiB
Nix
{
|
|
lib,
|
|
stdenv,
|
|
buildGoModule,
|
|
fetchFromGitHub,
|
|
bash,
|
|
protobuf,
|
|
protoc-gen-go,
|
|
protoc-gen-go-grpc,
|
|
kubernetes-controller-tools,
|
|
installShellFiles,
|
|
nix-update-script,
|
|
writableTmpDirAsHomeHook,
|
|
}:
|
|
|
|
buildGoModule (finalAttrs: {
|
|
pname = "dcp";
|
|
version = "0.25.13";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "microsoft";
|
|
repo = "dcp";
|
|
tag = "v${finalAttrs.version}";
|
|
hash = "sha256-dbgvKAsUw6950ig1/eUewUS++P803Bdg5qYmFYnqaGQ=";
|
|
};
|
|
|
|
vendorHash = "sha256-WBre4iBMYzx1unqz9+F1wDogYbPEsm3DyUgeceB8yko=";
|
|
|
|
# This is required so we:
|
|
# - Delete an inconsistent vendor directory from upstream
|
|
# - Avoid running a preBuild before the codegen step
|
|
overrideModAttrs = _: {
|
|
preBuild = null;
|
|
postUnpack = ''
|
|
rm -rf $sourceRoot/vendor
|
|
'';
|
|
};
|
|
|
|
nativeBuildInputs = [
|
|
installShellFiles
|
|
protoc-gen-go
|
|
protoc-gen-go-grpc
|
|
writableTmpDirAsHomeHook
|
|
];
|
|
|
|
# Run code generation using the upstream Makefile.
|
|
# Override SHELL for Nix sandbox compatibility.
|
|
# Use full paths for PROTOC and CONTROLLER_GEN to avoid Makefile target conflicts.
|
|
preBuild = ''
|
|
make generate \
|
|
SHELL="${bash}/bin/bash -o pipefail" \
|
|
PROTOC="${protobuf}/bin/protoc" \
|
|
CONTROLLER_GEN="${kubernetes-controller-tools}/bin/controller-gen"
|
|
'';
|
|
|
|
subPackages = [
|
|
"cmd/dcp"
|
|
"cmd/dcptun"
|
|
];
|
|
|
|
ldflags =
|
|
let
|
|
pkg = "github.com/microsoft/dcp/internal/version";
|
|
in
|
|
[
|
|
"-s"
|
|
"-w"
|
|
"-X ${pkg}.ProductVersion=${finalAttrs.version}"
|
|
"-X ${pkg}.CommitHash=v${finalAttrs.version}"
|
|
];
|
|
|
|
# The dcptun binary should be named dcptun_c for compatibility
|
|
# https://github.com/microsoft/dcp/blob/3146b1dd5b2ea283947f846a55bf2e01c294e2ba/Makefile#L103
|
|
postInstall = ''
|
|
mv $out/bin/dcptun $out/bin/dcptun_c
|
|
''
|
|
+ lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
|
|
installShellCompletion --cmd dcp \
|
|
--bash <($out/bin/dcp completion bash) \
|
|
--fish <($out/bin/dcp completion fish) \
|
|
--zsh <($out/bin/dcp completion zsh)
|
|
'';
|
|
|
|
passthru.updateScript = nix-update-script { };
|
|
|
|
meta = {
|
|
description = "Developer Control Plane - API server and CLI for managing developer workloads";
|
|
homepage = "https://github.com/microsoft/dcp";
|
|
changelog = "https://github.com/microsoft/dcp/releases/tag/v${finalAttrs.version}";
|
|
license = lib.licenses.mit;
|
|
maintainers = with lib.maintainers; [ mtrsk ];
|
|
mainProgram = "dcp";
|
|
platforms = lib.platforms.unix;
|
|
};
|
|
})
|