Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: nix development environment for subnet #114

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

andyjsbell
Copy link
Collaborator

Pull Request

Description

  • This contribution represents a trivial change (skip the following sections).
  • This contribution represents a CI/CD change that needs to be tested e2e (skip the following sections; justify below).

Addition of a Nix flake

Motivation and Context

Added Nix flake to allow us to create reproducible development environments for subnet.

Changes Made

The changes consist of a flake.nix and a supporting expression avalanche-network-runner.nix which builds an environment to test and simulate subnet

Testing

Using nix develop I was able to check that avalanchego and avalanche-network-runner are in the path

Screenshots (if applicable)

Related Issues

Checklist

  • I have read and followed the project's contributing guidelines.
  • I have tested the changes thoroughly.
  • My code follows the style and formatting guidelines of the project.
  • I have updated the relevant documentation, if applicable.
  • I have added tests, if appropriate.
  • The code builds without any errors or warnings.
  • All existing tests pass successfully.

Additional Notes

@andyjsbell andyjsbell added the enhancement New feature or request label Feb 20, 2024
@0xmovses
Copy link
Collaborator

0xmovses commented Feb 21, 2024

Seems like the NIX_LDFLAGS needs to be set prior to line 83?

When I run nix develop inside m1 on linux ubuntu I get this error:

