templates/rust/cargo-nightly/crane+fenix/flake.nix

59 lines
1.8 KiB
Nix

{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
systems.url = "github:nix-systems/default";
crane.url = "github:ipetkov/crane";
fenix.url = "github:nix-community/fenix";
fenix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, systems, crane, fenix, ... }:
let
eachSystem = nixpkgs.lib.genAttrs (import systems);
fenixToolchain = "default";
in {
packages = eachSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
toolchain = fenix.packages.${system}.${fenixToolchain}.toolchain;
in {
hello = pkgs.callPackage ./package.nix {
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
};
default = self.packages.${system}.hello;
});
devShells = eachSystem (system:
let pkgs = nixpkgs.legacyPackages.${system};
in {
default = import ./shell.nix { inherit pkgs crane fenix fenixToolchain; };
});
checks = eachSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
toolchain = fenix.packages.${system}.${fenixToolchain}.toolchain;
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
crate = self.packages.${system}.default;
in {
inherit crate;
clippy = craneLib.cargoClippy (
crate.commonArgs
// {
inherit (crate) cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
}
);
doc = craneLib.cargoDoc (
crate.commonArgs
// {
inherit (crate) cargoArtifacts;
env.RUSTDOCFLAGS = "--deny warnings";
}
);
});
};
}