rodecaster-protocol 0.15.0

JUCE var / ValueTree codec and transport frame for the RODECaster Pro II / Duo wire protocol
Documentation
{
  description = "rodecaster-protocol: JUCE var / ValueTree codec for the RODECaster wire protocol";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    rust-overlay.url = "github:oxalica/rust-overlay";
    rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
    flake-utils.url = "github:numtide/flake-utils";
    crane.url = "github:ipetkov/crane";
  };

  # Nix governs the build: every check (test, clippy, fmt) is a flake check, so
  # `nix flake check` is the single source of truth that CI runs.
  outputs =
    {
      self,
      nixpkgs,
      rust-overlay,
      flake-utils,
      crane,
      ...
    }:
    flake-utils.lib.eachDefaultSystem (
      system:
      let
        overlays = [ (import rust-overlay) ];
        pkgs = import nixpkgs { inherit system overlays; };

        # Pinned, NOT `stable.latest`: `latest` re-resolves to the newest stable
        # whenever rust-overlay updates, which silently shifts rustfmt/clippy
        # rules and breaks `nix flake check` on unchanged code. Pin an explicit
        # version so the toolchain is deterministic; bump it deliberately and
        # re-run `nix flake check` to confirm fmt + clippy stay green.
        rustToolchain = pkgs.rust-bin.stable."1.96.0".default.override {
          extensions = [
            "rust-src"
            "rust-analyzer"
            "clippy"
            "rustfmt"
          ];
        };

        craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;

        # Crane's default Cargo filter excludes binary fixture extensions. Keep
        # the real-hardware corpus in every test/clippy derivation so Nix and
        # local Cargo validate the same source tree.
        src = pkgs.lib.cleanSourceWith {
          src = ./.;
          filter =
            path: type:
            (craneLib.filterCargoSources path type)
            || (builtins.match ".*/tests/fixtures(/.*)?" (toString path) != null);
        };
        commonArgs = {
          inherit src;
          strictDeps = true;
        };

        # Dependency-free crate: this is effectively a no-op, but keeps the
        # standard crane shape so adding a dep later Just Works.
        cargoArtifacts = craneLib.buildDepsOnly commonArgs;

        rodecaster-protocol = craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; });
      in
      {
        checks = {
          inherit rodecaster-protocol;
          clippy = craneLib.cargoClippy (
            commonArgs
            // {
              inherit cargoArtifacts;
              cargoClippyExtraArgs = "--all-targets -- --deny warnings";
            }
          );
          fmt = craneLib.cargoFmt { inherit src; };
          doc = craneLib.cargoDoc (
            commonArgs
            // {
              inherit cargoArtifacts;
              cargoDocExtraArgs = "--no-deps";
              RUSTDOCFLAGS = "-D warnings";
            }
          );
          test = craneLib.cargoTest (commonArgs // { inherit cargoArtifacts; });
        };

        packages.default = rodecaster-protocol;

        devShells.default = craneLib.devShell {
          checks = self.checks.${system};
        };
      }
    );
}