Something went wrong. Try again.
Sign git commits and tags with an OpenPGP key kept in Bitwarden.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182# SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie <jeff@ocjtech.us># SPDX-License-Identifier: MIT
{ lib, stdenv, callPackage, zig_0_17, gnupg, # Also install bwgpg-fixture, which fills a Vaultwarden for the NixOS test. withFixture ? false,}:let # Generated from build.zig.zon by zon2nix; regenerate with # nix develop -c zon2nix --17 --nix=build.zig.zon.nix build.zig.zon zigDeps = callPackage ./build.zig.zon.nix { }; # build.zig.zon is where the version lives; this reads it rather than # keeping a second copy to fall out of step. version = builtins.head ( builtins.match ".*\n \\.version = \"([^\"]+)\",\n.*" (builtins.readFile ./build.zig.zon) );instdenv.mkDerivation (finalAttrs: { pname = "bwgpg"; inherit version;
# Named rather than filtered, so that editing something outside this list -- # the flake, the NixOS test, a note -- does not rebuild. src = lib.fileset.toSource { root = ./.; fileset = lib.fileset.unions [ ./build.zig ./build.zig.zon ./contrib ./src ./tests/fixture.zig ./tests/interop.sh ./tools ]; };
nativeBuildInputs = [ zig_0_17 ]; # The interop check runs gpg against signatures made here. nativeCheckInputs = [ gnupg ];
zigBuildFlags = [ "--system" "${zigDeps}" ] ++ lib.optional withFixture "-Dfixture=true"; # The check phase assembles its own flags rather than reusing the build's, # so without this `zig build test` runs without --system, tries to fetch, # and fails in the sandbox. zigCheckFlags = finalAttrs.zigBuildFlags;
doCheck = true; checkPhase = '' runHook preCheck zig build test interop --summary all ''${zigCheckFlags[@]} runHook postCheck '';
# The systemd user units for running the agent socket-activated, pointed # at this package's binary. postInstall = lib.optionalString stdenv.hostPlatform.isLinux '' mkdir -p $out/share/systemd/user for unit in bwgpg-agent.socket bwgpg-agent-extra.socket bwgpg-agent-tailnet.socket bwgpg-agent.service; do substitute contrib/systemd/$unit $out/share/systemd/user/$unit \ --replace-quiet @bwgpg@ $out/bin/bwgpg done grep -q "ExecStart=$out/bin/bwgpg" $out/share/systemd/user/bwgpg-agent.service '';
meta = { description = "Sign git commits and tags with an OpenPGP key kept in Bitwarden"; homepage = "https://git.jcollie.dev/jeff/zig-bwgpg"; license = lib.licenses.mit; mainProgram = "bwgpg"; platforms = lib.platforms.linux ++ lib.platforms.windows; };})