forked from tokio-rs/console
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
109 lines (98 loc) · 3.88 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
108
109
{
description = "The Tokio console: a debugger for async Rust.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
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, flake-utils, rust-overlay }:
flake-utils.lib.eachDefaultSystem
(system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
####################################################################
#### tokio-console package ####
####################################################################
tokio-console = with pkgs; let
inherit (nix-gitignore) gitignoreFilterPure withGitignoreFile;
# Workaround for the builtins.filterSource issue mentioned in
# https://nixos.org/manual/nix/unstable/expressions/builtins.html
# Since this might be built from a flake, the source path may be a store path,
# so we need to provide our own version of gitignoreSource that avoids
# builtins.filterSource in favor of builtins.path.
gitignoreSource = patterns: path:
builtins.path {
filter =
gitignoreFilterPure (_: _: true) (withGitignoreFile patterns path) path;
path = path;
name = "src";
};
# Ignore some extra things that don't factor into the main build to help with
# caching.
extraIgnores = ''
/.envrc
/*.nix
/flake.*
/netlify.toml
/.github
/assets
/*.md
/.gitignore
/LICENSE
'';
src = gitignoreSource extraIgnores ./.;
cargoTOML = lib.importTOML "${src}/tokio-console/Cargo.toml";
rustToolchain = rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
rust = makeRustPlatform {
cargo = rustToolchain;
rustc = rustToolchain;
};
in
rust.buildRustPackage
{
pname = cargoTOML.package.name;
version = cargoTOML.package.version;
nativeBuildInputs = [ protobuf ];
inherit src;
cargoLock = { lockFile = "${src}/Cargo.lock"; };
meta = {
inherit (cargoTOML.package) description homepage license;
maintainers = cargoTOML.package.authors;
};
};
####################################################################
#### dev shell ####
####################################################################
devShell = with pkgs;
mkShell {
name = "tokio-console-env";
buildInputs = tokio-console.buildInputs ++ lib.optional stdenv.isDarwin libiconv;
nativeBuildInputs = tokio-console.nativeBuildInputs;
RUST_SRC_PATH = "${rustPlatform.rustLibSrc}";
CARGO_TERM_COLOR = "always";
RUST_BACKTRACE = "full";
};
in
{
apps = {
tokio-console = {
type = "app";
program = "${tokio-console}/bin/tokio-console";
description = "The Tokio console: a debugger for async Rust.";
};
default = self.apps.${system}.tokio-console;
};
devShells.default = devShell;
packages = {
inherit tokio-console;
default = self.packages.${system}.tokio-console;
};
});
}