Something went wrong. Try again.
Sign git commits and tags with an OpenPGP key kept in Bitwarden.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131# SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie <jeff@ocjtech.us># SPDX-License-Identifier: MIT
{ description = "bwgpg: sign git commits with an OpenPGP key kept in Bitwarden";
inputs = { nixpkgs = { url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz"; }; zon2nix = { url = "github:jcollie/zon2nix"; inputs.nixpkgs.follows = "nixpkgs"; }; # Only for the check that builds a Home Manager configuration with the # module; the module itself needs nothing from it. home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; };
outputs = { self, nixpkgs, zon2nix, home-manager, ... }: let inherit (nixpkgs) lib; makePackages = system: import nixpkgs { inherit system; }; forAllSystems = lib.genAttrs lib.systems.flakeExposed; linuxSystems = lib.filter (system: lib.hasSuffix "-linux" system) lib.systems.flakeExposed;
# zon2nix shells out to `zig env`, and without a Zig on PATH it prints # "unable to execute zig, is it in your PATH?" and stops having written # nothing -- which leaves the previous build.zig.zon.nix in place looking # untouched rather than obviously broken. Wrap it so the Zig it finds is # this project's. wrappedZon2nix = pkgs: pkgs.symlinkJoin { name = "zon2nix"; paths = [ zon2nix.packages.${pkgs.stdenv.hostPlatform.system}.zon2nix ]; nativeBuildInputs = [ pkgs.makeWrapper ]; postBuild = '' wrapProgram $out/bin/zon2nix \ --prefix PATH : ${lib.makeBinPath [ pkgs.zig_0_17 ]} ''; }; in { packages = forAllSystems ( system: let pkgs = makePackages system; in rec { bwgpg = pkgs.callPackage ./package.nix { }; default = bwgpg; zig-deps = pkgs.callPackage ./build.zig.zon.nix { }; } );
# `programs.bwgpg` for Home Manager: see nix/hm-module.nix. homeModules = rec { bwgpg = import ./nix/hm-module.nix { inherit self; }; default = bwgpg; }; # The name Home Manager's documentation used before `homeModules`. homeManagerModules = self.homeModules;
# Linux only: the virtual machine test boots NixOS, and without this # `nix flake check` tries to evaluate one for Darwin and fails before # running anything. checks = lib.genAttrs linuxSystems ( system: let pkgs = makePackages system; bwgpg = pkgs.callPackage ./package.nix { }; in { inherit bwgpg; vaultwarden = pkgs.testers.runNixOSTest ( import ./nix/vm-test.nix { bwgpg = bwgpg.override { withFixture = true; }; } ); ssh = pkgs.testers.runNixOSTest ( import ./nix/vm-test-ssh.nix { bwgpg = bwgpg.override { withFixture = true; }; } ); tailnet = pkgs.testers.runNixOSTest ( import ./nix/vm-test-tailnet.nix { bwgpg = bwgpg.override { withFixture = true; }; } ); home-manager = import ./nix/hm-test.nix { inherit pkgs bwgpg home-manager; module = self.homeModules.default; }; } );
devShells = forAllSystems ( system: let pkgs = makePackages system; in { default = pkgs.mkShell { name = "zig-bwgpg"; nativeBuildInputs = [ pkgs.zig_0_17 (wrappedZon2nix pkgs) pkgs.git-pages-cli pkgs.gnupg pkgs.reuse ] ++ lib.optionals (pkgs.stdenv.hostPlatform.isLinux && pkgs.stdenv.hostPlatform.isx86_64) [ # Runs the Windows build's unit tests: `zig build test # -Dtarget=x86_64-windows-gnu.win10_rs4 -fwine`. pkgs.wineWow64Packages.stable ]; }; } ); };}