-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First pass at a dev env, which pulls in the usual Rust deps, as well as go, which is required to build `penumbra-indexer`. The go-linking functionality isn't well supported yet: within the devShell, `cargo build` works, but `nix build` does not. CI cache timing info: * First run of cargo-check: 3m13s * First run of cargo-fmt: 1m57s
- Loading branch information
Showing
8 changed files
with
273 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
use flake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Rust CI | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
check: | ||
name: cargo check | ||
runs-on: buildjet-8vcpu-ubuntu-2204 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
lfs: true | ||
|
||
- name: install nix | ||
uses: nixbuild/nix-quick-install-action@v28 | ||
|
||
- name: setup nix cache | ||
uses: nix-community/cache-nix-action@v5 | ||
with: | ||
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix') }} | ||
restore-prefixes-first-match: nix-${{ runner.os }}- | ||
backend: buildjet | ||
|
||
- name: Load rust cache | ||
uses: astriaorg/buildjet-rust-cache@v2.5.1 | ||
|
||
- name: Run cargo check, failing on warnings | ||
run: >- | ||
nix develop --command | ||
just check | ||
fmt: | ||
name: cargo fmt | ||
runs-on: buildjet-8vcpu-ubuntu-2204 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: install nix | ||
uses: nixbuild/nix-quick-install-action@v28 | ||
|
||
- name: setup nix cache | ||
uses: nix-community/cache-nix-action@v5 | ||
with: | ||
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix') }} | ||
restore-prefixes-first-match: nix-${{ runner.os }}- | ||
backend: buildjet | ||
|
||
- name: Load rust cache | ||
uses: astriaorg/buildjet-rust-cache@v2.5.1 | ||
|
||
- name: Run cargo fmt, failing on reformatting | ||
run: >- | ||
nix develop --command | ||
just fmt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,7 @@ | |
|
||
# Rust / Cargo | ||
/target | ||
|
||
# Ignore .envrc; copy from .envrc.example to get started | ||
.envrc | ||
.direnv/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
{ | ||
description = "A nix development shell and build environment for penumbra-reindexer"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
fenix = { | ||
url = "github:nix-community/fenix"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
inputs.rust-analyzer-src.follows = ""; | ||
}; | ||
crane = { | ||
url = "github:ipetkov/crane"; | ||
inputs = { nixpkgs.follows = "nixpkgs"; }; | ||
}; | ||
}; | ||
|
||
outputs = { self, nixpkgs, flake-utils, crane, ... }: | ||
flake-utils.lib.eachDefaultSystem | ||
(system: | ||
let | ||
pkgs = import nixpkgs { inherit system; }; | ||
# Permit version declarations, but default to unset, | ||
# meaning the local working copy will be used. | ||
penumbraReindexerRelease = null; | ||
|
||
# Set up for Rust builds. | ||
craneLib = crane.mkLib pkgs; | ||
|
||
# Important environment variables so that the build can find the necessary libraries | ||
LIBCLANG_PATH="${pkgs.libclang.lib}/lib"; | ||
ROCKSDB_LIB_DIR="${pkgs.rocksdb.out}/lib"; | ||
in with pkgs; with pkgs.lib; let | ||
# All the Penumbra binaries | ||
penumbraReindexer = (craneLib.buildPackage { | ||
pname = "penumbra-reindexer"; | ||
# what | ||
src = cleanSourceWith { | ||
src = if penumbraReindexerRelease == null then craneLib.path ./. else fetchFromGitHub { | ||
owner = "penumbra-zone"; | ||
repo = "reindexer"; | ||
rev = "v${penumbraReindexerRelease.version}"; | ||
sha256 = "${penumbraReindexerRelease.sha256}"; | ||
}; | ||
filter = path: type: | ||
# Retain non-rust files as build inputs: | ||
# * sql: database schema files for indexing | ||
# * go, mod, sum: golang files for linking in cometbft | ||
(builtins.match ".*\.(sql|go|mod|sum)$" path != null) || | ||
# ... as well as all the normal cargo source files: | ||
(craneLib.filterCargoSources path type); | ||
}; | ||
nativeBuildInputs = [ pkg-config ]; | ||
buildInputs = if stdenv.hostPlatform.isDarwin then | ||
with pkgs.darwin.apple_sdk.frameworks; [clang openssl rocksdb SystemConfiguration CoreServices go] | ||
else | ||
[clang openssl rocksdb go]; | ||
|
||
inherit system LIBCLANG_PATH ROCKSDB_LIB_DIR; | ||
cargoExtraArgs = "-p penumbra-reindexer"; | ||
meta = { | ||
description = "A reindexing tool for Penumbra ABCI event data"; | ||
homepage = "https://penumbra.zone"; | ||
license = [ licenses.mit licenses.asl20 ]; | ||
}; | ||
}).overrideAttrs (_: { doCheck = false; }); # Disable tests to improve build times | ||
|
||
in rec { | ||
packages = { inherit penumbraReindexer ; }; | ||
apps = { | ||
penumbra-reindexer.type = "app"; | ||
penumbra-reindexer.program = "${penumbraReindexer}/bin/penumbra-reindexer"; | ||
}; | ||
defaultPackage = symlinkJoin { | ||
name = "penumbra-reindexer"; | ||
paths = [ penumbraReindexer ]; | ||
}; | ||
devShells.default = craneLib.devShell { | ||
inherit LIBCLANG_PATH ROCKSDB_LIB_DIR; | ||
inputsFrom = [ penumbraReindexer ]; | ||
packages = [ | ||
cargo-nextest | ||
cargo-watch | ||
go | ||
just | ||
nix-prefetch-scripts | ||
sqlfluff | ||
]; | ||
shellHook = '' | ||
export LIBCLANG_PATH=${LIBCLANG_PATH} | ||
export ROCKSDB_LIB_DIR=${ROCKSDB_LIB_DIR} | ||
''; | ||
}; | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Run cargo check, failing on warnings | ||
check: | ||
# The `-D warnings` option causes an error on warnings. | ||
RUSTFLAGS="-D warnings" \ | ||
cargo check --release --all-targets | ||
|
||
# Run cargo fmt, failing on warnings | ||
fmt: | ||
cargo fmt --all -- --check |