forked from evmos/evmos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
68 lines (66 loc) · 2.42 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{ lib
, buildGoApplication
, buildPackages
, darwin
, fetchFromGitHub
, pkgs
, stdenv
, rev ? "dirty"
, rocksdb
, static ? stdenv.hostPlatform.isStatic
, dbBackend ? "goleveldb"
}:
let
version = if dbBackend == "rocksdb" then "latest-rocksdb" else "latest";
pname = "evmosd";
tags = [ "ledger" "netgo" ] ++ lib.optionals (dbBackend == "rocksdb") [ "rocksdb" "grocksdb_clean_link" ];
ldflags = lib.concatStringsSep "\n" ([
"-X github.com/cosmos/cosmos-sdk/version.Name=evmos"
"-X github.com/cosmos/cosmos-sdk/version.AppName=${pname}"
"-X github.com/cosmos/cosmos-sdk/version.Version=${version}"
"-X github.com/cosmos/cosmos-sdk/version.BuildTags=${lib.concatStringsSep "," tags}"
"-X github.com/cosmos/cosmos-sdk/version.Commit=${rev}"
"-X github.com/cosmos/cosmos-sdk/types.DBBackend=${dbBackend}"
]);
buildInputs = lib.optionals (dbBackend == "rocksdb") [ rocksdb ] ++ lib.optionals stdenv.isDarwin ([ darwin.apple_sdk.frameworks.CoreServices ]);
# use a newer version of nixpkgs to get go_1_22
# We're not updating this on the whole setup because breaks other stuff
# but we can import the needed packages from the newer version
nixpkgsUrl = "https://github.com/NixOS/nixpkgs/archive/master.tar.gz";
nixpkgs = import (fetchTarball nixpkgsUrl) {};
# the go_1_22 nixpkgs is v1.22.1
# but we need the v1.22.8.
# This overrides the pkg to use
# the v1.22.8 version
go_1_22 = nixpkgs.pkgs.go_1_22.overrideAttrs {
pname = "golang";
version = "go1.22.8";
src = fetchFromGitHub {
owner = "golang";
repo = "go";
rev = "aeccd613c896d39f582036aa52917c85ecf0b0c0";
sha256 = "sha256-N3uG+FLMgThIAr1aDJSq+X+VKCz8dw6az35um3Mr3D0=";
};
};
in
buildGoApplication rec {
inherit pname version buildInputs tags ldflags;
go = go_1_22;
src = ./.;
modules = ./gomod2nix.toml;
doCheck = false;
pwd = src; # needed to support replace
subPackages = [ "cmd/evmosd" ];
CGO_ENABLED = "1";
postFixup = if dbBackend == "rocksdb" then
''
# Rename the binary from evmosd to evmosd-rocksdb
mv $out/bin/evmosd $out/bin/evmosd-rocksdb
'' else '''';
meta = with lib; {
description = "Evmos is a scalable and interoperable blockchain, built on Proof-of-Stake with fast-finality using the Cosmos SDK which runs on top of CometBFT Core consensus engine.";
homepage = "https://github.com/evmos/evmos";
license = licenses.asl20;
mainProgram = "evmosd";
};
}