8 enableWasmEval ? false,
12 enableWasmEval && stdenv.hostPlatform.isDarwin
13 -> builtins.throw "building with wasm on darwin is failing in nixpkgs";
16 pname = "open-policy-agent";
19 src = fetchFromGitHub {
20 owner = "open-policy-agent";
23 hash = "sha256-7br0rxhVNH+lt+gWwFSuYCBmZMrejLatWJyVNcQ95NA=";
28 nativeBuildInputs = [ installShellFiles ];
30 subPackages = [ "." ];
35 "-X github.com/open-policy-agent/opa/version.Version=${version}"
38 tags = lib.optional enableWasmEval (
40 "Warning: enableWasmEval breaks reproducability, "
41 + "ensure you need wasm evaluation. "
42 + "`opa build` does not need this feature."
46 checkFlags = lib.optionals (!enableWasmEval) [
47 "-skip=TestRegoTargetWasmAndTargetPluginDisablesIndexingTopdownStages"
52 # Feed in all but the e2e tests for testing
53 # This is because subPackages above limits what is built to just what we
54 # want but also limits the tests
55 # Also avoid wasm tests on darwin due to wasmtime-go build issues
57 go list ./... | grep -v -e e2e ${lib.optionalString stdenv.hostPlatform.isDarwin "-e wasm"}
60 + lib.optionalString stdenv.hostPlatform.isDarwin ''
61 # remove tests that have "too many open files"/"no space left on device" issues on darwin in hydra
62 rm server/server_test.go
66 installShellCompletion --cmd opa \
67 --bash <($out/bin/opa completion bash) \
68 --fish <($out/bin/opa completion fish) \
69 --zsh <($out/bin/opa completion zsh)
72 doInstallCheck = true;
73 installCheckPhase = ''
74 runHook preInstallCheck
77 $out/bin/opa version | grep "Version: ${version}"
79 ${lib.optionalString enableWasmEval ''
80 # If wasm is enabled verify it works
81 $out/bin/opa eval -t wasm 'trace("hello from wasm")'
84 runHook postInstallCheck
89 homepage = "https://www.openpolicyagent.org";
90 changelog = "https://github.com/open-policy-agent/opa/blob/v${version}/CHANGELOG.md";
91 description = "General-purpose policy engine";
93 The Open Policy Agent (OPA, pronounced "oh-pa") is an open source, general-purpose policy engine that unifies
94 policy enforcement across the stack. OPA provides a high-level declarative language that let’s you specify policy
95 as code and simple APIs to offload policy decision-making from your software. You can use OPA to enforce policies
96 in microservices, Kubernetes, CI/CD pipelines, API gateways, and more.
98 license = licenses.asl20;
99 maintainers = with maintainers; [