7 , enableWasmEval ? false
10 assert enableWasmEval && stdenv.isDarwin -> builtins.throw "building with wasm on darwin is failing in nixpkgs";
13 pname = "open-policy-agent";
16 src = fetchFromGitHub {
17 owner = "open-policy-agent";
20 hash = "sha256-yXYyRl0ZDgS6eB2pB0Iqi3DiBGcIO3Vdet9RLSOczkU=";
25 nativeBuildInputs = [ installShellFiles ];
27 subPackages = [ "." ];
29 ldflags = [ "-s" "-w" "-X github.com/open-policy-agent/opa/version.Version=${version}" ];
31 tags = lib.optional enableWasmEval (
33 ("Warning: enableWasmEval breaks reproducability, "
34 + "ensure you need wasm evaluation. "
35 + "`opa build` does not need this feature.")
38 checkFlags = lib.optionals (!enableWasmEval) [
39 "-skip=TestRegoTargetWasmAndTargetPluginDisablesIndexingTopdownStages"
43 # Feed in all but the e2e tests for testing
44 # This is because subPackages above limits what is built to just what we
45 # want but also limits the tests
46 # Also avoid wasm tests on darwin due to wasmtime-go build issues
48 go list ./... | grep -v -e e2e ${lib.optionalString stdenv.isDarwin "-e wasm"}
50 '' + lib.optionalString stdenv.isDarwin ''
51 # remove tests that have "too many open files"/"no space left on device" issues on darwin in hydra
52 rm server/server_test.go
56 installShellCompletion --cmd opa \
57 --bash <($out/bin/opa completion bash) \
58 --fish <($out/bin/opa completion fish) \
59 --zsh <($out/bin/opa completion zsh)
62 doInstallCheck = true;
63 installCheckPhase = ''
64 runHook preInstallCheck
67 $out/bin/opa version | grep "Version: ${version}"
69 ${lib.optionalString enableWasmEval ''
70 # If wasm is enabled verify it works
71 $out/bin/opa eval -t wasm 'trace("hello from wasm")'
74 runHook postInstallCheck
79 homepage = "https://www.openpolicyagent.org";
80 changelog = "https://github.com/open-policy-agent/opa/blob/v${version}/CHANGELOG.md";
81 description = "General-purpose policy engine";
83 The Open Policy Agent (OPA, pronounced "oh-pa") is an open source, general-purpose policy engine that unifies
84 policy enforcement across the stack. OPA provides a high-level declarative language that let’s you specify policy
85 as code and simple APIs to offload policy decision-making from your software. You can use OPA to enforce policies
86 in microservices, Kubernetes, CI/CD pipelines, API gateways, and more.
88 license = licenses.asl20;
89 maintainers = with maintainers; [ lewo jk ];