forked from antithesishq/antithesis-sdk-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
93 lines (85 loc) · 3.4 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
{
description = "Development environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
flakelight.url = "github:nix-community/flakelight";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs = { flakelight, ... } @ inputs: flakelight ./. {
inherit inputs;
withOverlays = [
inputs.rust-overlay.overlays.default
(final: { inputs', lib, rust-bin, ... }:
let
# version:
# "latest" => latest stable
# "nightly" => latest nightly
# "1.61.0" => specific stable version
craneLib = version: inputs'.crane.lib.overrideToolchain (if version == "nightly" then rust-bin.nightly.latest.default else rust-bin.stable.${version}.default);
commonArgs = {
src = ./.;
pname = "antithesis-sdk-rust-workspace";
version = "0.0.0";
};
workspaceDeps = version: (craneLib version).buildDepsOnly commonArgs;
workspace = version: (craneLib version).buildPackage (commonArgs // {
cargoArtifacts = workspaceDeps version;
});
workspaceEmptyFeature = version: (craneLib version).buildPackage (commonArgs // {
cargoArtifacts = workspaceDeps version;
cargoExtraArgs = "--no-default-features"; # Disable the default `full` feature for builds.
cargoTestExtraArgs = "-F full"; # But enable the `full` feature when running `cargo test`.
});
clippy = version: (craneLib version).cargoClippy (commonArgs // {
cargoArtifacts = workspaceDeps version;
cargoClippyExtraArgs = "--all-targets -- -D warnings";
});
test = version: (craneLib version).cargoTest (commonArgs // {
cargoArtifacts = workspaceDeps version;
});
doc = version: (craneLib version).cargoDoc (commonArgs // {
cargoArtifacts = workspaceDeps version;
});
in
{
inherit craneLib workspaceDeps;
antithesis-sdk-rust = {
workspace = workspace "nightly";
workspaceEmptyFeature = workspaceEmptyFeature "nightly";
workspaceMSRV = workspace (lib.importTOML ./lib/Cargo.toml).package.rust-version;
clippy = clippy "nightly";
test = test "nightly";
doc = doc "nightly";
};
})
];
packages = rec {
default = workspace;
workspace = { antithesis-sdk-rust }: antithesis-sdk-rust.workspace;
doc = { antithesis-sdk-rust }: antithesis-sdk-rust.doc;
};
apps = rec {
default = simple;
simple = pkgs: "${pkgs.antithesis-sdk-rust-workspace}/bin/simple";
};
devShells.default = pkgs: {
inputsFrom = with pkgs; [ antithesis-sdk-rust.workspace ];
packages = with pkgs; [ rust-analyzer cargo-msrv ];
};
# TODO: Perform semver check.
checks = { antithesis-sdk-rust, ... }: {
inherit (antithesis-sdk-rust) workspaceMSRV workspaceEmptyFeature clippy test;
};
# TODO: Decide whether we want auto formatting.
# formatters = pkgs: {
# "*.rs" = "${pkgs.rustfmt}/bin/rustfmt";
# "*.nix" = "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt";
# };
flakelight.builtinFormatters = false;
};
}