nixpkgs/pkgs/by-name/ku/kubernetes-kcp/package.nix
Sergei Trofimovich c2e85f96e6 kubernetes-kcp.tests: fix the eval
Without the change the eval fails as:

    $ nix build --no-link -f. kubernetes-kcp.tests
    error:
       … while evaluating the attribute 'version'
         at pkgs/by-name/ku/kubernetes-kcp/package.nix:52:3:
           51|
           52|   passthru.tests.version = testers.testVersion {
             |   ^
           53|     command = "kcp --version";

       … from call site
         at pkgs/by-name/ku/kubernetes-kcp/package.nix:52:28:
           51|
           52|   passthru.tests.version = testers.testVersion {
             |                            ^
           53|     command = "kcp --version";

       error: function 'testVersion' called without required argument 'package'
       at pkgs/build-support/testers/default.nix:66:5:
           65|   testVersion =
           66|     { package,
             |     ^
           67|       command ? "${package.meta.mainProgram or package.pname or package.name} --version",
2024-12-04 06:13:57 +00:00

71 lines
2.2 KiB
Nix

{
lib,
stdenv,
buildGoModule,
fetchFromGitHub,
installShellFiles,
testers,
kubernetes-kcp,
}:
buildGoModule rec {
pname = "kubernetes-kcp";
version = "0.26.0";
src = fetchFromGitHub {
owner = "kcp-dev";
repo = "kcp";
rev = "refs/tags/v${version}";
hash = "sha256-ZEgDeILo2weSAZgBsfR2EQyzym/I/+3P99b47E5Tfrw=";
};
vendorHash = "sha256-IONbTih48LKAiEPFNFdBkJDMI2sjHWxiqVbEJCskyio=";
subPackages = [ "cmd/kcp" ];
# TODO: The upstream has the additional version information pulled from go.mod
# dependencies.
ldflags = [
"-X k8s.io/client-go/pkg/version.gitCommit=unknown"
"-X k8s.io/client-go/pkg/version.gitTreeState=clean"
"-X k8s.io/client-go/pkg/version.gitVersion=v${version}"
# "-X k8s.io/client-go/pkg/version.gitMajor=${KUBE_MAJOR_VERSION}"
# "-X k8s.io/client-go/pkg/version.gitMinor=${KUBE_MINOR_VERSION}"
"-X k8s.io/client-go/pkg/version.buildDate=unknown"
"-X k8s.io/component-base/version.gitCommit=unknown"
"-X k8s.io/component-base/version.gitTreeState=clean"
"-X k8s.io/component-base/version.gitVersion=v${version}"
# "-X k8s.io/component-base/version.gitMajor=${KUBE_MAJOR_VERSION}"
# "-X k8s.io/component-base/version.gitMinor=${KUBE_MINOR_VERSION}"
"-X k8s.io/component-base/version.buildDate=unknown"
];
# TODO: Check if this is necessary.
# __darwinAllowLocalNetworking = true;
nativeBuildInputs = [ installShellFiles ];
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
$out/bin/kcp completion bash > kcp.bash
$out/bin/kcp completion zsh > kcp.zsh
$out/bin/kcp completion fish > kcp.fish
installShellCompletion kcp.{bash,zsh,fish}
'';
passthru.tests.version = testers.testVersion {
package = kubernetes-kcp;
command = "kcp --version";
# NOTE: Once the go.mod version is pulled in, the version info here needs
# to be also updated.
version = "v${version}";
};
meta = {
homepage = "https://kcp.io";
description = "Kubernetes-like control planes for form-factors and use-cases beyond Kubernetes and container workloads";
mainProgram = "kcp";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [
rytswd
];
};
}