-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
107 lines (92 loc) · 2.7 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
# This is used to create a local development shell with Nix, containing all the
# packages used for development.
#
# To use it, install Nix and run `nix develop`.
#
# You can use it with direnv by creating a file called .envrc.local and adding
# the line, `use flake`.
{
description = "ndc-sdk-rs";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs?branch=nixos-unstable";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
};
outputs =
{ self
, flake-utils
, nixpkgs
, crane
, rust-overlay
}:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
buildArgs = with pkgs; {
pname = "ndc-sdk";
src = craneLib.cleanCargoSource (craneLib.path ./.);
strictDeps = true;
# build-time inputs
nativeBuildInputs = [
openssl.dev # required to build Rust crates that can conduct TLS connections
pkg-config # required to find OpenSSL
];
# runtime inputs
buildInputs = [
openssl # required for TLS connections
protobuf # required by opentelemetry-proto, a dependency of axum-tracing-opentelemetry
] ++ lib.optionals hostPlatform.isDarwin [
# macOS-specific dependencies
libiconv
darwin.apple_sdk.frameworks.CoreFoundation
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.SystemConfiguration
];
};
in
{
packages = {
deps = craneLib.buildDepsOnly buildArgs;
default = craneLib.buildPackage
(buildArgs // {
cargoArtifacts = self.packages.${system}.deps;
doCheck = false;
});
};
apps = {
example = flake-utils.lib.mkApp {
drv = self.packages.${system}.default;
exePath = "/bin/ndc_hub_example";
};
};
devShells.default = with pkgs; mkShell {
inputsFrom = [ self.packages.${system}.default ];
nativeBuildInputs = [
rustToolchain
bacon
cargo-edit
cargo-machete
cargo-nextest
cargo-watch
just
nixpkgs-fmt
nodePackages.prettier
];
};
formatter = pkgs.nixpkgs-fmt;
});
}