如何解决如何将ghcide添加到shell.nix
我有一个Haskell Cabal项目。我一直在使用 cabal2nix 构建它。因此,我有3个nix文件:
- project.nix- cabal2nix 生成的.nix文件。
- default.nix-仅
haskell.callPackage ./project.nix {}
- shell.nix-仅返回默认的环境
(import ./default.nix {}).env
最近,我决定使用ghcide设置vscode开发环境。在说明中说
在项目
pkgs.haskellPackages.ghcide
中包含shell.nix
...
无需进一步说明。听起来应该很容易,但是我不知道怎么做。我该怎么办?
解决方法
您可以将ghcide
软件包添加到buildTools
配置下;
{mkDerivation,stdenv,base,aeson,scotty,wai-extra,text,ghcide}:
mkDerivation {
pname = "come";
version = "0.1.0.0";
src = ./.;
isLibrary = false;
isExecutable = true;
executableHaskellDepends = [
base aeson scotty wai-extra text
];
buildTools = [ghcide];
homepage = "http://emre.xyz/come";
description = "demo project";
license = with stdenv.lib.licenses; [gpl3Plus];
}
,
在shell.nix
中使用shellFor
函数。它在软件包集中,而不是haskell.lib
中。根据{{3}}上shellFor内联文档的示例,我已重命名all-packages.nix
,并在shell.nix
中为其添加了一个let绑定,并添加了ghcide
。
# Returns a derivation whose environment contains a GHC with only
# the dependencies of packages listed in `packages`,not the
# packages themselves. Using nix-shell on this derivation will
# give you an environment suitable for developing the listed
# packages with an incremental tool like cabal-install.
# In addition to the "packages" arg and "withHoogle" arg,anything that
# can be passed into stdenv.mkDerivation can be included in the input attrset
#
# # all-packages.nix
# with import <nixpkgs> {};
# haskellPackages.extend (haskell.lib.packageSourceOverrides {
# frontend = ./frontend;
# backend = ./backend;
# common = ./common;
# })
#
# # shell.nix
# let pkgs = import <nixpkgs> {};
# allPackages = import ./all-packages.nix;
# in
# allPackages.shellFor {
# packages = p: [p.frontend p.backend p.common];
# withHoogle = true;
# buildInputs = [ allPackages.ghcide ];
# }
#
# -- cabal.project
# packages:
# frontend/
# backend/
# common/
#
# bash$ nix-shell --run "cabal new-build all"
# bash$ nix-shell --run "python"
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。