{
description = "Development environment for polyproto-rs";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
polyphony-workflows.url = "git+https://codeberg.org/polyphony/workflows";
polyphony-workflows.inputs.nixpkgs.follows = "nixpkgs";
polyphony-workflows.inputs.flake-parts.follows = "flake-parts";
};
outputs =
inputs@{
self,
nixpkgs,
flake-parts,
polyphony-workflows,
...
}:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
imports = [ polyphony-workflows.flakeModules.default ];
polyphony.rust = {
toolchainFile = ./rust-toolchain.toml;
hash = "sha256-viptHfVceErIpjvZQgo6i7CM3BjBlsH0r/nBKMEXP60=";
};
perSystem =
{
config,
pkgs,
lib,
...
}:
let
commonArgs = {
pname = "polyproto";
version = "0.17.0";
src = lib.cleanSource ./.;
cargoLock.lockFile = ./Cargo.lock;
nativeBuildInputs = [ pkgs.pkg-config ];
};
in
{
polyphony.devshell.extraPackages = with pkgs; [
cargo-nextest
mold
rust-analyzer
];
polyphony.rust.package =
pkgs: pkgs.callPackage ({ rustPlatform }: rustPlatform.buildRustPackage commonArgs) { };
checks.build = config.packages.rustBuild;
# Please feel free to improve/dedup this. i am not great with nix yet. but hey, it works!
checks.clippy-default = pkgs.callPackage (
{ rustPlatform }:
rustPlatform.buildRustPackage (
commonArgs
// {
pname = "polyproto-clippy-default";
nativeBuildInputs = commonArgs.nativeBuildInputs ++ [ config.polyphony.rust.toolchain ];
buildPhase = "cargo clippy --features=default -- -D warnings";
installPhase = "touch $out";
checkPhase = "true";
}
)
) { };
checks.clippy-all = pkgs.callPackage (
{ rustPlatform }:
rustPlatform.buildRustPackage (
commonArgs
// {
pname = "polyproto-clippy-all";
nativeBuildInputs = commonArgs.nativeBuildInputs ++ [ config.polyphony.rust.toolchain ];
buildPhase = "cargo clippy --all-targets --all-features -- -D warnings";
installPhase = "touch $out";
checkPhase = "true";
}
)
) { };
checks.nextest = pkgs.callPackage (
{ rustPlatform, cargo-nextest }:
rustPlatform.buildRustPackage (
commonArgs
// {
pname = "polyproto-nextest";
nativeBuildInputs = commonArgs.nativeBuildInputs ++ [
config.polyphony.rust.toolchain
cargo-nextest
];
# Skip the default checkPhase which runs 'cargo test'
checkPhase = ''
cargo nextest run --features="types,reqwest,gateway" --failure-output final --no-fail-fast --tests --examples
'';
installPhase = "touch $out";
}
)
) { };
checks.clippy-doc = pkgs.callPackage (
{ rustPlatform }:
rustPlatform.buildRustPackage (
commonArgs
// {
pname = "polyproto-doc";
nativeBuildInputs = commonArgs.nativeBuildInputs ++ [ config.polyphony.rust.toolchain ];
buildPhase = "RUSTDOCFLAGS='-D warnings' cargo doc --document-private-items --all-features -p polyproto --no-deps";
installPhase = "touch $out";
checkPhase = "true";
}
)
) { };
# Disable pre-commit clippy hook; we are using a dedicated nix check
pre-commit.settings.hooks.clippy.enable = lib.mkForce false;
pre-commit.settings.hooks.treefmt.enable = lib.mkForce true;
};
};
}