Skip to content

Instantly share code, notes, and snippets.

@savannidgerinel
Created February 4, 2017 00:40
Show Gist options
  • Save savannidgerinel/50d2d50fb7a5be87fb9ba96073eedc94 to your computer and use it in GitHub Desktop.
Save savannidgerinel/50d2d50fb7a5be87fb9ba96073eedc94 to your computer and use it in GitHub Desktop.
A .nix file for building whatever version of purescript you want from the github releases
{ env, pkgs, ghc }:
let
pname = "purescript";
pversion = "0.10.3";
url = "https://github.com/purescript/purescript/archive/v${pversion}.tar.gz";
sha256 = "46c3f695ccc6e7be3cb2afe1ea9586eafdf51a04f1d40fe7240def0d8693ca68";
in env.mkDerivation rec {
name = pname;
version = pversion;
src = pkgs.fetchurl {
url = url;
sha256 = sha256;
name = pname;
};
buildInputs = [ pkgs.stack
pkgs.haskell.compiler."${ghc}"
pkgs.ncurses5
pkgs.zlib
pkgs.haskell.packages."${ghc}".alex
pkgs.haskell.packages."${ghc}".happy
];
# copied from generic-stack-builder.nix in the nixpkgs repository
# workaround for https://ghc.haskell.org/trac/ghc/ticket/11042
LD_LIBRARY_PATH = pkgs.stdenv.lib.makeLibraryPath (buildInputs);
buildCommand = ''
export HOME=/tmp/stack
tar -xf $src
cd purescript-0.10.3
mkdir -p $out
stack build --system-ghc --local-bin-path=$out/bin --copy-bins
'';
}
let
pkgs = import <nixpkgs> {};
stdenv = pkgs.stdenv;
purescript = pkgs.callPackage ./nix-deps/purescript.nix { env = pkgs.stdenv;
pkgs = pkgs;
ghc = "ghc7103";
};
in stdenv.mkDerivation {
name =
...
}
@savannidgerinel
Copy link
Author

I'm sure there is a better way to do this, but the purescript.nix file above is my solution to needing to get a particular version of purescript that is not actually in the nixpkgs mainline. I set it up with the intent that shell.nix for my project would include the purescript derivation. I also explicitly specify /tmp/stack as a way to cache stack build results so that I didn't have to rebuild the world on every single invocation of this script. I find this an acceptable compromise, at least for now, because stack does a reasonable job of handling build artifacts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment