Skip to content

Instantly share code, notes, and snippets.

@codebje
Last active Aug 7, 2018
Embed
What would you like to do?
Version of cabal.nix that can be retrieved directly from the gist
{ basePath ? ./.}:
with builtins; rec {
cabalProjects = listToAttrs (if pathExists (basePath + "/cabal.project")
then projectParse
else [ { name = baseNameOf basePath; value = basePath; } ] );
projectParse = let
contents = readFile (basePath + "/cabal.project");
trimmed = replaceStrings ["packages:" " "] ["" ""] contents;
packages = filter (x: isString x && x != "") (split "\n" trimmed);
package = p: substring 0 (stringLength p - 1) p;
paths = map (p: let p' = package p; in { name = p'; value = toPath (basePath + "/${p'}"); } ) packages;
in paths;
}.cabalProjects
let
# ...
# Parse the list of targets to build from cabal.project, or from <basename>.cabal if no project file exists
targets = import (builtins.fetchurl {
url = "https://gist.githubusercontent.com/codebje/6bb4d9887cca0fd34c359d033f0c80d8/raw/ddda82c94dff6bfe010bae6b22491c4991a43373/cabal.nix";
sha256 = "0zackipwxw4qnxap89srl3gmlgd9nqrjrh6fghxsf6ib96fif71n";
}) { basePath = ./.; };
# ...
in {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment