/ flake.nix
flake.nix
1 { 2 description = "Apibara development environment"; 3 4 inputs = { 5 nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11"; 6 flake-utils = { 7 url = "github:numtide/flake-utils"; 8 }; 9 rust-overlay = { 10 url = "github:oxalica/rust-overlay"; 11 inputs.nixpkgs.follows = "nixpkgs"; 12 }; 13 crane = { 14 url = "github:ipetkov/crane?rev=35110cccf28823320f4fd697fcafcb5038683982"; 15 inputs.nixpkgs.follows = "nixpkgs"; 16 }; 17 pre-commit-hooks = { 18 url = "github:cachix/pre-commit-hooks.nix"; 19 }; 20 }; 21 22 outputs = { self, nixpkgs, rust-overlay, flake-utils, crane, pre-commit-hooks, ... }: 23 flake-utils.lib.eachDefaultSystem (system: 24 let 25 overlays = [ 26 (import rust-overlay) 27 (import ./nix/overlay.nix) 28 ]; 29 30 pkgs = import nixpkgs { 31 inherit system overlays; 32 }; 33 34 crates = { 35 starknet = { 36 description = "The Starknet DNA server"; 37 path = ./starknet; 38 ports = { 39 "7171/tcp" = { }; 40 }; 41 }; 42 operator = { 43 description = "The Apibara Kubernetese Operator"; 44 path = ./operator; 45 ports = { 46 "8118/tcp" = { }; 47 }; 48 }; 49 sink-console = { 50 description = "Print stream data to the console"; 51 path = ./sinks/sink-console; 52 volumes = { 53 "/data" = { }; 54 }; 55 ports = { 56 "8118/tcp" = { }; 57 }; 58 }; 59 sink-webhook = { 60 description = "Integration to connect onchain data to HTTP endpoints"; 61 path = ./sinks/sink-webhook; 62 volumes = { 63 "/data" = { }; 64 }; 65 ports = { 66 "8118/tcp" = { }; 67 }; 68 }; 69 sink-mongo = { 70 description = "Integration to populate a MongoDB collection with onchain data"; 71 path = ./sinks/sink-mongo; 72 volumes = { 73 "/data" = { }; 74 }; 75 ports = { 76 "8118/tcp" = { }; 77 }; 78 }; 79 sink-postgres = { 80 description = "Integration to populate a PostgreSQL table with onchain data"; 81 path = ./sinks/sink-postgres; 82 volumes = { 83 "/data" = { }; 84 }; 85 ports = { 86 "8118/tcp" = { }; 87 }; 88 }; 89 sink-parquet = { 90 description = "Integration to generate a Parquet dataset from onchain data"; 91 path = ./sinks/sink-parquet; 92 volumes = { 93 "/data" = { }; 94 }; 95 ports = { 96 "8118/tcp" = { }; 97 }; 98 }; 99 cli = { 100 description = "Apibara CLI tool"; 101 path = ./cli; 102 binaryName = "apibara"; 103 extraBinaries = [ 104 "sink-console" 105 "sink-webhook" 106 "sink-postgres" 107 "sink-mongo" 108 "sink-parquet" 109 ]; 110 volumes = { 111 "/data" = { }; 112 }; 113 ports = { 114 "8118/tcp" = { }; 115 }; 116 }; 117 }; 118 119 builtCrates = pkgs.callPackage ./nix/crates.nix { 120 inherit crane crates; 121 pre-commit-hooks = pre-commit-hooks.lib.${system}; 122 workspaceDir = ./.; 123 }; 124 125 ci = pkgs.callPackage ./nix/ci.nix { 126 tests = builtCrates.packages.tests; 127 binaries = builtCrates.binaries; 128 }; 129 in 130 { 131 inherit (ci) pipeline; 132 133 # format with `nix fmt` 134 formatter = pkgs.nixpkgs-fmt; 135 136 # checks. run with `nix flake check`. 137 checks = builtCrates.checks; 138 139 # development shells. start with `nix develop`. 140 devShells = (builtCrates.shell // ci.shell); 141 142 # all packages. 143 # show them with `nix flake show`. 144 # build with `nix build .#<name>`. 145 packages = (builtCrates.packages // { }); 146 } 147 ); 148 149 nixConfig = { 150 extra-substituters = [ "https://apibara-public.cachix.org" ]; 151 extra-trusted-public-keys = [ 152 "apibara-public.cachix.org-1:FLOMNlARo9CcxtcLDblZlt2xhsu/pa/EddEH1cM3Vog=" 153 ]; 154 }; 155 }