Skip to content

Instantly share code, notes, and snippets.

@matthewess
Last active October 30, 2019 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewess/03d833431b5855a3bc212861242bfaca to your computer and use it in GitHub Desktop.
Save matthewess/03d833431b5855a3bc212861242bfaca to your computer and use it in GitHub Desktop.
Nix-based Unison Development Environment
# this file is consumed by `nix-shell` to provide ghc+stack, as well as whatever development tools you need
# hlint is provided as an example
# this file can and should be customized with whatever development tools you want to use.
let
pkgs = import <nixpkgs> { };
in
pkgs.mkShell {
# include build or development tools here
buildInputs = [ pkgs.stack pkgs.ghc pkgs.haskellPackages.hlint ];
}
# this file is consumed by stack + nix to provide the right libraries for the unison build. it can probably be left alone.
{ ghc }:
with (import <nixpkgs> {});
let
libs = [
gmp
ncurses
zlib
];
native_libs = lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
Cocoa
CoreServices
]);
in haskell.lib.buildStackProject {
inherit ghc;
nativeBuildInputs = native_libs;
buildInputs = libs;
name = "unisonBuildEnv";
src = if lib.inNixShell then null else ./.;
}
# ...
# add the following stanza to your stack.yaml to tell stack to build dependencies using nix.
nix:
enable: true
shell-file: stack-shell.nix
# alternatively, create a separate file like stack-nix.yaml, and invoke stack with `stack --stack-yaml stack-nix.yaml ...`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment