forked from seanmonstar/reqwest
-
Notifications
You must be signed in to change notification settings - Fork 6
/
flake.nix
104 lines (79 loc) · 2.49 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
{
description = "Build env";
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) ];
};
rustVersion = "1.65.0";
rust = pkgs.rust-bin.stable.${rustVersion}.default.override {
extensions = [
"rust-src" # rust-analyzer
];
};
nixLib = nixpkgs.lib;
craneLib = (crane.mkLib pkgs).overrideToolchain rust;
envVars = rec {
RUST_BACKTRACE = 1;
MOLD_PATH = "${pkgs.mold.out}/bin/mold";
RUSTFLAGS = "-Clink-arg=-fuse-ld=${MOLD_PATH} -Clinker=clang";
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
};
# Allow more files to be included in the build workspace
workspaceSrc = ./.;
# workspaceSrcString = builtins.toString workspaceSrc;
workspaceFilter = path: type:
(craneLib.filterCargoSources path type);
# The main application derivation
reqwest-impersonate = craneLib.buildPackage
(rec {
src = nixLib.cleanSourceWith
{
src = workspaceSrc;
filter = workspaceFilter;
};
doCheck = false;
buildInputs = with pkgs;
[
openssl
boringssl
]
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ ];
nativeBuildInputs = with pkgs;
[
clang
pkg-config
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ ];
LD_LIBRARY_PATH = nixLib.makeLibraryPath buildInputs;
} // envVars);
in
{
checks = {
inherit reqwest-impersonate;
};
packages.default = reqwest-impersonate;
devShells.rust = pkgs.mkShell ({
nativeBuildInputs = [
rust
];
} // envVars);
devShells.default = reqwest-impersonate;
});
}