tAoC2022/flake.nix
2022-12-02 16:02:56 +11:00

99 lines
2.4 KiB
Nix

{
description = "tAoC2022 - Nix Builder";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
advisory-db = {
url = "github:rustsec/advisory-db";
flake = false;
};
# my rust project
# taoc2022 = {
# url = "git+ssh://gitea@git.p7.co.nz/thornAvery/tAoC2022";
# flake = false;
# };
};
outputs = { self, nixpkgs, crane, flake-utils, advisory-db, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
inherit (pkgs) lib;
craneLib = crane.lib.${system};
src = ./.;
buildInputs = [
] ++ lib.optionals pkgs.stdenv.isDarwin [
pkgs.libiconv
];
cargoArtifacts = craneLib.buildDepsOnly {
inherit src buildInputs;
};
my-crate = craneLib.buildPackage {
inherit cargoArtifacts src buildInputs;
};
in
{
checks = {
inherit my-crate;
my-crate-clippy = craneLib.cargoClippy {
inherit cargoArtifacts src buildInputs;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
};
my-crate-doc = craneLib.cargoDoc {
inherit cargoArtifacts src;
};
my-crate-fmt = craneLib.cargoFmt {
inherit src;
};
my-crate-audit = craneLib.cargoAudit {
inherit src advisory-db;
};
my-crate-nextest = craneLib.cargoNextest {
inherit cargoArtifacts src buildInputs;
partitions = 1;
partitionType = "count";
};
} // lib.optionalAttrs (system == "x86_64-linux") {
# cargo-tarpaulin only supports x86_64 systems
my-crate-coverage = craneLib.cargoTarpaulin {
inherit cargoArtifacts src;
};
};
packages.default = my-crate;
apps.default = flake-utils.lib.mkApp {
drv = my-crate;
};
devShells.default = pkgs.mkShell {
inputsFrom = builtins.attrValues self.checks;
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
nativeBuildInputs = with pkgs; [
cargo
rustc
rust-analyzer
];
};
});
}