Skip to content

Commit 644965b

Browse files
committed
Add chainlink-ton-extras pkg
1 parent a3868e2 commit 644965b

File tree

5 files changed

+75
-1
lines changed

5 files changed

+75
-1
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
pkgs,
3+
rev,
4+
}: let
5+
lock = pkgs.callPackage ./lock.nix {inherit pkgs;};
6+
package-info = builtins.fromJSON (builtins.readFile ../../pkg/package.json);
7+
8+
# Fetch karalabe/hid for HIDAPI C sources and headers
9+
karalabe-hid = pkgs.fetchFromGitHub {
10+
owner = "karalabe";
11+
repo = "hid";
12+
rev = "821c38d2678e741180ec60b2512b408fa8bab99e";
13+
sha256 = "sha256-z3KSqKrIoy6WR2HUPjKJEm93NvuN0m9Edcq5BtGO5yA=";
14+
};
15+
in
16+
pkgs.buildGo124Module rec {
17+
inherit (package-info) version;
18+
pname = "chainlink-ton-extras";
19+
20+
# source at the root of the module
21+
src = ./../..;
22+
subPackages = ["cmd/explorer"];
23+
24+
nativeBuildInputs = [pkgs.gcc pkgs.pkg-config];
25+
buildInputs = [pkgs.libusb1]; # for Linux builds
26+
# Export CGO_CFLAGS so the C compiler can find vendored hidapi sources
27+
preBuild = ''
28+
export CGO_ENABLED=1
29+
30+
# Ensure the C compiler can find hidapi headers:
31+
# point directly at the hidapi/hidapi subdir which contains hidapi.h
32+
export CGO_CFLAGS="-I${karalabe-hid}/hidapi/hidapi -I${karalabe-hid} -I${pkgs.libusb1}/include"
33+
34+
export CGO_LDFLAGS="-L${pkgs.libusb1}/lib -lusb-1.0"
35+
'';
36+
37+
ldflags = [
38+
"-X main.Version=${package-info.version}"
39+
"-X main.GitCommit=${rev}"
40+
];
41+
42+
# pin the vendor hash (update using 'pkgs.lib.fakeHash')
43+
vendorHash = lock.chainlink-ton-extras;
44+
45+
# postInstall script to write version and rev to share folder
46+
postInstall = ''
47+
mkdir $out/share
48+
echo ${package-info.version} > $out/share/.version
49+
echo ${rev} > $out/share/.rev
50+
'';
51+
52+
meta = with pkgs.lib; {
53+
inherit (package-info) description;
54+
license = licenses.mit;
55+
changelog = "https://github.com/smartcontractkit/chainlink-ton/releases/tag/v${version}";
56+
};
57+
}

cmd/chainlink-ton-extras/lock.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Notice: `pkgs.lib.fakeHash` can be used as a placeholder,
2+
# but `nix-lock-tidy` will only replace actual hashes.
3+
{pkgs}: {
4+
chainlink-ton-extras = "sha256-jtaFXUcjqQgoJLpOibc2RcL+2JmdZ/c0HX8DNjud9FY=";
5+
}

cmd/chainlink-ton/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ in
1111

1212
# source at the root of the module
1313
src = ./../..;
14-
subPackages = ["cmd/chainlink-ton"];
14+
subPackages = ["cmd/chainlink-ton" "cmd/explorer"];
1515

1616
ldflags = [
1717
"-X main.Version=${package-info.version}"

docs/.misc/dev-guides/explorer/usage.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ Three ways to run:
1010
2. **Hash + Address**: `./explorer <tx-hash> <address>`
1111
3. **Hash only**: `./explorer <tx-hash>` (testnet/mainnet only)
1212

13+
## Run with Nix
14+
15+
The `explorer` binary is packaged with `chainlink-ton-extras` pkg bundle.
16+
17+
We can start a dev shell including specific pkg contents and execute a bash cmd:
18+
19+
```bash
20+
nix shell .#chainlink-ton-extras -c explorer https://testnet.tonscan.org/tx/1d2080630f8a2dab1ba73c309fc5fe81268f3c2b116a91fd7c5e3018f7fce676
21+
```
22+
1323
## Build
1424

1525
```bash

flake.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
# Resolve root module
3131
chainlink-ton = pkgs.callPackage ./cmd/chainlink-ton commonArgs;
32+
chainlink-ton-extras = pkgs.callPackage ./cmd/chainlink-ton-extras commonArgs;
3233
# Resolve sub-modules
3334
contracts = pkgs.callPackage ./contracts commonArgs;
3435
integration-tests = pkgs.callPackage ./integration-tests {
@@ -71,6 +72,7 @@
7172
{
7273
# Chainlink core node plugin (default + alias)
7374
inherit chainlink-ton;
75+
inherit chainlink-ton-extras;
7476
default = chainlink-ton;
7577
# Dependency analyzer
7678
dependency-analyzer = dependency-analyzer.packages.default;

0 commit comments

Comments
 (0)