Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,7 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@82dee4ba654bd2146511f85f0d013af94670c4de # v1
with:
# Pinned to specific version since newer versions do not produce
# deterministic block hashes. Unpin once that's fixed upstream
version: v1.2.3
version: nightly

- name: Install pnpm
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4
Expand Down
19 changes: 9 additions & 10 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

263 changes: 144 additions & 119 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
foundry.url = "github:shazow/foundry.nix/5af12b6f2b708858ef3120041546ed6b038474a5";
foundry.url = "github:shazow/foundry.nix";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
Expand All @@ -11,160 +11,185 @@
flake-parts.url = "github:hercules-ci/flake-parts";
};

outputs = inputs@{ flake-parts, process-compose-flake, services-flake, nixpkgs, fenix, foundry, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [ process-compose-flake.flakeModule ];
outputs = inputs @ {
flake-parts,
process-compose-flake,
services-flake,
nixpkgs,
fenix,
foundry,
...
}:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [process-compose-flake.flakeModule];
systems = [
"x86_64-linux" # 64-bit Intel/AMD Linux
"aarch64-linux" # 64-bit ARM Linux
"x86_64-darwin" # 64-bit Intel macOS
"aarch64-darwin" # 64-bit ARM macOS
];

perSystem = { config, self', inputs', pkgs, system, ... }:
let
overlays = [
fenix.overlays.default
foundry.overlay
];
perSystem = {
config,
self',
inputs',
pkgs,
system,
...
}: let
overlays = [
fenix.overlays.default
foundry.overlay
];

pkgs = import nixpkgs {
inherit overlays system;
};
pkgs = import nixpkgs {
inherit overlays system;
};

toolchain = with fenix.packages.${system}; combine [
toolchain = with fenix.packages.${system};
combine [
(fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-+9FmLhAOezBZCOziO0Qct1NOrfpjNsXxc/8I0c7BdKE=";
})
stable.rust-src # This is needed for rust-analyzer to find stdlib symbols. Should use the same channel as the toolchain.
];
in {
devShells.default = pkgs.mkShell {
packages = (with pkgs; [
toolchain
foundry-bin
solc
protobuf
uv
cmake
corepack
nodejs
postgresql
just
cargo-nextest
]);
};
in {
formatter = pkgs.alejandra;
devShells.default = pkgs.mkShell {
packages = with pkgs; [
toolchain
foundry-bin
solc
protobuf
uv
cmake
corepack
nodejs
postgresql
just
cargo-nextest
];
};

process-compose = let
inherit (services-flake.lib) multiService;
ipfs = multiService ./nix/ipfs.nix;
anvil = multiService ./nix/anvil.nix;
process-compose = let
inherit (services-flake.lib) multiService;
ipfs = multiService ./nix/ipfs.nix;
anvil = multiService ./nix/anvil.nix;

# Helper function to create postgres configuration with graph-specific defaults
mkPostgresConfig = { name, port, user, password, database, dataDir }: {
enable = true;
inherit port dataDir;
initialScript = {
before = ''
CREATE USER \"${user}\" WITH PASSWORD '${password}' SUPERUSER;
'';
};
initialDatabases = [
{
inherit name;
schemas = [ (pkgs.writeText "init-${name}.sql" ''
# Helper function to create postgres configuration with graph-specific defaults
mkPostgresConfig = {
name,
port,
user,
password,
database,
dataDir,
}: {
enable = true;
inherit port dataDir;
initialScript = {
before = ''
CREATE USER \"${user}\" WITH PASSWORD '${password}' SUPERUSER;
'';
};
initialDatabases = [
{
inherit name;
schemas = [
(pkgs.writeText "init-${name}.sql" ''
CREATE EXTENSION IF NOT EXISTS pg_trgm;
CREATE EXTENSION IF NOT EXISTS btree_gist;
CREATE EXTENSION IF NOT EXISTS btree_gist;
CREATE EXTENSION IF NOT EXISTS postgres_fdw;
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
GRANT USAGE ON FOREIGN DATA WRAPPER postgres_fdw TO "${user}";
ALTER DATABASE "${database}" OWNER TO "${user}";
'') ];
}
];
settings = {
shared_preload_libraries = "pg_stat_statements";
log_statement = "all";
default_text_search_config = "pg_catalog.english";
max_connections = 500;
};
'')
];
}
];
settings = {
shared_preload_libraries = "pg_stat_statements";
log_statement = "all";
default_text_search_config = "pg_catalog.english";
max_connections = 500;
};
in {
# Unit tests configuration
unit = {
imports = [
services-flake.processComposeModules.default
ipfs
anvil
];
};
in {
# Unit tests configuration
unit = {
imports = [
services-flake.processComposeModules.default
ipfs
anvil
];

cli = {
environment.PC_DISABLE_TUI = true;
options = {
port = 8881;
};
cli = {
environment.PC_DISABLE_TUI = true;
options = {
port = 8881;
};
};

services.postgres."postgres-unit" = mkPostgresConfig {
name = "graph-test";
port = 5432;
dataDir = "./.data/unit/postgres";
user = "graph";
password = "graph";
database = "graph-test";
};
services.postgres."postgres-unit" = mkPostgresConfig {
name = "graph-test";
port = 5432;
dataDir = "./.data/unit/postgres";
user = "graph";
password = "graph";
database = "graph-test";
};

services.ipfs."ipfs-unit" = {
enable = true;
dataDir = "./.data/unit/ipfs";
port = 5001;
gateway = 8080;
};
services.ipfs."ipfs-unit" = {
enable = true;
dataDir = "./.data/unit/ipfs";
port = 5001;
gateway = 8080;
};
};

# Integration tests configuration
integration = {
imports = [
services-flake.processComposeModules.default
ipfs
anvil
];
# Integration tests configuration
integration = {
imports = [
services-flake.processComposeModules.default
ipfs
anvil
];

cli = {
environment.PC_DISABLE_TUI = true;
options = {
port = 8882;
};
cli = {
environment.PC_DISABLE_TUI = true;
options = {
port = 8882;
};
};

services.postgres."postgres-integration" = mkPostgresConfig {
name = "graph-node";
port = 3011;
dataDir = "./.data/integration/postgres";
user = "graph-node";
password = "let-me-in";
database = "graph-node";
};
services.postgres."postgres-integration" = mkPostgresConfig {
name = "graph-node";
port = 3011;
dataDir = "./.data/integration/postgres";
user = "graph-node";
password = "let-me-in";
database = "graph-node";
};

services.ipfs."ipfs-integration" = {
enable = true;
dataDir = "./.data/integration/ipfs";
port = 3001;
gateway = 3002;
};
services.ipfs."ipfs-integration" = {
enable = true;
dataDir = "./.data/integration/ipfs";
port = 3001;
gateway = 3002;
};

services.anvil."anvil-integration" = {
enable = true;
package = pkgs.foundry-bin;
port = 3021;
timestamp = 1743944919;
gasLimit = 100000000000;
baseFee = 1;
blockTime = 2;
};
services.anvil."anvil-integration" = {
enable = true;
package = pkgs.foundry-bin;
port = 3021;
timestamp = 1743944919;
gasLimit = 100000000000;
baseFee = 1;
blockTime = 2;
};
};
};
};
};
}
7 changes: 6 additions & 1 deletion nix/anvil.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{ pkgs, lib, name, config, ... }:
{
pkgs,
lib,
name,
config,
...
}: {
options = {
package = lib.mkOption {
type = lib.types.package;
Expand Down
Loading