-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
134 lines (120 loc) · 4.62 KB
/
flake.nix
File metadata and controls
134 lines (120 loc) · 4.62 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
{
description = "netprofiler_lite: shareable object storage throughput benchmark";
nixConfig = {
extra-substituters = [
"https://nix-community.cachix.org"
];
extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUQxH7u0yZ6u5nYzK5vC7g1VQJzY="
];
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
flake-utils.url = "github:numtide/flake-utils";
fenix.url = "github:nix-community/fenix";
};
outputs = { self, nixpkgs, flake-utils, fenix }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
# Fenix toolchain provides `cargo`, `rustc`, `clippy`, `rustfmt`, etc.
stable = fenix.packages.${system}.stable;
toolchain = stable.toolchain;
rustPlatform = pkgs.makeRustPlatform {
cargo = toolchain;
rustc = toolchain;
};
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
pkgVersion = cargoToml.package.version;
in
{
# Package
# - `nix build` produces: ./result/bin/netprofiler_lite
packages.default = rustPlatform.buildRustPackage {
pname = "netprofiler_lite";
version = pkgVersion;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
doCheck = false;
nativeBuildInputs = [ pkgs.pkg-config ];
};
# Static Linux package
# - `nix build .#linux-static` produces a statically linked musl binary
# - uses the same Rust toolchain as the normal build (fenix stable)
packages.linux-static =
if pkgs.stdenv.isLinux then
let
pkgsStatic = pkgs.pkgsStatic;
toolchainMusl = fenix.packages.${system}.combine [
stable.cargo
stable.rustc
fenix.packages.${system}.targets.x86_64-unknown-linux-musl.stable.rust-std
];
rustPlatformMusl = pkgsStatic.makeRustPlatform {
cargo = toolchainMusl;
rustc = toolchainMusl;
};
in
rustPlatformMusl.buildRustPackage {
pname = "netprofiler_lite";
version = pkgVersion;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
doCheck = false;
# Force the musl target so the resulting binary is fully static.
cargoBuildTarget = "x86_64-unknown-linux-musl";
RUSTFLAGS = "-C target-feature=+crt-static";
}
else
pkgs.writeText "linux-static-unavailable" "linux-static is only available on Linux";
# Apps
# - `nix run .` runs the binary
# - `nix run .#bench` runs a default benchmark command
# - `nix run .#seed` runs the maintainer preseeding script
apps.default = flake-utils.lib.mkApp {
drv = self.packages.${system}.default;
};
apps.bench = flake-utils.lib.mkApp {
drv = pkgs.writeShellApplication {
name = "netprofiler_lite_bench";
runtimeInputs = [ pkgs.bash pkgs.coreutils ];
text = ''
backends="sf-netprofiler-lite-public-6f9c2e-eun1:eu-north-1,sf-netprofiler-lite-public-6f9c2e-euc1:eu-central-1,sf-netprofiler-lite-public-6f9c2e-usw2:us-west-2,sf-netprofiler-lite-public-6f9c2e-use1:us-east-1,https://pub-0323b6896e3e42cb8971495d2f9a2370.r2.dev,https://pub-c02404be13b644a1874a29231dfbe0d2.r2.dev"
exec "${self.packages.${system}.default}/bin/netprofiler_lite" \
--backends "$backends" \
--direction download \
--concurrency 256 \
--duration 15 \
--prefix data-8m \
--file-count 100 \
--file-size-mb 8 \
"$@"
'';
};
};
# Dev shell
# - `nix develop` provides the Rust toolchain + utilities used by scripts
devShells.default = pkgs.mkShell {
packages = [
pkgs.pkg-config
pkgs.awscli2
pkgs.curl
pkgs.doppler
stable.cargo
stable.clippy
stable.rustc
stable.rustfmt
];
};
apps.seed = flake-utils.lib.mkApp {
drv = pkgs.writeShellApplication {
name = "seed_artifacts";
runtimeInputs = [ pkgs.bash pkgs.awscli2 pkgs.coreutils pkgs.curl pkgs.doppler ];
text = ''
exec bash "${self}/scripts/seed_artifacts.sh" "$@"
'';
};
};
formatter = pkgs.nixfmt-rfc-style;
});
}