nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 buildGoModule,
5 fetchFromGitHub,
6 installShellFiles,
7 testers,
8 func,
9}:
10
11buildGoModule (finalAttrs: {
12 pname = "func";
13 version = "1.20.1";
14
15 src = fetchFromGitHub {
16 owner = "knative";
17 repo = "func";
18 tag = "knative-v${finalAttrs.version}";
19 hash = "sha256-SYqkWE7dVFy6stibcWayU2J+oIFIfwNDoK6TzchgBzo=";
20 };
21
22 vendorHash = "sha256-F/TQ1QwfQfum1DOY2xrzpTlm7jvuJQUjtBLY6pZfTh8=";
23
24 subPackages = [ "cmd/func" ];
25
26 ldflags = [
27 "-X knative.dev/func/pkg/version.Vers=v${finalAttrs.version}"
28 "-X main.date=19700101T000000Z"
29 "-X knative.dev/func/pkg/version.Hash=${finalAttrs.version}"
30 "-X knative.dev/func/pkg/version.Kver=${finalAttrs.src.tag}"
31 ];
32
33 nativeBuildInputs = [ installShellFiles ];
34
35 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
36 installShellCompletion --cmd func \
37 --bash <($out/bin/func completion bash) \
38 --zsh <($out/bin/func completion zsh)
39 '';
40
41 passthru.tests.version = testers.testVersion {
42 package = func;
43 command = "func version";
44 version = "v${finalAttrs.version}";
45 };
46
47 meta = {
48 description = "Knative client library and CLI for creating, building, and deploying Knative Functions";
49 mainProgram = "func";
50 homepage = "https://github.com/knative/func";
51 changelog = "https://github.com/knative/func/releases/tag/knative-v${finalAttrs.version}";
52 license = lib.licenses.asl20;
53 maintainers = with lib.maintainers; [ maxwell-lt ];
54 };
55})