Generating a Nix package from a stack project

时光毁灭记忆、已成空白 提交于 2019-11-30 20:22:25

With this recent merge, I am able to build and installed a simple stack project using following steps:

  1. Create new hello project with stack new hello
  2. Add following lines to stack.yaml

    nix:
      enable: true
      shell-file: default.nix
    
  3. Create default.nix

    with (import <nixpkgs> { });
    
    haskell.lib.buildStackProject {
      name = "hello";
      src = ./.;
    }
    

At this point, I am able to run nix-build to build the project and result will be at ./result/bin/hello-exe

If I want to install, I would run nix-env -i -f default.nix


Side note: nix-build will download stack's build plan every time it run.

I want to incrementally build my project while making changes so I mainly just drop in the shell and call stack build there.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!