# SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie # SPDX-License-Identifier: MIT { description = "Vault and OpenBao client for Zig"; inputs = { nixpkgs = { url = "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.zst"; }; }; outputs = { self, nixpkgs, ... }: let inherit (nixpkgs) lib; linuxSystems = builtins.filter ( system: (lib.systems.elaborate system).isLinux ) lib.systems.flakeExposed; makePackages = system: import nixpkgs { inherit system; }; forAllSystems = lib.genAttrs linuxSystems; in { packages = forAllSystems ( system: let pkgs = makePackages system; in { vaultctl = pkgs.callPackage ./package.nix { }; vault-integration-tests = pkgs.callPackage ./package.nix { integrationTests = true; }; default = self.packages.${system}.vaultctl; # A disposable VM running OpenBao with the client installed # alongside it, for trying things against real server software by # hand. `nix build .#openbao-vm` then ./result/bin/run-*-vm. openbao-vm = self.nixosConfigurations.openbao-vm.config.system.build.vm; } ); # `nix run` builds the CLI and runs it, so `nix run . -- get myapp/config` # works without installing anything. apps = forAllSystems (system: { vaultctl = { type = "app"; program = lib.getExe self.packages.${system}.vaultctl; meta = self.packages.${system}.vaultctl.meta; }; default = self.apps.${system}.vaultctl; }); devShells = forAllSystems ( system: let pkgs = makePackages system; in { default = pkgs.mkShell { name = "vaultz"; nativeBuildInputs = [ pkgs.pinact pkgs.radicle-node pkgs.reuse pkgs.zig_0_16 ]; }; } ); # A NixOS machine running OpenBao. `packages..openbao-vm` builds # it as a bootable VM, and the integration check below reuses the same # server module, so there is one definition of the server rather than # two that can drift. nixosConfigurations.openbao-vm = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ ./nix/test-vm.nix ]; }; checks = forAllSystems ( system: let pkgs = makePackages system; in { # `zig build test` runs as the package's check phase, so building the # package runs the hermetic suite. vaultctl = self.packages.${system}.vaultctl; # Boots a VM with OpenBao and runs the client against it. integration = pkgs.callPackage ./nix/integration-test.nix { inherit (self.packages.${system}) vaultctl vault-integration-tests; }; } ); }; }