twt/flake.nix

107 lines
3.0 KiB
Nix

{
description = "twt";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.systems.url = "github:msfjarvis/flake-systems";
inputs.advisory-db.url = "github:rustsec/advisory-db";
inputs.advisory-db.flake = false;
inputs.crane.url = "github:ipetkov/crane";
inputs.crane.inputs.flake-compat.follows = "flake-compat";
inputs.crane.inputs.flake-utils.follows = "flake-utils";
inputs.crane.inputs.nixpkgs.follows = "nixpkgs";
inputs.custom-nixpkgs.url = "github:msfjarvis/custom-nixpkgs";
inputs.custom-nixpkgs.inputs.nixpkgs.follows = "nixpkgs";
inputs.custom-nixpkgs.inputs.fenix.follows = "fenix";
inputs.custom-nixpkgs.inputs.systems.follows = "systems";
inputs.devshell.url = "github:numtide/devshell";
inputs.devshell.inputs.nixpkgs.follows = "nixpkgs";
inputs.devshell.inputs.systems.follows = "systems";
inputs.fenix.url = "github:nix-community/fenix";
inputs.fenix.inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.flake-utils.inputs.systems.follows = "systems";
inputs.flake-compat.url = "github:nix-community/flake-compat";
inputs.flake-compat.flake = false;
outputs = {
self,
nixpkgs,
advisory-db,
crane,
custom-nixpkgs,
devshell,
fenix,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [custom-nixpkgs.overlays.default devshell.overlays.default];
};
rustStable = (import fenix {inherit pkgs;}).fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-Q9UgzzvxLi4x9aWUJTn+/5EXekC98ODRU1TwhUs9RnY=";
};
craneLib = (crane.mkLib pkgs).overrideToolchain rustStable;
commonArgs = {
src = craneLib.cleanCargoSource ./.;
buildInputs = [];
nativeBuildInputs = [];
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
};
cargoArtifacts = craneLib.buildDepsOnly (commonArgs // {doCheck = false;});
twt = craneLib.buildPackage (commonArgs // {doCheck = false;});
twt-clippy = craneLib.cargoClippy (commonArgs
// {
inherit cargoArtifacts;
});
twt-fmt = craneLib.cargoFmt (commonArgs // {});
twt-audit = craneLib.cargoAudit (commonArgs // {inherit advisory-db;});
twt-nextest = craneLib.cargoNextest (commonArgs
// {
inherit cargoArtifacts;
partitions = 1;
partitionType = "count";
});
in {
checks = {
inherit twt twt-audit twt-clippy twt-fmt twt-nextest;
};
packages.default = twt;
apps.default = flake-utils.lib.mkApp {drv = twt;};
devShells.default = pkgs.devshell.mkShell {
bash = {interactive = "";};
env = [
{
name = "DEVSHELL_NO_MOTD";
value = 1;
}
];
packages = with pkgs; [
cargo-dist-unstable
cargo-nextest
cargo-release
oranda
rustStable
];
};
});
}