|
2 | 2 | description = "The Tokio console: a debugger for async Rust.";
|
3 | 3 |
|
4 | 4 | inputs = {
|
5 |
| - # nixpkgs.url = "github:nixos/nixpkgs/release-21.11"; |
6 |
| - flake-utils = { |
7 |
| - url = "github:numtide/flake-utils"; |
8 |
| - inputs.nixpkgs.follows = "nixpkgs"; |
| 5 | + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; |
| 6 | + flake-utils.url = "github:numtide/flake-utils"; |
| 7 | + rust-overlay = { |
| 8 | + url = "github:oxalica/rust-overlay"; |
| 9 | + inputs = { |
| 10 | + nixpkgs.follows = "nixpkgs"; |
| 11 | + flake-utils.follows = "flake-utils"; |
| 12 | + }; |
9 | 13 | };
|
10 | 14 | };
|
11 | 15 |
|
12 |
| - outputs = { self, nixpkgs, flake-utils }: |
13 |
| - flake-utils.lib.eachDefaultSystem (system: |
14 |
| - let |
15 |
| - pkgs = import nixpkgs { inherit system; }; |
16 |
| - tokio-console = import ./nix { inherit pkgs; }; |
17 |
| - devShell = import ./nix/shell.nix { inherit pkgs; }; |
18 |
| - in |
19 |
| - { |
20 |
| - inherit devShell; |
21 |
| - packages = { inherit tokio-console; }; |
22 |
| - defaultPackage = tokio-console; |
23 |
| - }); |
| 16 | + outputs = { self, nixpkgs, flake-utils, rust-overlay }: |
| 17 | + flake-utils.lib.eachDefaultSystem |
| 18 | + (system: |
| 19 | + let |
| 20 | + overlays = [ (import rust-overlay) ]; |
| 21 | + pkgs = import nixpkgs { inherit system overlays; }; |
| 22 | + |
| 23 | + #################################################################### |
| 24 | + #### tokio-console package #### |
| 25 | + #################################################################### |
| 26 | + tokio-console = with pkgs; let |
| 27 | + inherit (nix-gitignore) gitignoreFilterPure withGitignoreFile; |
| 28 | + # Workaround for the builtins.filterSource issue mentioned in |
| 29 | + # https://nixos.org/manual/nix/unstable/expressions/builtins.html |
| 30 | + # Since this might be built from a flake, the source path may be a store path, |
| 31 | + # so we need to provide our own version of gitignoreSource that avoids |
| 32 | + # builtins.filterSource in favor of builtins.path. |
| 33 | + gitignoreSource = patterns: path: |
| 34 | + builtins.path { |
| 35 | + filter = |
| 36 | + gitignoreFilterPure (_: _: true) (withGitignoreFile patterns path) path; |
| 37 | + path = path; |
| 38 | + name = "src"; |
| 39 | + }; |
| 40 | + |
| 41 | + # Ignore some extra things that don't factor into the main build to help with |
| 42 | + # caching. |
| 43 | + extraIgnores = '' |
| 44 | + /.envrc |
| 45 | + /*.nix |
| 46 | + /flake.* |
| 47 | + /netlify.toml |
| 48 | + /.github |
| 49 | + /assets |
| 50 | + /*.md |
| 51 | + /.gitignore |
| 52 | + /LICENSE |
| 53 | + ''; |
| 54 | + |
| 55 | + src = gitignoreSource extraIgnores ./.; |
| 56 | + |
| 57 | + cargoTOML = lib.importTOML "${src}/tokio-console/Cargo.toml"; |
| 58 | + rustToolchain = rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; |
| 59 | + rust = makeRustPlatform { |
| 60 | + cargo = rustToolchain; |
| 61 | + rustc = rustToolchain; |
| 62 | + }; |
| 63 | + in |
| 64 | + rust.buildRustPackage |
| 65 | + { |
| 66 | + pname = cargoTOML.package.name; |
| 67 | + version = cargoTOML.package.version; |
| 68 | + |
| 69 | + nativeBuildInputs = [ protobuf ]; |
| 70 | + |
| 71 | + inherit src; |
| 72 | + |
| 73 | + cargoLock = { lockFile = "${src}/Cargo.lock"; }; |
| 74 | + |
| 75 | + meta = { |
| 76 | + inherit (cargoTOML.package) description homepage license; |
| 77 | + maintainers = cargoTOML.package.authors; |
| 78 | + }; |
| 79 | + }; |
| 80 | + |
| 81 | + #################################################################### |
| 82 | + #### dev shell #### |
| 83 | + #################################################################### |
| 84 | + devShell = with pkgs; |
| 85 | + mkShell { |
| 86 | + name = "tokio-console-env"; |
| 87 | + buildInputs = tokio-console.buildInputs ++ lib.optional stdenv.isDarwin libiconv; |
| 88 | + nativeBuildInputs = tokio-console.nativeBuildInputs; |
| 89 | + RUST_SRC_PATH = "${rustPlatform.rustLibSrc}"; |
| 90 | + CARGO_TERM_COLOR = "always"; |
| 91 | + RUST_BACKTRACE = "full"; |
| 92 | + }; |
| 93 | + in |
| 94 | + { |
| 95 | + apps = { |
| 96 | + tokio-console = { |
| 97 | + type = "app"; |
| 98 | + program = "${tokio-console}/bin/tokio-console"; |
| 99 | + description = "The Tokio console: a debugger for async Rust."; |
| 100 | + }; |
| 101 | + default = self.apps.${system}.tokio-console; |
| 102 | + }; |
| 103 | + devShells.default = devShell; |
| 104 | + packages = { |
| 105 | + inherit tokio-console; |
| 106 | + default = self.packages.${system}.tokio-console; |
| 107 | + }; |
| 108 | + }); |
24 | 109 | }
|
0 commit comments