2

我想让 GHC 7.8.3 成为默认的系统范围的 Haskell 编译器,我不想安装整个平台;这是我的configurarion.nix文件:

{
    environment.systemPackages = with pkgs; [ 
        haskellPackages_ghc783_profiling.alex
        haskellPackages_ghc783_profiling.happy 
        # ghc.ghc783 -- not sure about this one
        haskellPackages_ghc783_profiling.ghc
        haskellPackages_ghc783_profiling.cabalInstall
    ];
}

但是,默认情况下会显示 7.6.3 版,我无法想象它来自哪里......

$ ghc --verion
$ The Glorious Glasgow Haskell Compilation System, version 7.6.3

我在Wiki 页面上找到了一些提示:

pkgs : {
   packageOverrides = self : rec {
     hsEnv = self.haskellPackages.ghcWithPackages (self : [
         self.haskellPlatform
         # add more packages here
         #
         #   I tried to replace `self.haskellPlatform`
         #   with `self:ghc783`, 
         #   with `self:haskellPackages.ghc_783_profiling.ghc`, and
         #   with `self:ghc`, but all that produces errors.
     ]);
   };
 }

那么,将 7.8.3 版本设置为默认版本的正确方法是什么?

4

2 回答 2

1

要在系统范围内使用特定的 GHC 版本,我使用这样的模块

用于nixpkgs.config.packageOverrides重命名haskellPackages为所需版本并添加 haskell 环境:

nixpkgs.config.cabal.libraryProfiling = true;
nixpkgs.config.packageOverrides = in_pkgs : rec
  { 
    haskellPackages = in_pkgs.haskellPackages_ghc784_profiling;
    hsEnv = in_pkgs.haskellPackages_ghc784_profiling.ghcWithPackages hsPkgs;
  }

定义hsPkgs为包列表构造函数:

添加hsEnvenvironment.systemPackages

environment.systemPackages = [ hsEnv ];
于 2015-02-08T01:44:54.523 回答
0

Maybe you installed it in your user nix env? Try nix-env -q.

于 2015-02-03T09:07:03.017 回答