Skip to content

Commit

Permalink
Don't require getopt to be installed by brew on macOS for Nix users
Browse files Browse the repository at this point in the history
Other changes:

* Add/Update copyright banners
* Add post-review comment for #5719
  • Loading branch information
zah committed Jan 13, 2024
1 parent b98f46c commit 05fb7ff
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
8 changes: 8 additions & 0 deletions beacon_chain/networking/eth2_network.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1964,6 +1964,14 @@ proc p2pProtocolBackendImpl*(p: P2PProtocol): Backend =
codecNameLit))

result.implementProtocolInit = proc (p: P2PProtocol): NimNode =
# TODO
# This current approach is not building on good foundations.
# Incrementing a global variable at compile-time fundamentally at odds with
# incremental compilation (because a recompile that doesn't revisit the whole
# program will mess up the counting and create duplicate indices).
# A better approach would build upon the `macrocache` module from the standard
# library, which is compatible with incremental compilation:
# https://nim-lang.org/docs/macrocache.html
var id {.global.}: int
let tmp = id
id += 1
Expand Down
9 changes: 9 additions & 0 deletions installer/nix/shell.nix
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# beacon_chain
# Copyright (c) 2023-2024 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.

{ pkgs ? import <nixpkgs> {}}:
let
mkdocs-packages = ps: with ps; [
Expand All @@ -16,6 +23,7 @@ mkShell {
git
git-lfs
gnumake
getopt

# For the local simulation
openssl # for generating the JWT file
Expand All @@ -34,6 +42,7 @@ mkShell {
# will erase `-march=native` because this introduces impurity in the build.
# For the purposes of compiling Nimbus, this behavior is not desired:
export NIX_ENFORCE_NO_NATIVE=0
export USE_SYSTEM_GETOPT=1
figlet "Welcome to Nimbus-eth2"
'';
Expand Down
4 changes: 2 additions & 2 deletions scripts/launch_local_testnet.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# Copyright (c) 2020-2023 Status Research & Development GmbH. Licensed under
# Copyright (c) 2020-2024 Status Research & Development GmbH. Licensed under
# either of:
# - Apache License, version 2.0
# - MIT license
Expand Down Expand Up @@ -34,7 +34,7 @@ PIDS_TO_WAIT=""
####################

GETOPT_BINARY="getopt"
if [[ "${OS}" == "macos" ]]; then
if [[ "${OS}" == "macos" && "$USE_SYSTEM_GETOPT" != "1" ]]; then
# Without the head -n1 constraint, it gets confused by multiple matches
GETOPT_BINARY=$(find /opt/homebrew/opt/gnu-getopt/bin/getopt /usr/local/opt/gnu-getopt/bin/getopt 2> /dev/null | head -n1 || true)
[[ -f "$GETOPT_BINARY" ]] || { echo "GNU getopt not installed. Please run 'brew install gnu-getopt'. Aborting."; exit 1; }
Expand Down

0 comments on commit 05fb7ff

Please sign in to comment.