NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.51k stars 12.99k forks source link

Package request: Sui #303467

Open hmanhng opened 2 months ago

hmanhng commented 2 months ago

Project description

Sui is a first-of-its-kind Layer 1 blockchain and smart contract platform designed to make digital asset ownership fast, private, secure, and accessible.

Metadata


Add a :+1: reaction to issues you find important.

hmanhng commented 2 months ago

I need this package to learn smart contracts blockchain, can someone help me build this package? I tried buildRustPackage to build it but i'm not good at nix

TomaSajt commented 2 months ago

Try to package it, however, upstream has an issue where tokio-macros is present from multiple places. This makes nixpkgs's cargo vendoring fail.

Here's the part in Cargo.lock https://github.com/MystenLabs/sui/blob/127f2cb31699ebddbe1ea4935d264a235ca2e9ca/Cargo.lock#L14852-L14871

This is probably caused by the real_tokio git dependency.

Here's what I had so far:

{
  lib,
  rustPlatform,
  fetchFromGitHub,
}:

rustPlatform.buildRustPackage rec {
  pname = "sui";
  version = "1.22.0";

  src = fetchFromGitHub {
    owner = "MystenLabs";
    repo = "sui";
    rev = "mainnet-v${version}";
    hash = "sha256-8RazuUtssjdvU545DFYjZBrGE0Ln3axtgTpEAHWGWiM=";
  };

  cargoLock = {
    lockFile = ./Cargo.lock;
    outputHashes = {
      "anemo-0.0.0" = "sha256-KZBh/i7vAF8MopWmxc403c+UkXLWv8bBrgXOy6Ro2Q4=";
      "async-task-4.3.0" = "sha256-zMTWeeW6yXikZlF94w9I93O3oyZYHGQDwyNTyHUqH8g=";
      "datatest-stable-0.1.3" = "sha256-VAdrD5qh6OfabMUlmiBNsVrUDAecwRmnElmkYzba+H0=";
      "fastcrypto-0.1.7" = "sha256-8CzB/1SqaWLhTBIHi68LDEiiGeUxyYbGetOMcJ1WeKk=";
      "json_to_table-0.6.0" = "sha256-UKMTa/9WZgM58ChkvQWs1iKWTs8qk71gG+Q/U/4D4x4=";
      "jsonrpsee-0.16.2" = "sha256-PvuoB3iepY4CLUm9C1EQ07YjFFgzhCmLL1Iix8Wwlns=";
      "msim-0.1.0" = "sha256-dqA/2xXnOdBg6O07f4gWf8XBHQqqC9W9TBpFVfM4tWU=";
      "nexlint-0.1.0" = "sha256-8UM1vRV+2mvx/4+qFgnsqzKkJgeg0mH1gX6iFYtHAAY=";
      "prometheus-parse-0.2.3" = "sha256-TGiTdewA9uMJ3C+tB+KQJICRW3dSVI0Xcf3YQMfUo6Q=";
      "real_tokio-1.36.0" = "sha256-q5jIRO3BGJVZtq3sagGFvLgL/u7dmz5yukwqFEuX3fc=";
    };
  };

  meta = {
    changelog = "";
    description = "";
    homepage = "";
    license = with lib.licenses; [ ];
    mainProgram = "";
    maintainers = with lib.maintainers; [ ];
  };
}
hmanhng commented 2 months ago

Try to package it, however, upstream has an issue where tokio-macros is present from multiple places. This makes nixpkgs's cargo vendoring fail.

Here's the part in Cargo.lock https://github.com/MystenLabs/sui/blob/127f2cb31699ebddbe1ea4935d264a235ca2e9ca/Cargo.lock#L14852-L14871

This is probably caused by the real_tokio git dependency.

Here's what I had so far:

{
  lib,
  rustPlatform,
  fetchFromGitHub,
}:

rustPlatform.buildRustPackage rec {
  pname = "sui";
  version = "1.22.0";

  src = fetchFromGitHub {
    owner = "MystenLabs";
    repo = "sui";
    rev = "mainnet-v${version}";
    hash = "sha256-8RazuUtssjdvU545DFYjZBrGE0Ln3axtgTpEAHWGWiM=";
  };

  cargoLock = {
    lockFile = ./Cargo.lock;
    outputHashes = {
      "anemo-0.0.0" = "sha256-KZBh/i7vAF8MopWmxc403c+UkXLWv8bBrgXOy6Ro2Q4=";
      "async-task-4.3.0" = "sha256-zMTWeeW6yXikZlF94w9I93O3oyZYHGQDwyNTyHUqH8g=";
      "datatest-stable-0.1.3" = "sha256-VAdrD5qh6OfabMUlmiBNsVrUDAecwRmnElmkYzba+H0=";
      "fastcrypto-0.1.7" = "sha256-8CzB/1SqaWLhTBIHi68LDEiiGeUxyYbGetOMcJ1WeKk=";
      "json_to_table-0.6.0" = "sha256-UKMTa/9WZgM58ChkvQWs1iKWTs8qk71gG+Q/U/4D4x4=";
      "jsonrpsee-0.16.2" = "sha256-PvuoB3iepY4CLUm9C1EQ07YjFFgzhCmLL1Iix8Wwlns=";
      "msim-0.1.0" = "sha256-dqA/2xXnOdBg6O07f4gWf8XBHQqqC9W9TBpFVfM4tWU=";
      "nexlint-0.1.0" = "sha256-8UM1vRV+2mvx/4+qFgnsqzKkJgeg0mH1gX6iFYtHAAY=";
      "prometheus-parse-0.2.3" = "sha256-TGiTdewA9uMJ3C+tB+KQJICRW3dSVI0Xcf3YQMfUo6Q=";
      "real_tokio-1.36.0" = "sha256-q5jIRO3BGJVZtq3sagGFvLgL/u7dmz5yukwqFEuX3fc=";
    };
  };

  meta = {
    changelog = "";
    description = "";
    homepage = "";
    license = with lib.licenses; [ ];
    mainProgram = "";
    maintainers = with lib.maintainers; [ ];
  };
}

Is it necessary to add these dependencies?

sudo apt-get install curl git-all cmake gcc libssl-dev pkg-config libclang-dev libpq-dev build-essential
TomaSajt commented 2 months ago

It will be, however this cargo thing is what we have to solve first. I'll look into it later.

hmanhng commented 2 months ago

Does it work?

hmanhng commented 2 months ago

It will be, however this cargo thing is what we have to solve first. I'll look into it later.

I get the following error ln: failed to create symbolic link '/nix/store/n8axkcpp0j7jf7cabax62jik03vrln85-cargo-vendor-dir/tokio-macros-2.2.0/5l99p53ifbax62jik03vrln85-cargo-vendor-dir/tokio-macros-2.2.0/5l99p53if38q8y1xcjm2amv9jdmmhs1z-tokio-macros-2.2.0': Permission denied

TomaSajt commented 2 months ago

AFAICT the issue is the following:

There's this line in the definition of cargo-vendor-dir https://github.com/NixOS/nixpkgs/blob/2a7a80ac27f403e10c1bdbd7cab3a1653a33816b/pkgs/build-support/rust/import-cargo-lock.nix#L250 which symlinks the cargo dependencies to the right place. However, because there are 2 different tokio-macros dependencies with the 2.2.0 version, it will try to create the symlink twice:

I think this is pretty similar to the problem mentioned here: https://github.com/NixOS/nixpkgs/issues/183344

TomaSajt commented 2 months ago

https://github.com/NixOS/nixpkgs/pull/282798 actually seems to solve the issue with cargo.