forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 3
/
flake.nix
98 lines (90 loc) · 3.4 KB
/
flake.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
{
description = "A Nix-flake-based Go 1.17 development environment";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.flake-compat.url = "github:edolstra/flake-compat";
inputs.flake-compat.flake = false;
inputs.solc-bin.url = "github:EspressoSystems/nix-solc-bin";
outputs = { flake-utils, nixpkgs, solc-bin, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
goVersion = 21; # Change this to update the whole stack
overlays = [
# solc-bin.overlays.default
(final: prev: {
go = prev."go_1_${toString goVersion}";
# Overlaying nodejs here to ensure nodePackages use the desired
# version of nodejs.
nodejs = prev.nodejs_20;
pnpm = prev.nodePackages.pnpm;
yarn = prev.nodePackages.yarn;
})
];
pkgs = import nixpkgs {
inherit overlays system;
};
# nixWithFlakes allows pre v2.4 nix installations to use
# flake commands (like `nix flake update`)
nixWithFlakes = pkgs.writeShellScriptBin "nix" ''
exec ${pkgs.nixFlakes}/bin/nix --experimental-features "nix-command flakes" "$@"
'';
foundry = pkgs.callPackage ./foundry { solc-bin-src = solc-bin; };
# Overriding version for go-packages is more complicated than it should be.
# To use a different go ethereum version the `version`, `hash` and `vendorHash` need to be updated.
#
# 1. Run the following command for `hash` :
#
# nix-shell -p nix-prefetch-github --run "nix-prefetch-github ethereum go-ethereum --nix --rev v1.13.4"
#
# 2. Replace the `vendorHash` with an empty string and run `nix develop`.
# 3. Find the `vendorHash` in the output in the line that starts with `got:` and copy it into this file.
go-ethereum =
let
version = "1.13.4";
src = pkgs.fetchFromGitHub {
owner = "ethereum";
repo = "go-ethereum";
rev = "v${version}";
hash = "sha256-RQlWWHoij3gtFwjJeEGsmd5YJNTGX0I84nOAQyWBx/M=";
};
vendorHash = "sha256-YmUgKO3JtVOE/YACqL/QBiyR1jT/jPCH+Gb0xYwkJEc=";
in
pkgs.go-ethereum.override {
buildGoModule = args: pkgs.buildGoModule (args // {
inherit version src vendorHash;
});
};
in
{
devShells.default = pkgs.mkShell {
COMPOSE_DOCKER_CLI_BUILD = 1;
DOCKER_BUILDKIT = 1;
packages = with pkgs; [
nixWithFlakes
go
# goimports, godoc, etc.
gotools
# https://github.com/golangci/golangci-lint
golangci-lint
# Node
nodejs
pnpm
yarn # `pnpm build` fails without this
# Foundry, and tools like the anvil dev node
foundry
# solc
# Docker
docker-compose # provides the `docker-compose` command
# Python
(python3.withPackages (ps: with ps; [ ]))
jq
# geth node
go-ethereum
] ++ lib.optionals stdenv.isDarwin [
darwin.libobjc
darwin.IOKit
darwin.apple_sdk.frameworks.CoreFoundation
];
};
});
}