jetbrains: useFetchCargoVendor (#377020)
[NixPkgs.git] / pkgs / by-name / op / openfga / package.nix
blob28f735331d966a9f4cf24dcea3dad7fa6f05e927
2   lib,
3   buildGoModule,
4   fetchFromGitHub,
5   installShellFiles,
6 }:
8 let
9   pname = "openfga";
10   version = "1.8.4";
13 buildGoModule {
14   inherit pname version;
16   src = fetchFromGitHub {
17     owner = "openfga";
18     repo = "openfga";
19     rev = "v${version}";
20     hash = "sha256-esamtNfmQajcxE/+pt7vf7+EsMojl9WL8mS4J6A5FiM=";
21   };
23   vendorHash = "sha256-NCRWUoElBs2jsUBNVqDiBdtsMFx8N6S7VkwHIL2cj1o=";
25   nativeBuildInputs = [ installShellFiles ];
27   ldflags =
28     let
29       buildInfoPkg = "github.com/openfga/openfga/internal/build";
30     in
31     [
32       "-s"
33       "-w"
34       "-X ${buildInfoPkg}.Version=${version}"
35       "-X ${buildInfoPkg}.Commit=${version}"
36       "-X ${buildInfoPkg}.Date=19700101"
37     ];
39   # Tests depend on docker
40   doCheck = false;
42   postInstall = ''
43     completions_dir=$TMPDIR/openfga_completions
44     mkdir $completions_dir
45     $out/bin/openfga completion bash > $completions_dir/openfga.bash
46     $out/bin/openfga completion zsh > $completions_dir/_openfga.zsh
47     $out/bin/openfga completion fish > $completions_dir/openfga.fish
48     installShellCompletion $completions_dir/*
49   '';
51   meta = {
52     description = "High performance and flexible authorization/permission engine built for developers and inspired by Google Zanzibar";
53     homepage = "https://openfga.dev/";
54     license = lib.licenses.asl20;
55     mainProgram = "openfga";
56     maintainers = with lib.maintainers; [ jlesquembre ];
57   };