|
1 | 1 | {
|
2 | 2 | inputs = {
|
3 | 3 | nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
4 |
| - foundry.url = "github:shazow/foundry.nix/5af12b6f2b708858ef3120041546ed6b038474a5"; |
| 4 | + foundry.url = "github:shazow/foundry.nix"; |
5 | 5 | fenix = {
|
6 | 6 | url = "github:nix-community/fenix";
|
7 | 7 | inputs.nixpkgs.follows = "nixpkgs";
|
|
11 | 11 | flake-parts.url = "github:hercules-ci/flake-parts";
|
12 | 12 | };
|
13 | 13 |
|
14 |
| - outputs = inputs@{ flake-parts, process-compose-flake, services-flake, nixpkgs, fenix, foundry, ... }: |
15 |
| - flake-parts.lib.mkFlake { inherit inputs; } { |
16 |
| - imports = [ process-compose-flake.flakeModule ]; |
| 14 | + outputs = inputs @ { |
| 15 | + flake-parts, |
| 16 | + process-compose-flake, |
| 17 | + services-flake, |
| 18 | + nixpkgs, |
| 19 | + fenix, |
| 20 | + foundry, |
| 21 | + ... |
| 22 | + }: |
| 23 | + flake-parts.lib.mkFlake {inherit inputs;} { |
| 24 | + imports = [process-compose-flake.flakeModule]; |
17 | 25 | systems = [
|
18 | 26 | "x86_64-linux" # 64-bit Intel/AMD Linux
|
19 | 27 | "aarch64-linux" # 64-bit ARM Linux
|
20 | 28 | "x86_64-darwin" # 64-bit Intel macOS
|
21 | 29 | "aarch64-darwin" # 64-bit ARM macOS
|
22 | 30 | ];
|
23 | 31 |
|
24 |
| - perSystem = { config, self', inputs', pkgs, system, ... }: |
25 |
| - let |
26 |
| - overlays = [ |
27 |
| - fenix.overlays.default |
28 |
| - foundry.overlay |
29 |
| - ]; |
| 32 | + perSystem = { |
| 33 | + config, |
| 34 | + self', |
| 35 | + inputs', |
| 36 | + pkgs, |
| 37 | + system, |
| 38 | + ... |
| 39 | + }: let |
| 40 | + overlays = [ |
| 41 | + fenix.overlays.default |
| 42 | + foundry.overlay |
| 43 | + ]; |
30 | 44 |
|
31 |
| - pkgs = import nixpkgs { |
32 |
| - inherit overlays system; |
33 |
| - }; |
| 45 | + pkgs = import nixpkgs { |
| 46 | + inherit overlays system; |
| 47 | + }; |
34 | 48 |
|
35 |
| - toolchain = with fenix.packages.${system}; combine [ |
| 49 | + toolchain = with fenix.packages.${system}; |
| 50 | + combine [ |
36 | 51 | (fromToolchainFile {
|
37 | 52 | file = ./rust-toolchain.toml;
|
38 | 53 | sha256 = "sha256-+9FmLhAOezBZCOziO0Qct1NOrfpjNsXxc/8I0c7BdKE=";
|
39 | 54 | })
|
40 | 55 | stable.rust-src # This is needed for rust-analyzer to find stdlib symbols. Should use the same channel as the toolchain.
|
41 | 56 | ];
|
42 |
| - in { |
43 |
| - devShells.default = pkgs.mkShell { |
44 |
| - packages = (with pkgs; [ |
45 |
| - toolchain |
46 |
| - foundry-bin |
47 |
| - solc |
48 |
| - protobuf |
49 |
| - uv |
50 |
| - cmake |
51 |
| - corepack |
52 |
| - nodejs |
53 |
| - postgresql |
54 |
| - just |
55 |
| - cargo-nextest |
56 |
| - ]); |
57 |
| - }; |
| 57 | + in { |
| 58 | + formatter = pkgs.alejandra; |
| 59 | + devShells.default = pkgs.mkShell { |
| 60 | + packages = with pkgs; [ |
| 61 | + toolchain |
| 62 | + foundry-bin |
| 63 | + solc |
| 64 | + protobuf |
| 65 | + uv |
| 66 | + cmake |
| 67 | + corepack |
| 68 | + nodejs |
| 69 | + postgresql |
| 70 | + just |
| 71 | + cargo-nextest |
| 72 | + ]; |
| 73 | + }; |
58 | 74 |
|
59 |
| - process-compose = let |
60 |
| - inherit (services-flake.lib) multiService; |
61 |
| - ipfs = multiService ./nix/ipfs.nix; |
62 |
| - anvil = multiService ./nix/anvil.nix; |
| 75 | + process-compose = let |
| 76 | + inherit (services-flake.lib) multiService; |
| 77 | + ipfs = multiService ./nix/ipfs.nix; |
| 78 | + anvil = multiService ./nix/anvil.nix; |
63 | 79 |
|
64 |
| - # Helper function to create postgres configuration with graph-specific defaults |
65 |
| - mkPostgresConfig = { name, port, user, password, database, dataDir }: { |
66 |
| - enable = true; |
67 |
| - inherit port dataDir; |
68 |
| - initialScript = { |
69 |
| - before = '' |
70 |
| - CREATE USER \"${user}\" WITH PASSWORD '${password}' SUPERUSER; |
71 |
| - ''; |
72 |
| - }; |
73 |
| - initialDatabases = [ |
74 |
| - { |
75 |
| - inherit name; |
76 |
| - schemas = [ (pkgs.writeText "init-${name}.sql" '' |
| 80 | + # Helper function to create postgres configuration with graph-specific defaults |
| 81 | + mkPostgresConfig = { |
| 82 | + name, |
| 83 | + port, |
| 84 | + user, |
| 85 | + password, |
| 86 | + database, |
| 87 | + dataDir, |
| 88 | + }: { |
| 89 | + enable = true; |
| 90 | + inherit port dataDir; |
| 91 | + initialScript = { |
| 92 | + before = '' |
| 93 | + CREATE USER \"${user}\" WITH PASSWORD '${password}' SUPERUSER; |
| 94 | + ''; |
| 95 | + }; |
| 96 | + initialDatabases = [ |
| 97 | + { |
| 98 | + inherit name; |
| 99 | + schemas = [ |
| 100 | + (pkgs.writeText "init-${name}.sql" '' |
77 | 101 | CREATE EXTENSION IF NOT EXISTS pg_trgm;
|
78 |
| - CREATE EXTENSION IF NOT EXISTS btree_gist; |
| 102 | + CREATE EXTENSION IF NOT EXISTS btree_gist; |
79 | 103 | CREATE EXTENSION IF NOT EXISTS postgres_fdw;
|
80 | 104 | CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
|
81 | 105 | GRANT USAGE ON FOREIGN DATA WRAPPER postgres_fdw TO "${user}";
|
82 | 106 | ALTER DATABASE "${database}" OWNER TO "${user}";
|
83 |
| - '') ]; |
84 |
| - } |
85 |
| - ]; |
86 |
| - settings = { |
87 |
| - shared_preload_libraries = "pg_stat_statements"; |
88 |
| - log_statement = "all"; |
89 |
| - default_text_search_config = "pg_catalog.english"; |
90 |
| - max_connections = 500; |
91 |
| - }; |
| 107 | + '') |
| 108 | + ]; |
| 109 | + } |
| 110 | + ]; |
| 111 | + settings = { |
| 112 | + shared_preload_libraries = "pg_stat_statements"; |
| 113 | + log_statement = "all"; |
| 114 | + default_text_search_config = "pg_catalog.english"; |
| 115 | + max_connections = 500; |
92 | 116 | };
|
93 |
| - in { |
94 |
| - # Unit tests configuration |
95 |
| - unit = { |
96 |
| - imports = [ |
97 |
| - services-flake.processComposeModules.default |
98 |
| - ipfs |
99 |
| - anvil |
100 |
| - ]; |
| 117 | + }; |
| 118 | + in { |
| 119 | + # Unit tests configuration |
| 120 | + unit = { |
| 121 | + imports = [ |
| 122 | + services-flake.processComposeModules.default |
| 123 | + ipfs |
| 124 | + anvil |
| 125 | + ]; |
101 | 126 |
|
102 |
| - cli = { |
103 |
| - environment.PC_DISABLE_TUI = true; |
104 |
| - options = { |
105 |
| - port = 8881; |
106 |
| - }; |
| 127 | + cli = { |
| 128 | + environment.PC_DISABLE_TUI = true; |
| 129 | + options = { |
| 130 | + port = 8881; |
107 | 131 | };
|
| 132 | + }; |
108 | 133 |
|
109 |
| - services.postgres."postgres-unit" = mkPostgresConfig { |
110 |
| - name = "graph-test"; |
111 |
| - port = 5432; |
112 |
| - dataDir = "./.data/unit/postgres"; |
113 |
| - user = "graph"; |
114 |
| - password = "graph"; |
115 |
| - database = "graph-test"; |
116 |
| - }; |
| 134 | + services.postgres."postgres-unit" = mkPostgresConfig { |
| 135 | + name = "graph-test"; |
| 136 | + port = 5432; |
| 137 | + dataDir = "./.data/unit/postgres"; |
| 138 | + user = "graph"; |
| 139 | + password = "graph"; |
| 140 | + database = "graph-test"; |
| 141 | + }; |
117 | 142 |
|
118 |
| - services.ipfs."ipfs-unit" = { |
119 |
| - enable = true; |
120 |
| - dataDir = "./.data/unit/ipfs"; |
121 |
| - port = 5001; |
122 |
| - gateway = 8080; |
123 |
| - }; |
| 143 | + services.ipfs."ipfs-unit" = { |
| 144 | + enable = true; |
| 145 | + dataDir = "./.data/unit/ipfs"; |
| 146 | + port = 5001; |
| 147 | + gateway = 8080; |
124 | 148 | };
|
| 149 | + }; |
125 | 150 |
|
126 |
| - # Integration tests configuration |
127 |
| - integration = { |
128 |
| - imports = [ |
129 |
| - services-flake.processComposeModules.default |
130 |
| - ipfs |
131 |
| - anvil |
132 |
| - ]; |
| 151 | + # Integration tests configuration |
| 152 | + integration = { |
| 153 | + imports = [ |
| 154 | + services-flake.processComposeModules.default |
| 155 | + ipfs |
| 156 | + anvil |
| 157 | + ]; |
133 | 158 |
|
134 |
| - cli = { |
135 |
| - environment.PC_DISABLE_TUI = true; |
136 |
| - options = { |
137 |
| - port = 8882; |
138 |
| - }; |
| 159 | + cli = { |
| 160 | + environment.PC_DISABLE_TUI = true; |
| 161 | + options = { |
| 162 | + port = 8882; |
139 | 163 | };
|
| 164 | + }; |
140 | 165 |
|
141 |
| - services.postgres."postgres-integration" = mkPostgresConfig { |
142 |
| - name = "graph-node"; |
143 |
| - port = 3011; |
144 |
| - dataDir = "./.data/integration/postgres"; |
145 |
| - user = "graph-node"; |
146 |
| - password = "let-me-in"; |
147 |
| - database = "graph-node"; |
148 |
| - }; |
| 166 | + services.postgres."postgres-integration" = mkPostgresConfig { |
| 167 | + name = "graph-node"; |
| 168 | + port = 3011; |
| 169 | + dataDir = "./.data/integration/postgres"; |
| 170 | + user = "graph-node"; |
| 171 | + password = "let-me-in"; |
| 172 | + database = "graph-node"; |
| 173 | + }; |
149 | 174 |
|
150 |
| - services.ipfs."ipfs-integration" = { |
151 |
| - enable = true; |
152 |
| - dataDir = "./.data/integration/ipfs"; |
153 |
| - port = 3001; |
154 |
| - gateway = 3002; |
155 |
| - }; |
| 175 | + services.ipfs."ipfs-integration" = { |
| 176 | + enable = true; |
| 177 | + dataDir = "./.data/integration/ipfs"; |
| 178 | + port = 3001; |
| 179 | + gateway = 3002; |
| 180 | + }; |
156 | 181 |
|
157 |
| - services.anvil."anvil-integration" = { |
158 |
| - enable = true; |
159 |
| - package = pkgs.foundry-bin; |
160 |
| - port = 3021; |
161 |
| - timestamp = 1743944919; |
162 |
| - gasLimit = 100000000000; |
163 |
| - baseFee = 1; |
164 |
| - blockTime = 2; |
165 |
| - }; |
| 182 | + services.anvil."anvil-integration" = { |
| 183 | + enable = true; |
| 184 | + package = pkgs.foundry-bin; |
| 185 | + port = 3021; |
| 186 | + timestamp = 1743944919; |
| 187 | + gasLimit = 100000000000; |
| 188 | + baseFee = 1; |
| 189 | + blockTime = 2; |
166 | 190 | };
|
167 | 191 | };
|
168 | 192 | };
|
| 193 | + }; |
169 | 194 | };
|
170 | 195 | }
|
0 commit comments