{
inputs.parts.url = "github:hercules-ci/flake-parts";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
inputs.nci.url = "github:90-008/nix-cargo-integration";
outputs =
inp:
inp.parts.lib.mkFlake { inputs = inp; } {
systems = [ "x86_64-linux" "aarch64-darwin" ];
imports = [inp.nci.flakeModule];
perSystem =
{
pkgs,
config,
system,
...
}:
let
# the docs site lives in site/ and reads docs/ in place. it builds with bun in the
# repo rather than in the nix store, since that would need its node deps pinned.
buildDocs = pkgs.writeShellApplication {
name = "build-docs";
runtimeInputs = [ pkgs.bun pkgs.nodejs pkgs.git ];
text = ''
root="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
cd "$root/site"
bun install --frozen-lockfile
bun run build
if [ -n "''${1:-}" ]; then
rm -rf "$1"
cp -r dist "$1"
fi
'';
};
deployDocs = pkgs.writeShellApplication {
name = "deploy-docs";
runtimeInputs = [ buildDocs pkgs.bun pkgs.git ];
text = ''
build-docs
root="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
bunx wispctl -y --path "$root/site/dist" --site hydrant-docs did:plc:dfl62fgb7wtjj3fcbb72naae
'';
};
in
{
nci.projects."hydrant" = {
path = ./.;
export = false;
};
packages.default = pkgs.callPackage ./default.nix {};
# the C api for embedding, as lib/libhydrant_ffi.a and include/hydrant.h
packages.ffi = config.packages.default.overrideAttrs {
pname = "hydrant-ffi";
cargoBuildFlags = [ "-p" "hydrant-ffi" ];
postInstall = "install -Dm644 ffi/include/hydrant.h -t $out/include";
};
apps.build-docs = { type = "app"; program = "${buildDocs}/bin/build-docs"; };
apps.deploy-docs = { type = "app"; program = "${deployDocs}/bin/deploy-docs"; };
devShells.default = config.nci.outputs."hydrant".devShell.overrideAttrs (old: {
packages = (old.packages or []) ++ (with pkgs; [
cargo-outdated
gemini-cli
go
cmake
websocat
http-nu
nushell
clang
rtk
bun
nodejs
]
++ lib.optionals (system == "x86_64-linux") [
psmisc
wild
]);
});
};
};
}