-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathflake.nix
More file actions
113 lines (94 loc) · 3.1 KB
/
flake.nix
File metadata and controls
113 lines (94 loc) · 3.1 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
{
description = "A Rust SDK for interacting with GolemBase.";
inputs = {
nixpkgs.url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz";
crane.url = "github:ipetkov/crane";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.rust-analyzer-src.follows = "";
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{ self
, nixpkgs
, crane
, fenix
, flake-utils
, ...
}:
flake-utils.lib.eachDefaultSystem (system:
let
inherit (pkgs) lib;
pkgs = nixpkgs.legacyPackages.${system};
rustToolchain = fenix.packages.${system}.fromToolchainFile {
file = ./.rust-toolchain.toml;
sha256 = "sha256-Qxt8XAuaUR2OMdKbN4u8dBJOhSHxS+uS06Wl9+flVEk=";
};
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
src =
let
markdownFilter = path: _type: builtins.match ".*md$" path != null;
markdownOrCargo = path: type:
(markdownFilter path type) || (craneLib.filterCargoSources path type);
in
lib.cleanSourceWith {
src = ./.;
filter = markdownOrCargo;
name = "source";
};
commonArgs = {
inherit src;
strictDeps = true;
# TODO: Check dependencies for rustls, we can potentially
# remove the dependency on pkg-config and openssl
nativeBuildInputs = with pkgs; [ pkg-config ];
buildInputs = with pkgs; [ openssl ];
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
golem-base-sdk = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
doCheck = false; # The tests don't work in the nix sandbox
});
in
{
# Additional cargo checks can be found at https://github.com/ipetkov/crane.
#
# These derivations are inherited by the `devShell`.
checks = {
inherit golem-base-sdk;
cargo-clippy = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});
cargo-fmt = craneLib.cargoFmt {
inherit src;
};
taplo-fmt = craneLib.taploFmt {
src = pkgs.lib.sources.sourceFilesBySuffices src [ ".toml" ];
};
cargo-doc = craneLib.cargoDoc (commonArgs // {
inherit cargoArtifacts;
cargoDocExtraArgs = "--no-deps --workspace";
# This can be commented out or tweaked as necessary, e.g. set to
# `--deny rustdoc::broken-intra-doc-links` to only enforce that lint
env.RUSTDOCFLAGS = "--deny warnings";
});
};
packages = {
inherit golem-base-sdk;
default = golem-base-sdk;
};
devShells.default = craneLib.devShell {
checks = self.checks.${system};
packages = with pkgs; [
pre-commit
nixpkgs-fmt
] ++ lib.optionals (!pkgs.stdenv.isDarwin) [
nil # currently requires compiling the world
];
};
formatter = pkgs.nixpkgs-fmt;
});
}