use cabal2nix to create local nix environment for packages that aren't in nixpkgs

江枫思渺然 提交于 2019-12-03 19:58:49
illabout

I was able to get this working after using the method on O'Charles' Nix wiki. I have not determined why this method was not working before.

Basically, first run cabal2nix. Then create a generic shell.nix (that can be shared between all Haskell packages).

$ cabal2nix --jailbreak --sha256=X ./$cabal > default.nix
$ sed -i 's#sha = .*#src = builtins.filterSource (path: type: type != "unknown") ./.;#' default.nix
$ cat - > shell.nix <<EOF
let
  pkgs = import <nixpkgs> {};
  haskellPackages = pkgs.haskellPackages.override {
    extension = self: super: {
      thispackage = self.callPackage ./. {};
    };
  };
in pkgs.myEnvFun {
     name = haskellPackages.thispackage.name;
     buildInputs = [
       (haskellPackages.ghcWithPackages (hs: ([
         hs.cabalInstall
         hs.hscolour
         hs.ghcMod
       ] ++ hs.thispackage.propagatedNativeBuildInputs)))
     ];
   }      
EOF
$ nix-shell
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!