【问题标题】:Building a Haskell nix expression from GitHub fails when passing optional build argument传递可选构建参数时,从 GitHub 构建 Haskell nix 表达式失败
【发布时间】:2020-02-11 17:53:15
【问题描述】:

问题。我正在从它的 GitHub repo 构建一个 nix 表达式 godot-haskell

  • 具有/需要 git 子模块才能正确编译
  • 采用我想使用的可选构建参数godot-api

如果我手动克隆这个 repo(通过 git clone --recursive 递归),然后

let 
  # ...
  godot-haskell = haskellPackages.callPackage /local/path/to/default.nix { api-json = godot-api; };
  # ...
in 
  # ...

然后一切正常!但如果我尝试在非本地执行此操作:

godot-haskell-nix = "${fetchFromGitHub {
  fetchSubmodules = true;
  owner = "SimulaVR";
  repo = "godot-haskell";
  rev =  "df592f8e12647ed58d7ba6da4cf40a382d83725e";
  sha256 = "05wp8lzj2xqwkif8hw9l4byw0dfm3y3jaccsvjif4izfwycj91r8";
  }}/default.nix";

godot-haskell = haskellPackages.callPackage godot-haskell-nix { api-json = godot-api; };  # <- With the `api-json` build argument

然后我得到

error: anonymous function at /nix/store/xnf67r119iazf828ixny8wjyzl01hwsg-source/default.nix:1:1 called with unexpected argument 'api-json', at /nix/store/7knlwgidnagqrckm5h051i4rxjf3l68z-nixpkgs-20.03pre211220.1144ee55385/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:87:27
(use '--show-trace' to show detailed location information)

问题: 为什么在本地执行时可以正常工作,但使用fetchFromGitHub 时突然失败?如何解决这个错误?

【问题讨论】:

标签: haskell github nix


【解决方案1】:

cat /nix/store/xnf67r119iazf828ixny8wjyzl01hwsg-source/default.nix 显示:

{ mkDerivation, aeson, ansi-wl-pprint, base, bytestring, c2hs
, casing, colour, containers, hpack, lens, linear, mtl, parsec
, parsers, stdenv, stm, template-haskell, text
, unordered-containers, vector
}:

mkDerivation {
  pname = "godot-haskell";
  version = "3.1.0.0";
  src = ./.;
  libraryHaskellDepends = [
    aeson ansi-wl-pprint base bytestring casing colour containers lens
    linear mtl parsec parsers stm template-haskell text
    unordered-containers vector
  ];
  libraryToolDepends = [ c2hs hpack ];
  doHaddock = false;
  preConfigure = "hpack";
  homepage = "https://github.com/KaneTW/godot-haskell#readme";
  description = "Haskell bindings for the Godot game engine API";
  license = stdenv.lib.licenses.bsd3;
}

没有api-json 参数!所以区别不在于 nix 如何评估本地文件与 fetchFromGitHub 的,区别在于它们的内容不同!

果然,我查看了那个 repo 的修订版df592f8e12647ed58d7ba6da4cf40a382d83725e。这是master 分支上的最新提交。但是,您在问题中包含的链接转到 simula 分支,其中包括尚未提交到 master 的提交。

尝试使用rev = "45f15cf95e5a7228bed0739e020d4c404c3af49e";(当然,您还必须更新 nix 哈希)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-08
    • 1970-01-01
    • 2020-04-09
    • 2019-04-07
    • 1970-01-01
    • 2021-02-17
    • 2015-03-12
    • 1970-01-01
    相关资源
    最近更新 更多