nixos:我的自定义软件包派生在“货物建造”中失败

时间:2019-05-05 22:14:49

标签: rust rust-cargo nix nixos

我正在编写一个派生软件包,以安装kryptco/kr,但在cargo build阶段失败。

kryptco/kr有一个子模块kryptco/sigchain,由rust编写。 在kryptco/sigchain的{​​{3}}中,他们使用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

1 个答案:

答案 0 :(得分:0)

我认为您不会对配置文件进行[replace]编辑。 cargo web deploy的构建失败是由于openssl-sys的版本过旧(已终止)。 Here's how Parity fixed it。好像他们编辑了Cargo.lock文件以依赖于该库的较新版本。