-
Notifications
You must be signed in to change notification settings - Fork 4
/
flake.nix
92 lines (79 loc) · 2.55 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
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
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
rustToolchain = pkgs.rust-bin.stable."1.75.0".default.override {
targets = [ "wasm32-unknown-unknown" ];
};
craneLib = ((crane.mkLib pkgs).overrideToolchain rustToolchain);
all = craneLib.buildPackage {
# NOTE: we need to force lld otherwise rust-lld is not found for wasm32 target
CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_LINKER = "lld";
pname = "all";
src = let
# Only keeps markdown files
tarFilter = path: _type: builtins.match ".*tar$" path != null;
tarOrCargo = path: type:
(tarFilter path type) || (craneLib.filterCargoSources path type);
in nixpkgs.lib.cleanSourceWith {
src = craneLib.path ./.;
filter = tarOrCargo;
};
strictDeps = true;
nativeBuildInputs = [
pkgs.binaryen
pkgs.pkg-config
pkgs.rustc-wasm32.llvmPackages.lld
];
buildInputs = [
pkgs.openssl
# Add additional build inputs here
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
# Additional darwin specific inputs can be set here
pkgs.libiconv
];
doCheck = false;
# Additional environment variables can be set directly
# MY_CUSTOM_VAR = "some value";
};
in
{
packages.default = all;
devShells.default = craneLib.devShell {
# Automatically inherit any build inputs from `my-crate`
inputsFrom = [ all ];
# Extra inputs (only used for interactive development)
# can be added here; cargo and rustc are provided by default.
packages = [
pkgs.bat
pkgs.cargo-audit
pkgs.cargo-edit
pkgs.cargo-nextest
pkgs.cargo-watch
pkgs.ripgrep
pkgs.rust-analyzer
pkgs.stgit
];
CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_LINKER = "lld";
};
});
}