rust - nixos:我的自定义包派生在 `cargo build` 上失败

标签 rust rust-cargo nix nixos

我正在编写一个包派生来安装 kryptco/kr它在 cargo build 阶段失败。

kryptco/kr 有一个由 rust 编写的子模块 kryptco/sigchain。 在Makefilekryptco/sigchain 中,他们使用 cargo web deploy 命令构建其子模块。我的包派生在此 cargo web deploy 阶段失败。

给出了这两个错误。

error: warning: replace for the non root package will be ignored, specify replace at the workspace root:
package:   /build/src/github.com/kryptco/kr/sigchain/sigchain_client/Cargo.toml
workspace: /build/src/github.com/kryptco/kr/sigchain/Cargo.toml
error: failed to fetch `https://github.com/rust-lang/crates.io-index`

Caused by:
  [6] Couldn't resolve host name; class=Net (12)

前一个错误提示要编辑 Cargo.toml 并添加 [replace] 部分,但我想尽可能避免编辑源代码。

这些错误的原因是什么?

这是我的包推导:

# Original: https://github.com/bogsen/nixos-public/blob/a0dc497eab5de528ce3006d\
36c52bc601422cf87/pkgs/krypton/default.nix

{ config, lib, pkgs, ... }: with lib; let
  cfg = config.services.krypton;

  cargoWeb = with pkgs; rustPlatform.buildRustPackage rec {
     ...
  };
  dependencies = with pkgs; [
    cargo
    emscripten
    go
    makeWrapper
    perl
  ];

  kr = pkgs.stdenv.mkDerivation {
    name = "kr";

    src = pkgs.fetchFromGitHub {
      owner = "kryptco";
      repo = "kr";
      rev = "2.4.10";
      sha256 = "1xxhlkcw2d52q1y4h40iyvq25804w7hzv0lflqnib68aps491xnj";
      fetchSubmodules = true;
    };

    buildInputs = dependencies ++ [cargoWeb];

    dontBuild = true;

    postUnpack = ''
      # prevent referring /homeless-shelter
      export HOME=$(pwd)

      # https://github.com/kryptco/kr/issues/254#issuecomment-464890476
      sed -i.bak -e '8,11d' source/sigchain/Cargo.toml

      export GOPATH=$(pwd)
      export GOCACHE=$GOPATH/.cache/go-build
      mkdir -p src/github.com/kryptco
      mv source src/github.com/kryptco/kr
      ln -s src/github.com/kryptco/kr source
    '';

    postPatch = ''
      substituteInPlace Makefile --replace sudo ""
    '';

    makeFlags = [ "PREFIX=$(out)" ];
  };
in {
  config = {
    nixpkgs.config.packageOverrides = pkgs: { kr = kr; };
  };
}

完整的错误信息在这里。

# use rsync so that file modifed times are only updated when the contents change
cd dashboard_yew && cargo web deploy --release --target=wasm32-unknown-emscripten && rsync --checksum --delete -r ../target/deploy/* ../target/deploy-final
error: warning: replace for the non root package will be ignored, specify replace at the workspace root:
package:   /build/src/github.com/kryptco/kr/sigchain/sigchain_client/Cargo.toml
workspace: /build/src/github.com/kryptco/kr/sigchain/Cargo.toml
    Updating crates.io index
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name; class=Net (12)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name; class=Net (12)
error: failed to fetch `https://github.com/rust-lang/crates.io-index`

Caused by:
  [6] Couldn't resolve host name; class=Net (12)

make[1]: *** [Makefile:25: libsigchain-with-dashboard] Error 101
make[1]: Leaving directory '/build/src/github.com/kryptco/kr/sigchain'
make: *** [Makefile:71: all] Error 2
builder for '/nix/store/78r0kh34ljzgfx658f9n99f8lxydjfxy-kr.drv' failed with exit code 2

最佳答案

我认为您不会绕过配置文件的 [replace] 编辑。 cargo web deploy 中的构建失败是由于 openssl-sys 版本过时(已停产)。 Here's how Parity fixed it .看起来他们编辑了 Cargo.lock 文件以依赖于这个库的更新版本。

关于rust - nixos:我的自定义包派生在 `cargo build` 上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55996879/

相关文章:

compiler-errors - 如何添加外部软件包并在rust编译器中运行?

nix - 关于 Nix 包管理的 Nix 表达式是什么?

go - 在 nix 中使用 buildGoPackage 时出现“没有这样的文件或目录”错误

c++ - Rust 中泛型的单独编译

rust - 将可变实例方法传递给函数

rust - 如何避免并行运行一些测试?

Python3 安装与 nix 困惑 PATH

rust - 无需克隆即可获得 HashMap.get() 结果的所有权

rust - 如何将 Entry API 与仅在 Entry 为空时才构建的昂贵 key 一起使用?

rust - 如何更改 `cargo install` 放置二进制文件的位置?