mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-12-23 14:31:55 +03:00
translators/cabal-freeze: Read name and version from cabal file
Also remove those fields from extraArgs.
This commit is contained in:
parent
2c55306152
commit
2d78731477
@ -17,7 +17,6 @@
|
||||
{
|
||||
translator = "cabal-freeze";
|
||||
}
|
||||
{subsystemInfo = {defaultPackageName = "unordered-containers";};}
|
||||
];
|
||||
});
|
||||
}
|
||||
|
@ -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";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user