translators/cabal-freeze: Read name and version from cabal file

Also remove those fields from extraArgs.
This commit is contained in:
Brian Leung 2022-10-22 02:24:10 -07:00
parent 2c55306152
commit 2d78731477
No known key found for this signature in database
GPG Key ID: 2D86D6A94C8BB3B1
2 changed files with 23 additions and 17 deletions

View File

@ -17,7 +17,6 @@
{
translator = "cabal-freeze";
}
{subsystemInfo = {defaultPackageName = "unordered-containers";};}
];
});
}

View File

@ -112,8 +112,6 @@ in {
tree,
# arguments defined in `extraArgs` (see below) specified by user
ghcVersion,
defaultPackageName,
defaultPackageVersion,
...
} @ args: let
# get the root source and project source
@ -121,6 +119,29 @@ in {
projectSource = "${tree.fullPath}/${project.relPath}";
projectTree = tree.getNodeFromPath project.relPath;
# FIXME: This is the first of many snippets that will need to be modified to support multiple packages
cabalFileText = l.pipe projectTree.files [
l.attrNames
(
l.findFirst (l.hasSuffix ".cabal")
(throw "No cabal file in the tree")
)
projectTree.getNodeFromPath
(l.attrByPath ["fullPath"] "")
dlib.readTextFile
(s: "\n" + s)
];
defaultPackageName = l.pipe cabalFileText [
(l.match ".*\nname:[[:space:]]+([^[:space:]]+).*")
l.head
];
defaultPackageVersion = l.pipe cabalFileText [
(l.match ".*\nversion:[[:space:]]+([^[:space:]]+).*")
l.head
];
parsedCabalFreeze = l.pipe projectTree.files [
l.attrNames
(
@ -277,19 +298,5 @@ in {
examples = ["9.0.2" "9.4.1"];
type = "argument";
};
defaultPackageName = {
description = "Name of default package";
default = "main";
examples = ["main" "default"];
type = "argument";
};
defaultPackageVersion = {
description = "Version of default package";
default = "unknown";
examples = ["unknown" "1.2.0"];
type = "argument";
};
};
}