Merge pull request #54 from nixops4/add-github-pages

Add GitHub pages
This commit is contained in:
Robert Hensing 2026-02-10 10:00:39 +01:00 committed by GitHub
commit d374652a90
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 164 additions and 1 deletions

View file

@ -211,6 +211,7 @@ For VSCode, load the dev shell via Nix Env Selector extension or direnv.
## Documentation
- [API Reference](https://nixops4.github.io/nix-bindings-rust/development/)
- [Changelog](CHANGELOG.md)
- [Nix C API Reference][C API]
- [nix-cargo-integration][nix-cargo-integration]

View file

@ -1,5 +1,6 @@
{
inputs,
withSystem,
...
}:
{
@ -56,6 +57,119 @@
''}";
};
# Combined rustdoc for all crates with cross-linking.
# NOTE: nci.outputs.nix-bindings.docs uses doc-merge which doesn't support
# rustdoc's new sharded search index format (Rust 1.78+).
# See https://github.com/90-008/nix-cargo-integration/issues/198
# Instead, we build all workspace crates together so rustdoc can link them.
packages.docs =
let
# Use nix-bindings-flake (has most transitive deps) as base
base = config.nci.outputs.nix-bindings-flake.packages.release;
crates = [
"nix-bindings-bdwgc-sys"
"nix-bindings-util-sys"
"nix-bindings-util"
"nix-bindings-store-sys"
"nix-bindings-store"
"nix-bindings-expr-sys"
"nix-bindings-expr"
"nix-bindings-fetchers-sys"
"nix-bindings-fetchers"
"nix-bindings-flake-sys"
"nix-bindings-flake"
];
packageFlags = pkgs.lib.concatMapStringsSep " " (c: "-p ${c}") crates;
in
(base.extendModules {
modules = [
{
mkDerivation = {
# Build docs for all crates together (enabling cross-crate linking)
buildPhase = pkgs.lib.mkForce ''
cargo doc $cargoBuildFlags --no-deps --profile $cargoBuildProfile ${packageFlags}
'';
checkPhase = pkgs.lib.mkForce ":";
installPhase = pkgs.lib.mkForce ''
mv target/$CARGO_BUILD_TARGET/doc $out
# Find rustdoc assets (have hashes in filenames)
find_asset() {
local pattern="$1"
local matches=($out/static.files/$pattern)
if [[ ''${#matches[@]} -ne 1 || ! -e "''${matches[0]}" ]]; then
echo "Expected exactly one match for $pattern, found: ''${matches[*]}" >&2
exit 1
fi
basename "''${matches[0]}"
}
rustdoc_css=$(find_asset 'rustdoc-*.css')
normalize_css=$(find_asset 'normalize-*.css')
storage_js=$(find_asset 'storage-*.js')
cat > $out/index.html <<EOF
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>nix-bindings-rust</title>
<link rel="stylesheet" href="static.files/$normalize_css">
<link rel="stylesheet" href="static.files/$rustdoc_css">
<script src="static.files/$storage_js"></script>
<style>
body { max-width: 800px; margin: 2em auto; padding: 0 1em; }
h1 { border-bottom: 1px solid var(--border-color); padding-bottom: 0.5em; }
ul { list-style: none; padding: 0; }
li { margin: 0.5em 0; display: flex; align-items: baseline; }
.crate {
display: inline-block;
min-width: 14em;
background-color: var(--code-block-background-color);
padding: 0.2em 0.5em;
border-radius: 3px;
}
.desc { color: var(--main-color); opacity: 0.7; margin-left: 1em; }
details { margin-top: 1.5em; }
summary { cursor: pointer; }
</style>
</head>
<body>
<h1>nix-bindings-rust</h1>
<p>Rust bindings for the Nix C API</p>
<h2>Crates</h2>
<ul>
<li><span class="crate"><a href="nix_bindings_store/index.html">nix_bindings_store</a></span><span class="desc"> Store operations</span></li>
<li><span class="crate"><a href="nix_bindings_expr/index.html">nix_bindings_expr</a></span><span class="desc"> Expression evaluation</span></li>
<li><span class="crate"><a href="nix_bindings_fetchers/index.html">nix_bindings_fetchers</a></span><span class="desc"> Fetcher operations</span></li>
<li><span class="crate"><a href="nix_bindings_flake/index.html">nix_bindings_flake</a></span><span class="desc"> Flake operations</span></li>
<li><span class="crate"><a href="nix_bindings_util/index.html">nix_bindings_util</a></span><span class="desc"> Utilities</span></li>
</ul>
<details>
<summary><h2 style="display: inline;">Low-level bindings</h2></summary>
<p>
These <code>-sys</code> crates provide raw FFI bindings generated by
<a href="https://rust-lang.github.io/rust-bindgen/">bindgen</a>.
They expose the C API directly without safety wrappers.
Most users should prefer the high-level crates above.
</p>
<ul>
<li><span class="crate"><a href="nix_bindings_store_sys/index.html">nix_bindings_store_sys</a></span><span class="desc"> nix-store-c</span></li>
<li><span class="crate"><a href="nix_bindings_expr_sys/index.html">nix_bindings_expr_sys</a></span><span class="desc"> nix-expr-c</span></li>
<li><span class="crate"><a href="nix_bindings_fetchers_sys/index.html">nix_bindings_fetchers_sys</a></span><span class="desc"> nix-fetchers-c</span></li>
<li><span class="crate"><a href="nix_bindings_flake_sys/index.html">nix_bindings_flake_sys</a></span><span class="desc"> nix-flake-c</span></li>
<li><span class="crate"><a href="nix_bindings_util_sys/index.html">nix_bindings_util_sys</a></span><span class="desc"> nix-util-c</span></li>
<li><span class="crate"><a href="nix_bindings_bdwgc_sys/index.html">nix_bindings_bdwgc_sys</a></span><span class="desc"> Boehm GC</span></li>
</ul>
</details>
</body>
</html>
EOF
'';
};
}
];
}).config.public;
devShells.default = pkgs.mkShell {
name = "nix-bindings-devshell";
strictDeps = true;
@ -105,9 +219,24 @@
};
};
herculesCI =
{ ... }:
hci@{ lib, ... }:
{
ciSystems = [ "x86_64-linux" ];
onPush.default.outputs = {
effects.pushDocs = lib.optionalAttrs (hci.config.repo.branch == "main") (
withSystem "x86_64-linux" (
{ config, hci-effects, ... }:
hci-effects.gitWriteBranch {
git.checkout.remote.url = hci.config.repo.remoteHttpUrl;
git.checkout.forgeType = "github";
git.checkout.user = "x-access-token";
git.update.branch = "gh-pages";
contents = config.packages.docs;
destination = "development"; # directory
}
)
);
};
};
hercules-ci.flake-update = {
enable = true;

View file

@ -6,6 +6,7 @@ build = "build.rs"
license = "LGPL-2.1"
description = "Low-level FFI bindings to the Boehm-Demers-Weiser garbage collector"
repository = "https://github.com/nixops4/nix-bindings-rust"
documentation = "https://nixops4.github.io/nix-bindings-rust/development/nix_bindings_bdwgc_sys/"
readme = "README.md"
[lib]

View file

@ -3,6 +3,8 @@
This crate contains generated bindings for the Boehm-Demers-Weiser garbage collector (`bdw-gc`).
**You should not have to use this crate directly,** and so you should probably not add it to your dependencies.
[API Documentation](https://nixops4.github.io/nix-bindings-rust/development/nix_bindings_bdwgc_sys/)
## Changelog
See the [nix-bindings-rust changelog](https://github.com/nixops4/nix-bindings-rust/blob/main/CHANGELOG.md).

View file

@ -6,6 +6,7 @@ build = "build.rs"
license = "LGPL-2.1"
description = "Low-level FFI bindings to the Nix expression evaluator"
repository = "https://github.com/nixops4/nix-bindings-rust"
documentation = "https://nixops4.github.io/nix-bindings-rust/development/nix_bindings_expr_sys/"
readme = "README.md"
[lib]

View file

@ -4,6 +4,8 @@ This crate contains generated bindings for the Nix C API (`nix-expr-c`).
**You should not have to use this crate directly,** and so you should probably not add it to your dependencies.
Instead, use the `nix-bindings-expr` crate, which _should_ be sufficient.
[API Documentation](https://nixops4.github.io/nix-bindings-rust/development/nix_bindings_expr_sys/)
## Changelog
See the [nix-bindings-rust changelog](https://github.com/nixops4/nix-bindings-rust/blob/main/CHANGELOG.md).

View file

@ -6,6 +6,7 @@ build = "build.rs"
license = "LGPL-2.1"
description = "Rust bindings to Nix expression evaluator"
repository = "https://github.com/nixops4/nix-bindings-rust"
documentation = "https://nixops4.github.io/nix-bindings-rust/development/nix_bindings_expr/"
readme = "README.md"
[lib]

View file

@ -2,6 +2,8 @@
Rust bindings to the Nix expression evaluator.
[API Documentation](https://nixops4.github.io/nix-bindings-rust/development/nix_bindings_expr/)
## Changelog
See the [nix-bindings-rust changelog](https://github.com/nixops4/nix-bindings-rust/blob/main/CHANGELOG.md).

View file

@ -6,6 +6,7 @@ build = "build.rs"
license = "LGPL-2.1"
description = "Low-level FFI bindings to the nix-fetchers library"
repository = "https://github.com/nixops4/nix-bindings-rust"
documentation = "https://nixops4.github.io/nix-bindings-rust/development/nix_bindings_fetchers_sys/"
readme = "README.md"
[lib]

View file

@ -4,6 +4,8 @@ This crate contains generated bindings for the Nix C API (`nix-fetchers-c`).
**You should not have to use this crate directly,** and so you should probably not add it to your dependencies.
Instead, use the `nix-bindings-fetchers` crate, which _should_ be sufficient.
[API Documentation](https://nixops4.github.io/nix-bindings-rust/development/nix_bindings_fetchers_sys/)
## Changelog
See the [nix-bindings-rust changelog](https://github.com/nixops4/nix-bindings-rust/blob/main/CHANGELOG.md).

View file

@ -5,6 +5,7 @@ edition = "2021"
license = "LGPL-2.1"
description = "Rust bindings to Nix fetchers"
repository = "https://github.com/nixops4/nix-bindings-rust"
documentation = "https://nixops4.github.io/nix-bindings-rust/development/nix_bindings_fetchers/"
readme = "README.md"
[lib]

View file

@ -2,6 +2,8 @@
Rust bindings to the nix-fetchers library.
[API Documentation](https://nixops4.github.io/nix-bindings-rust/development/nix_bindings_fetchers/)
## Changelog
See the [nix-bindings-rust changelog](https://github.com/nixops4/nix-bindings-rust/blob/main/CHANGELOG.md).

View file

@ -6,6 +6,7 @@ build = "build.rs"
license = "LGPL-2.1"
description = "Low-level FFI bindings to Nix flakes"
repository = "https://github.com/nixops4/nix-bindings-rust"
documentation = "https://nixops4.github.io/nix-bindings-rust/development/nix_bindings_flake_sys/"
readme = "README.md"
[lib]

View file

@ -4,6 +4,8 @@ This crate contains generated bindings for the Nix C API (`nix-flake-c`).
**You should not have to use this crate directly,** and so you should probably not add it to your dependencies.
Instead, use the `nix-bindings-flake` crate, which _should_ be sufficient.
[API Documentation](https://nixops4.github.io/nix-bindings-rust/development/nix_bindings_flake_sys/)
## Changelog
See the [nix-bindings-rust changelog](https://github.com/nixops4/nix-bindings-rust/blob/main/CHANGELOG.md).

View file

@ -5,6 +5,7 @@ edition = "2021"
license = "LGPL-2.1"
description = "Rust bindings to Nix flakes"
repository = "https://github.com/nixops4/nix-bindings-rust"
documentation = "https://nixops4.github.io/nix-bindings-rust/development/nix_bindings_flake/"
readme = "README.md"
[lib]

View file

@ -2,6 +2,8 @@
Rust bindings to Nix flakes.
[API Documentation](https://nixops4.github.io/nix-bindings-rust/development/nix_bindings_flake/)
## Changelog
See the [nix-bindings-rust changelog](https://github.com/nixops4/nix-bindings-rust/blob/main/CHANGELOG.md).

View file

@ -6,6 +6,7 @@ build = "build.rs"
license = "LGPL-2.1"
description = "Low-level FFI bindings to the Nix store library"
repository = "https://github.com/nixops4/nix-bindings-rust"
documentation = "https://nixops4.github.io/nix-bindings-rust/development/nix_bindings_store_sys/"
readme = "README.md"
[lib]

View file

@ -4,6 +4,8 @@ This crate contains generated bindings for the Nix C API (`nix-store-c`).
**You should not have to use this crate directly,** and so you should probably not add it to your dependencies.
Instead, use the `nix-bindings-store` crate, which _should_ be sufficient.
[API Documentation](https://nixops4.github.io/nix-bindings-rust/development/nix_bindings_store_sys/)
## Changelog
See the [nix-bindings-rust changelog](https://github.com/nixops4/nix-bindings-rust/blob/main/CHANGELOG.md).

View file

@ -6,6 +6,7 @@ build = "build.rs"
license = "LGPL-2.1"
description = "Rust bindings to Nix store library"
repository = "https://github.com/nixops4/nix-bindings-rust"
documentation = "https://nixops4.github.io/nix-bindings-rust/development/nix_bindings_store/"
readme = "README.md"
[lib]

View file

@ -2,6 +2,8 @@
Rust bindings to the Nix store library.
[API Documentation](https://nixops4.github.io/nix-bindings-rust/development/nix_bindings_store/)
## Changelog
See the [nix-bindings-rust changelog](https://github.com/nixops4/nix-bindings-rust/blob/main/CHANGELOG.md).

View file

@ -6,6 +6,7 @@ build = "build.rs"
license = "LGPL-2.1"
description = "Low-level FFI bindings to Nix utility library"
repository = "https://github.com/nixops4/nix-bindings-rust"
documentation = "https://nixops4.github.io/nix-bindings-rust/development/nix_bindings_util_sys/"
readme = "README.md"
[lib]

View file

@ -4,6 +4,8 @@ This crate contains generated bindings for the Nix C API (`nix-util-c`).
**You should not have to use this crate directly,** and so you should probably not add it to your dependencies.
Instead, use the `nix-bindings-util` crate, which _should_ be sufficient.
[API Documentation](https://nixops4.github.io/nix-bindings-rust/development/nix_bindings_util_sys/)
## Changelog
See the [nix-bindings-rust changelog](https://github.com/nixops4/nix-bindings-rust/blob/main/CHANGELOG.md).

View file

@ -5,6 +5,7 @@ edition = "2021"
license = "LGPL-2.1"
description = "Rust bindings to Nix utility library"
repository = "https://github.com/nixops4/nix-bindings-rust"
documentation = "https://nixops4.github.io/nix-bindings-rust/development/nix_bindings_util/"
readme = "README.md"
[lib]

View file

@ -2,6 +2,8 @@
Rust bindings to the Nix utility library.
[API Documentation](https://nixops4.github.io/nix-bindings-rust/development/nix_bindings_util/)
## Changelog
See the [nix-bindings-rust changelog](https://github.com/nixops4/nix-bindings-rust/blob/main/CHANGELOG.md).