Nix & Haskell

Creating shell.nix

$ nix-shell -p cabal2nix
[nix-shell:~/Werk/foo]$ cabal2nix --shell . > shell.nix

Running tests

[nix-shell:~/Werk/sfoo]$ runhaskell -isrc -itest test/Spec.hs 

Building

$ cabal2nix . > default.nix
$ echo "let pkgs = import <nixpkgs> {}; in pkgs.haskellPackages.callPackage ./default.nix {}" > build.nix
$ nix-build build.nix
$ ./result/bin/foo

For disabling tests in dependencies, I added the following to ~/.nixpkgs/config.nix:

{
  packageOverrides = super: let self = super.pkgs; in
  {
    noTestsHaskellPackages = self.haskellPackages.override {
      overrides = self: super: {
        mkDerivation = args: super.mkDerivation (args // {
          doCheck = false;
        });
      };
    };
  };
}
 
0
Kudos
 
0
Kudos

Now read this

When linking goes wrong

I have a Haskell application that needs to be deployed to a server. I took the route of having CircleCI copy the binary after stack install to a S3 bucket, and have an Ansible playbook that copies the binary to the server and launch it... Continue →