2025-08-26 14:52:12 +02:00
|
|
|
{
|
|
|
|
|
inputs,
|
|
|
|
|
...
|
|
|
|
|
}:
|
|
|
|
|
{
|
2024-08-29 17:13:47 +02:00
|
|
|
imports = [
|
|
|
|
|
inputs.pre-commit-hooks-nix.flakeModule
|
|
|
|
|
inputs.hercules-ci-effects.flakeModule
|
|
|
|
|
];
|
2025-08-26 14:52:12 +02:00
|
|
|
perSystem =
|
|
|
|
|
{
|
2025-10-27 01:37:18 +01:00
|
|
|
config,
|
|
|
|
|
pkgs,
|
|
|
|
|
inputs',
|
|
|
|
|
...
|
|
|
|
|
}:
|
|
|
|
|
{
|
|
|
|
|
nix-bindings-rust.nixPackage = inputs'.nix.packages.default;
|
2024-08-29 16:58:18 +02:00
|
|
|
|
2025-08-26 14:52:12 +02:00
|
|
|
pre-commit.settings.hooks.nixfmt-rfc-style.enable = true;
|
|
|
|
|
# Temporarily disable rustfmt due to configuration issues
|
|
|
|
|
# pre-commit.settings.hooks.rustfmt.enable = true;
|
2025-10-26 23:29:13 +01:00
|
|
|
pre-commit.settings.settings.rust.cargoManifestPath = "./Cargo.toml";
|
2024-08-29 16:58:18 +02:00
|
|
|
|
2025-08-26 14:52:12 +02:00
|
|
|
# Check that we're using ///-style doc comments in Rust code.
|
|
|
|
|
#
|
|
|
|
|
# Unfortunately, rustfmt won't do this for us yet - at least not
|
|
|
|
|
# without nightly, and it might do too much.
|
|
|
|
|
pre-commit.settings.hooks.rust-doc-comments = {
|
|
|
|
|
enable = true;
|
|
|
|
|
files = "\\.rs$";
|
|
|
|
|
entry = "${pkgs.writeScript "rust-doc-comments" ''
|
|
|
|
|
#!${pkgs.runtimeShell}
|
|
|
|
|
set -uxo pipefail
|
|
|
|
|
grep -n -C3 --color=always -F '/**' "$@"
|
|
|
|
|
r=$?
|
|
|
|
|
set -e
|
|
|
|
|
if [ $r -eq 0 ]; then
|
|
|
|
|
echo "Please replace /**-style comments by /// style comments in Rust code."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
''}";
|
|
|
|
|
};
|
2024-08-29 16:58:18 +02:00
|
|
|
|
2025-08-26 14:52:12 +02:00
|
|
|
devShells.default = pkgs.mkShell {
|
|
|
|
|
name = "nix-bindings-devshell";
|
|
|
|
|
strictDeps = true;
|
|
|
|
|
inputsFrom = [ config.nci.outputs.nix-bindings.devShell ];
|
|
|
|
|
inherit (config.nci.outputs.nix-bindings.devShell.env)
|
|
|
|
|
LIBCLANG_PATH
|
|
|
|
|
NIX_CC_UNWRAPPED
|
|
|
|
|
;
|
|
|
|
|
NIX_DEBUG_INFO_DIRS =
|
|
|
|
|
let
|
|
|
|
|
# TODO: add to Nixpkgs lib
|
|
|
|
|
getDebug =
|
|
|
|
|
pkg:
|
|
|
|
|
if pkg ? debug then
|
|
|
|
|
pkg.debug
|
|
|
|
|
else if pkg ? lib then
|
|
|
|
|
pkg.lib
|
|
|
|
|
else
|
|
|
|
|
pkg;
|
|
|
|
|
in
|
|
|
|
|
"${getDebug config.packages.nix}/lib/debug";
|
|
|
|
|
buildInputs = [
|
|
|
|
|
config.packages.nix
|
|
|
|
|
];
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
|
pkgs.rust-analyzer
|
|
|
|
|
pkgs.nixfmt-rfc-style
|
|
|
|
|
pkgs.rustfmt
|
|
|
|
|
pkgs.pkg-config
|
|
|
|
|
pkgs.clang-tools # clangd
|
|
|
|
|
pkgs.valgrind
|
|
|
|
|
pkgs.gdb
|
|
|
|
|
pkgs.hci
|
|
|
|
|
# TODO: set up cargo-valgrind in shell and build
|
|
|
|
|
# currently both this and `cargo install cargo-valgrind`
|
|
|
|
|
# produce a binary that says ENOENT.
|
|
|
|
|
# pkgs.cargo-valgrind
|
|
|
|
|
];
|
|
|
|
|
shellHook = ''
|
|
|
|
|
${config.pre-commit.installationScript}
|
2025-10-26 23:29:13 +01:00
|
|
|
source ${../bindgen-gcc.sh}
|
2025-08-26 14:52:12 +02:00
|
|
|
echo 1>&2 "Welcome to the development shell!"
|
|
|
|
|
'';
|
|
|
|
|
# rust-analyzer needs a NIX_PATH for some reason
|
|
|
|
|
NIX_PATH = "nixpkgs=${inputs.nixpkgs}";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
herculesCI =
|
2025-10-27 13:57:51 +01:00
|
|
|
{ config, ... }:
|
2025-08-26 14:52:12 +02:00
|
|
|
{
|
|
|
|
|
ciSystems = [ "x86_64-linux" ];
|
2024-08-29 16:58:18 +02:00
|
|
|
};
|
2024-10-23 16:46:56 +02:00
|
|
|
hercules-ci.flake-update = {
|
|
|
|
|
enable = true;
|
|
|
|
|
baseMerge.enable = true;
|
|
|
|
|
autoMergeMethod = "merge";
|
2025-10-04 02:03:25 +02:00
|
|
|
when = {
|
|
|
|
|
dayOfMonth = 1;
|
|
|
|
|
};
|
2024-10-23 16:46:56 +02:00
|
|
|
flakes = {
|
|
|
|
|
"." = { };
|
|
|
|
|
"dev" = { };
|
|
|
|
|
};
|
|
|
|
|
};
|
2024-08-29 17:13:47 +02:00
|
|
|
flake = { };
|
2024-08-29 16:58:18 +02:00
|
|
|
}
|