Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
112 lines (98 loc) · 3.1 KB
/
Copy pathflake.nix
File metadata and controls
112 lines (98 loc) · 3.1 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
{
description = "wtfi2 — What The F*ck Internet: a live, visual network-path diagnostic";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs =
{ self, nixpkgs }:
let
lib = nixpkgs.lib;
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
forAllSystems = lib.genAttrs systems;
pkgsFor = system: import nixpkgs { inherit system; };
# Read the version from Cargo.toml so the flake can never drift from the crate.
version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.version;
description = "Live, visual network-path diagnostic that pinpoints exactly where your connection dies";
# Linux shells out to these at runtime (ip/iw for link telemetry, ping and
# traceroute for the probes). Appended to PATH, not prepended: a distro's
# own ping carries cap_net_raw, the store copy does not.
runtimeTools =
pkgs: with pkgs; [
iproute2
iw
iputils
traceroute
];
mkWtfi =
pkgs:
pkgs.rustPlatform.buildRustPackage {
pname = "wtfi2";
inherit version;
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./Cargo.toml
./Cargo.lock
./src
./tests
];
};
cargoLock.lockFile = ./Cargo.lock;
nativeBuildInputs = lib.optionals pkgs.stdenv.hostPlatform.isLinux [ pkgs.makeWrapper ];
postInstall = lib.optionalString pkgs.stdenv.hostPlatform.isLinux ''
wrapProgram $out/bin/wtfi \
--suffix PATH : ${lib.makeBinPath (runtimeTools pkgs)}
'';
meta = {
inherit description;
homepage = "https://github.com/kanywst/wtfi2";
license = lib.licenses.mit;
mainProgram = "wtfi";
platforms = lib.platforms.linux ++ lib.platforms.darwin;
};
};
app = system: {
type = "app";
program = "${self.packages.${system}.wtfi2}/bin/wtfi";
meta.description = description;
};
in
{
packages = forAllSystems (system: {
wtfi2 = mkWtfi (pkgsFor system);
default = self.packages.${system}.wtfi2;
});
overlays.default = final: _prev: {
wtfi2 = mkWtfi final;
};
nixosModules.default = { ... }: {
nixpkgs.overlays = [ self.overlays.default ];
};
apps = forAllSystems (system: {
default = app system;
wtfi2 = app system;
});
devShells = forAllSystems (
system:
let
pkgs = pkgsFor system;
in
{
default = pkgs.mkShell {
packages =
with pkgs;
[
cargo
rustc
rustfmt
clippy
]
++ lib.optionals pkgs.stdenv.hostPlatform.isLinux (runtimeTools pkgs);
};
}
);
formatter = forAllSystems (system: (pkgsFor system).nixfmt);
};
}