error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:9:12:
            8|
            9|   strict = derivationStrict drvAttrs;
             |            ^
           10|

       … while evaluating derivation 'nix-shell'
         whose name attribute is located at /nix/store/bg5fbkfa5x53clcjf4p5p92k1l3w8x38-source/pkgs/stdenv/generic/make-derivation.nix:353:7

       … while evaluating attribute 'NIX_LDFLAGS' of derivation 'nix-shell'
         at /nix/store/djk9jaqbgv7bf8h7gsxp8l750z9c251l-source/m1/flake.nix:83:13:
           82|           devShells.default = mkShell {
           83|             NIX_LDFLAGS="-l${stdenv.cc.libcxx.cxxabi.libName}";
             |             ^
           84|             buildInputs = developmentDependencies;

       error: expected a set but found null: null

@andyjsbell
Copy link
Collaborator Author

I feared that may happen as I was unable to easily run this on a x86_64 system. I will now and get back with an update.

@0xmovses
Copy link
Collaborator

Old error gone, new error:

error: builder for '/nix/store/l98v8asrh7pgkqhqas11rd0zfxssn5xp-source.drv' failed with exit code 1;
       last 8 log lines:
       >
       > trying https://github.com/ava-labs/avalanche-network-runner/archive/v1.75.tar.gz
       >   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
       >                                  Dload  Upload   Total   Spent    Left  Speed
       >   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
       >   0    14    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
       > curl: (22) The requested URL returned error: 404
       > error: cannot download source from any mirror
       For full logs, run 'nix-store -l /nix/store/l98v8asrh7pgkqhqas11rd0zfxssn5xp-source.drv'.
error: 1 dependencies of derivation '/nix/store/1rs16mxnpg04g3ah62rd93kmk2wr4fld-avalanche-network-runner-1.75.drv' failed to build
error: 1 dependencies of derivation '/nix/store/ji1i49c3mjsj100j4adj8f59mrmwpsdz-nix-shell-env.drv' failed to build

The full log outputs the same thing.

@0xmovses
Copy link
Collaborator

avalanchego errors now

⋊> ~/m/M/m1 on andy/nixme ◦ nix develop                                                           12:23:08
warning: Ignoring setting 'auto-allocate-uids' because experimental feature 'auto-allocate-uids' is not enabled
warning: Ignoring setting 'impure-env' because experimental feature 'configurable-impure-env' is not enabled
error: builder for '/nix/store/gx0fg6ll6rx5bywcmz6scaimwn95v8jg-avalanche-network-runner-1.7.5.drv' failed with exit code 1;
       last 25 log lines:
       > local/blockchain.go:21:2: reading github.com/ava-labs/avalanchego/go.mod at revision v1.11.0-rc.1: git ls-remote -q origin in /build/go/pkg/mod/cache/vcs/34ba33bedc5b436c30b0c20a8888c4cbb375ec094c9e23140903fc9808d67c63: exit status 128:
       >   fatal: unable to access 'https://github.com/ava-labs/avalanchego/': Could not resolve host: github.com
       > local/blockchain.go:17:2: reading github.com/ava-labs/avalanchego/go.mod at revision v1.11.0-rc.1: git ls-remote -q origin in /build/go/pkg/mod/cache/vcs/34ba33bedc5b436c30b0c20a8888c4cbb375ec094c9e23140903fc9808d67c63: exit status 128:
       >   fatal: unable to access 'https://github.com/ava-labs/avalanchego/': Could not resolve host: github.com
       > local/blockchain.go:37:2: reading github.com/ava-labs/avalanchego/go.mod at revision v1.11.0-rc.1: git ls-remote -q origin in /build/go/pkg/mod/cache/vcs/34ba33bedc5b436c30b0c20a8888c4cbb375ec094c9e23140903fc9808d67c63: exit status 128:
       >   fatal: unable to access 'https://github.com/ava-labs/avalanchego/': Could not resolve host: github.com
       > local/blockchain.go:38:2: reading github.com/ava-labs/avalanchego/go.mod at revision v1.11.0-rc.1: git ls-remote -q origin in /build/go/pkg/mod/cache/vcs/34ba33bedc5b436c30b0c20a8888c4cbb375ec094c9e23140903fc9808d67c63: exit status 128:
       >   fatal: unable to access 'https://github.com/ava-labs/avalanchego/': Could not resolve host: github.com
       > local/blockchain.go:39:2: reading github.com/ava-labs/avalanchego/go.mod at revision v1.11.0-rc.1: git ls-remote -q origin in /build/go/pkg/mod/cache/vcs/34ba33bedc5b436c30b0c20a8888c4cbb375ec094c9e23140903fc9808d67c63: exit status 128:
       >   fatal: unable to access 'https://github.com/ava-labs/avalanchego/': Could not resolve host: github.com
       > local/blockchain.go:22:2: reading github.com/ava-labs/avalanchego/go.mod at revision v1.11.0-rc.1: git ls-remote -q origin in /build/go/pkg/mod/cache/vcs/34ba33bedc5b436c30b0c20a8888c4cbb375ec094c9e23140903fc9808d67c63: exit status 128:
       >   fatal: unable to access 'https://github.com/ava-labs/avalanchego/': Could not resolve host: github.com
       > local/blockchain.go:40:2: reading github.com/ava-labs/avalanchego/go.mod at revision v1.11.0-rc.1: git ls-remote -q origin in /build/go/pkg/mod/cache/vcs/34ba33bedc5b436c30b0c20a8888c4cbb375ec094c9e23140903fc9808d67c63: exit status 128:
       >   fatal: unable to access 'https://github.com/ava-labs/avalanchego/': Could not resolve host: github.com
       > local/blockchain.go:41:2: reading github.com/ava-labs/avalanchego/go.mod at revision v1.11.0-rc.1: git ls-remote -q origin in /build/go/pkg/mod/cache/vcs/34ba33bedc5b436c30b0c20a8888c4cbb375ec094c9e23140903fc9808d67c63: exit status 128:
       >   fatal: unable to access 'https://github.com/ava-labs/avalanchego/': Could not resolve host: github.com
       > local/snapshot.go:20:2: reading github.com/otiai10/copy/go.mod at revision v1.11.0: git ls-remote -q origin in /build/go/pkg/mod/cache/vcs/e0ff6709d9561cd702e87443057d453d3548ea032e47732ee7cb2e3eabe398bd: exit status 128:
       >  fatal: unable to access 'https://github.com/otiai10/copy/': Could not resolve host: github.com
       > local/node.go:30:2: reading github.com/prometheus/client_golang/go.mod at revision v1.16.0: git ls-remote -q origin in /build/go/pkg/mod/cache/vcs/6ffa6057942360db9e438bbc1bc03e3efd3ae1d41df4abeb5328ef376a815bfa: exit status 128:
       >  fatal: unable to access 'https://github.com/prometheus/client_golang/': Could not resolve host: github.com
       > local/node_process.go:16:2: reading github.com/shirou/gopsutil/go.mod at revision v3.21.11: git ls-remote -q origin in /build/go/pkg/mod/cache/vcs/35df165a65ecee74f2bbc0703b3b5f004c2986669b1ee712f3e0af6e4a4c8db2: exit status 128:
       >      fatal: unable to access 'https://github.com/shirou/gopsutil/': Could not resolve host: github.com
       > local/blockchain.go:43:2: unrecognized import path "golang.org/x/exp": https fetch: Get "https://golang.org/x/exp?go-get=1": dial tcp: lookup golang.org on [::1]:53: read udp [::1]:46770->[::1]:53: read: connection refused
       > local/network.go:39:2: unrecognized import path "golang.org/x/mod": https fetch: Get "https://golang.org/x/mod?go-get=1": dial tcp: lookup golang.org on [::1]:53: read udp [::1]:52709->[::1]:53: read: connection refused
       > server/server.go:22:2: unrecognized import path "go.uber.org/multierr": https fetch: Get "https://go.uber.org/multierr?go-get=1": dial tcp: lookup go.uber.org on [::1]:53: read udp [::1]:59572->[::1]:53: read: connection refused
       For full logs, run 'nix-store -l /nix/store/gx0fg6ll6rx5bywcmz6scaimwn95v8jg-avalanche-network-runner-1.7.5.drv'.
error: 1 dependencies of derivation '/nix/store/zxzc563qdbpcj16ainrkvjdly4l226cd-nix-shell-env.drv' failed to build

@andyjsbell
Copy link
Collaborator Author

Looks more like a name resolution issue from the logs.

@0xmovses
Copy link
Collaborator

Adding this here as a note to self, but the nix shell will need these cargo deps. No need to add now.

cargo install cargo-binstall
cargo binstall cargo-risczero
cargo risczero install

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants