Skip to content

Commit 66a3a63

Browse files
Setup basic Nix flake.
1 parent 0cc66c8 commit 66a3a63

File tree

2 files changed

+229
-0
lines changed

2 files changed

+229
-0
lines changed

flake.lock

+151
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
description = "Development environment";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
6+
flakelight.url = "github:nix-community/flakelight";
7+
crane = {
8+
url = "github:ipetkov/crane";
9+
inputs.nixpkgs.follows = "nixpkgs";
10+
};
11+
rust-overlay.url = "github:oxalica/rust-overlay";
12+
};
13+
14+
outputs = { flakelight, ... } @ inputs : flakelight ./. {
15+
inherit inputs;
16+
withOverlays = [
17+
inputs.rust-overlay.overlays.default
18+
(final: { inputs', lib, rust-bin, ... }: let
19+
# version:
20+
# "latest" => latest stable
21+
# "nightly" => latest nightly
22+
# "1.61.0" => specific stable version
23+
craneLib = version: inputs'.crane.lib.overrideToolchain (if version == "nightly" then rust-bin.nightly.latest.default else rust-bin.stable.${version}.default);
24+
commonArgs = {
25+
src = ./.;
26+
pname = "antithesis-sdk-rust-workspace";
27+
version = "0.0.0";
28+
};
29+
workspaceDeps = version: (craneLib version).buildDepsOnly commonArgs;
30+
workspace = version: (craneLib version).buildPackage (commonArgs // {
31+
cargoArtifacts = workspaceDeps version;
32+
});
33+
clippy = version: (craneLib version).cargoClippy (commonArgs // {
34+
cargoArtifacts = workspaceDeps version;
35+
cargoClippyExtraArgs = "--all-targets -- -D warnings";
36+
});
37+
test = version: (craneLib version).cargoTest (commonArgs // {
38+
cargoArtifacts = workspaceDeps version;
39+
});
40+
doc = version: (craneLib version).cargoDoc (commonArgs // {
41+
cargoArtifacts = workspaceDeps version;
42+
});
43+
in {
44+
inherit craneLib workspaceDeps;
45+
antithesis-sdk-rust = {
46+
workspace = workspace "nightly";
47+
workspaceMSRV = workspace (lib.importTOML ./lib/Cargo.toml).package.rust-version;
48+
clippy = clippy "nightly";
49+
test = test "nightly";
50+
doc = doc "nightly";
51+
};
52+
})
53+
];
54+
55+
packages = rec {
56+
default = workspace;
57+
workspace = { antithesis-sdk-rust }: antithesis-sdk-rust.workspace;
58+
doc = { antithesis-sdk-rust }: antithesis-sdk-rust.doc;
59+
};
60+
61+
apps = rec {
62+
default = simple;
63+
simple = pkgs: "${pkgs.antithesis-sdk-rust-workspace}/bin/simple";
64+
};
65+
66+
devShells.default = pkgs: {
67+
packages = with pkgs; [ rust-analyzer cargo-msrv ];
68+
};
69+
70+
# TODO: Check minimal versions of dependency, and feature flags.
71+
# TODO: Do we what formatters?
72+
checks = { antithesis-sdk-rust, ... }: {
73+
inherit (antithesis-sdk-rust) workspaceMSRV clippy test;
74+
};
75+
76+
flakelight.builtinFormatters = false;
77+
};
78+
}

0 commit comments

Comments
 (0)