Last active
August 7, 2018 00:47
-
-
Save codebje/6bb4d9887cca0fd34c359d033f0c80d8 to your computer and use it in GitHub Desktop.
Version of cabal.nix that can be retrieved directly from the gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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