generated from matthiasbeyer/enterprise-rust-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
159 lines (123 loc) · 4.67 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
{
description = "The type_description rust library flake";
inputs = {
nixpkgs.url = "nixpkgs/nixos-22.05";
flake-utils = {
url = "github:numtide/flake-utils";
};
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
};
outputs = { self, nixpkgs, crane, flake-utils, rust-overlay, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
wasm-bindgen-cli = pkgs.rustPlatform.buildRustPackage rec {
pname = "wasm-bindgen-cli";
version = "0.2.84";
src = pkgs.fetchCrate {
inherit pname version;
sha256 = "sha256-0rK+Yx4/Jy44Fw5VwJ3tG243ZsyOIBBehYU54XP/JGk=";
};
cargoSha256 = "sha256-vcpxcRlW1OKoD64owFF6mkxSqmNrvY+y3Ckn5UwEQ50=";
nativeBuildInputs = [ pkgs.pkg-config ];
buildInputs = [ pkgs.openssl ];
checkInputs = [ pkgs.nodejs ];
# other tests require it to be ran in the wasm-bindgen monorepo
cargoTestFlags = [ "--test=interface-types" ];
meta = with pkgs.lib; {
homepage = "https://rustwasm.github.io/docs/wasm-bindgen/";
license = with licenses; [ asl20 /* or */ mit ];
description = "Facilitating high-level interactions between wasm modules and JavaScript";
maintainers = with maintainers; [ nitsky rizary ];
mainProgram = "wasm-bindgen";
};
};
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
rustTarget = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
craneLib = (crane.mkLib pkgs).overrideToolchain rustTarget;
tomlInfo = craneLib.crateNameFromCargoToml { cargoToml = ./Cargo.toml; };
inherit (tomlInfo) pname version;
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
cargoArtifacts = craneLib.buildDepsOnly {
inherit src;
cargoExtraArgs = "--all-features";
};
type_description = craneLib.buildPackage {
inherit cargoArtifacts src version;
cargoExtraArgs = "--all-features";
};
book = craneLib.mkCargoDerivation {
inherit cargoArtifacts src version;
cargoVendorDir = null;
buildPhaseCargoCommand = "mdbook build doc_guide -d $out";
checkPhaseCargoCommand = "mdbook test doc_guide -L target/debug/deps";
postFixup = "rm -rf $out/target";
pname = "type_description_book";
nativeBuildInputs = [ pkgs.mdbook ];
};
description_website = craneLib.mkCargoDerivation rec {
inherit cargoArtifacts src version;
CARGO_NET_OFFLINE = "true";
TRUNK_STAGING_DIR = "/tmp/trunk-staging";
XDG_CACHE_HOME = "/tmp/trunk-cache";
PUBLIC_URL = "/";
buildPhaseCargoCommand = "trunk build online_description_generator/index.html --dist $out --release --public-url $PUBLIC_URL";
postFixup = "rm -rf $out/target";
pname = "type_description_website";
nativeBuildInputs = [
pkgs.trunk
pkgs.binaryen
pkgs.nodePackages.sass
wasm-bindgen-cli
];
};
in
rec {
checks = {
inherit type_description book;
type_description-clippy = craneLib.cargoClippy {
inherit cargoArtifacts src;
cargoClippyExtraArgs = "--all-features -- --deny warnings";
};
type_description-fmt = craneLib.cargoFmt {
inherit src;
};
};
packages.book = book;
packages.description_website = description_website;
packages.description_website_gh_pages = description_website.overrideAttrs (_: _: { PUBLIC_URL = "type_description/description_viewer/"; });
packages.type_description = type_description;
packages.default = packages.type_description;
devShells.type_description = pkgs.mkShell {
nativeBuildInputs = [
rustTarget
pkgs.cargo-msrv
pkgs.cargo-edit
pkgs.cargo-deny
pkgs.cargo-expand
pkgs.cargo-bloat
pkgs.mdbook
pkgs.trunk
wasm-bindgen-cli
pkgs.binaryen
pkgs.nodePackages.sass
];
# Tell the trybuild crate to not use the wip folder
TRYBUILD = "overwrite";
};
devShells.default = devShells.type_description;
}
);
}