From 26edc7b80b568d81b771cec4d72a5125a0028205 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Sun, 31 Jul 2022 21:59:08 +0200 Subject: [PATCH] Add OPA dev --- README.md | 39 ++++++++++++++++++-------------- flake.nix | 5 +++++ opa/.envrc | 1 + opa/flake.lock | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ opa/flake.nix | 25 +++++++++++++++++++++ 5 files changed, 114 insertions(+), 16 deletions(-) create mode 100644 opa/.envrc create mode 100644 opa/flake.lock create mode 100644 opa/flake.nix diff --git a/README.md b/README.md index 814381f..16de6d4 100644 --- a/README.md +++ b/README.md @@ -27,22 +27,23 @@ Once your preferred template has been initialized, you can use the provided shel ## Available templates -| Language/framework/tool | Template | -| :---------------------- | :------------------------ | -| [Dhall] | [`dhall`](./dhall/) | -| [Elixir] | [`elixir`](./elixir/) | -| [Gleam] | [`gleam`](./gleam/) | -| [Go] 1.17 | [`go1_17`](./go1.17/) | -| [Go] 1.18 | [`go1_18`](./go1.18/) | -| [Hashicorp] tools | [`hashi`](./hashi/) | -| [Java] | [`java`](./java/) | -| [Kotlin] | [`kotlin`](./kotlin/) | -| [Nix] | [`nix`](./nix/) | -| [Node.js][node] | [`node`](./node/) | -| [Protobuf] | [`protobuf`](./protobuf/) | -| [Rust] | [`rust`](./rust/) | -| [Scala] | [`scala`](./scala/) | -| [Zig] | [`zig`](./zig/) | +| Language/framework/tool | Template | +| :----------------------- | :------------------------ | +| [Dhall] | [`dhall`](./dhall/) | +| [Elixir] | [`elixir`](./elixir/) | +| [Gleam] | [`gleam`](./gleam/) | +| [Go] 1.17 | [`go1_17`](./go1.17/) | +| [Go] 1.18 | [`go1_18`](./go1.18/) | +| [Hashicorp] tools | [`hashi`](./hashi/) | +| [Java] | [`java`](./java/) | +| [Kotlin] | [`kotlin`](./kotlin/) | +| [Nix] | [`nix`](./nix/) | +| [Node.js][node] | [`node`](./node/) | +| [Open Policy Agent][opa] | [`opa`](./opa) | +| [Protobuf] | [`protobuf`](./protobuf/) | +| [Rust] | [`rust`](./rust/) | +| [Scala] | [`scala`](./scala/) | +| [Zig] | [`zig`](./zig/) | ## Template contents @@ -138,6 +139,11 @@ The sections below list what each template includes. In all cases, you're free t - [pnpm] 7.3.0 - [Yarn] 1.22.19 +### [`opa`](./opa/) + +- [Open Policy Agent][opa] 0.43.0 +- [Conftest] 0.33.2 + ### [`protobuf`](./protobuf/) - The [Buf CLI][buf] 1.7.0 @@ -205,6 +211,7 @@ All of the templates have only the root [flake](./flake.nix) as a flake input. T [nomad]: https://nomadproject.io [nomad-autoscaler]: TOhttps://github.com/hashicorp/nomad-autoscaler [nomad-pack]: https://github.com/hashicorp/nomad-pack +[opa]: https://openpolicyagent.org [packer]: https://packer.io [phoenix]: https://phoenixframework.org [pnpm]: https://pnpm.io diff --git a/flake.nix b/flake.nix index 5452c97..88a84af 100644 --- a/flake.nix +++ b/flake.nix @@ -109,6 +109,11 @@ description = "Node.js development environment"; }; + opa = { + path = ./opa; + description = "Open Policy Agent development environment"; + }; + protobuf = { path = ./protobuf; description = "Protobuf development environment"; diff --git a/opa/.envrc b/opa/.envrc new file mode 100644 index 0000000..a5dbbcb --- /dev/null +++ b/opa/.envrc @@ -0,0 +1 @@ +use flake . diff --git a/opa/flake.lock b/opa/flake.lock new file mode 100644 index 0000000..fb87cce --- /dev/null +++ b/opa/flake.lock @@ -0,0 +1,60 @@ +{ + "nodes": { + "dev": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1659291915, + "narHash": "sha256-W1on31THSVnqFf/eC8wxP+oGu1jRpFb7K419w21ijNc=", + "owner": "the-nix-way", + "repo": "dev-templates", + "rev": "41e9f202186994255e28bfa4c518e0c9ffce2bb5", + "type": "github" + }, + "original": { + "owner": "the-nix-way", + "repo": "dev-templates", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1656928814, + "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1659291823, + "narHash": "sha256-8GrIQYelrtzEAXDWdfHpAodwrjL08mVES7nRDXSF9fE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4a778d9b98941fe28f0ac4b8400749a16dbb03fe", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "dev": "dev" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/opa/flake.nix b/opa/flake.nix new file mode 100644 index 0000000..d9d12c8 --- /dev/null +++ b/opa/flake.nix @@ -0,0 +1,25 @@ +{ + description = "A Nix-flake-based Protobuf development environment"; + + inputs = { dev.url = "github:the-nix-way/dev-templates"; }; + + outputs = { self, dev }: + let inherit (dev.lib) flake-utils nixpkgs; + in flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + inherit (pkgs) conftest mkShell open-policy-agent; + + opaTools = [ conftest open-policy-agent ]; + in { + devShells = { + default = mkShell { + buildInputs = opaTools; + + shellHook = '' + ${open-policy-agent}/bin/opa version + ''; + }; + }; + }); +}