summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabrielGonzalez <>2020-12-07 05:03:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2020-12-07 05:03:00 (GMT)
commit5b68e1df10b2aec5d0823f28f13b19c783878670 (patch)
treef2d61527908cf08a6f740d894998971a73e74968
parent665087c0c25ca2570988c182e41211a42ebe9729 (diff)
version 1.0.3HEAD1.0.3master
-rw-r--r--Main.hs42
-rw-r--r--dhall-nixpkgs.cabal6
2 files changed, 35 insertions, 13 deletions
diff --git a/Main.hs b/Main.hs
index fadba79..10a8518 100644
--- a/Main.hs
+++ b/Main.hs
@@ -140,6 +140,7 @@ data GitHub = GitHub
, directory :: FilePath
, file :: FilePath
, source :: Bool
+ , document :: Bool
}
data Directory = Directory
@@ -147,6 +148,7 @@ data Directory = Directory
, directory :: FilePath
, file :: FilePath
, source :: Bool
+ , document :: Bool
}
data NixPrefetchGit = NixPrefetchGit
@@ -197,6 +199,13 @@ parseSource =
<> Options.help "Configure the Nix package to include source code"
)
+parseDocument :: Parser Bool
+parseDocument =
+ Options.switch
+ ( Options.long "document"
+ <> Options.help "Generate documentation for the Nix package"
+ )
+
parseName :: Parser (Maybe Text)
parseName =
optional
@@ -246,6 +255,8 @@ parseGitHub = do
source <- parseSource
+ document <- parseDocument
+
return GitHub{..}
parseDirectory :: Parser Directory
@@ -258,6 +269,8 @@ parseDirectory = do
source <- parseSource
+ document <- parseDocument
+
return Directory{..}
parserInfoOptions :: ParserInfo Options
@@ -399,7 +412,7 @@ dependencyToNix url@URL{ authority, path } = do
let functionParameter = (prelude, Nothing)
let dependencyExpression =
- (Nix.mkSym prelude @. "override")
+ (Nix.mkSym prelude @. "overridePackage")
@@ Nix.attrsE
[ ("file", Nix.mkStr fileArgument ) ]
@@ -411,7 +424,7 @@ dependencyToNix url@URL{ authority, path } = do
let functionParameter = (repo, Nothing)
let dependencyExpression =
- (Nix.mkSym repo @. "override")
+ (Nix.mkSym repo @. "overridePackage")
@@ Nix.attrsE
[ ("file", Nix.mkStr fileArgument ) ]
@@ -453,7 +466,7 @@ dependencyToNix url@URL{ authority, path } = do
let functionParameter = (prelude, Nothing)
let dependencyExpression =
- (Nix.mkSym prelude @. "override")
+ (Nix.mkSym prelude @. "overridePackage")
@@ Nix.attrsE
[ ("file", Nix.mkStr fileArgument) ]
@@ -463,7 +476,7 @@ dependencyToNix url@URL{ authority, path } = do
die (UnsupportedDomainDependency url authority)
githubToNixpkgs :: GitHub -> IO ()
-githubToNixpkgs GitHub{ name, uri, rev = maybeRev, hash, fetchSubmodules, directory, file, source } = do
+githubToNixpkgs GitHub{ name, uri, rev = maybeRev, hash, fetchSubmodules, directory, file, source, document } = do
URI{ uriScheme, uriAuthority = Just URIAuth{ uriUserInfo, uriRegName, uriPort }, uriPath, uriQuery, uriFragment } <- do
case URI.parseAbsoluteURI (Text.unpack uri) of
Nothing -> die (RepositoryIsNotAValidURI uri)
@@ -569,8 +582,6 @@ githubToNixpkgs GitHub{ name, uri, rev = maybeRev, hash, fetchSubmodules, direct
let baseDirectory = Turtle.directory expressionFile
- let baseDirectoryString = Turtle.encodeString baseDirectory
-
exists <- Turtle.testfile expressionFile
if exists
@@ -579,9 +590,13 @@ githubToNixpkgs GitHub{ name, uri, rev = maybeRev, hash, fetchSubmodules, direct
expressionText <- Turtle.readTextFile expressionFile
- expression <- Dhall.Core.throws (Dhall.Parser.exprFromText baseDirectoryString expressionText)
+ let expressionFileString = Turtle.encodeString expressionFile
+
+ expression <- Dhall.Core.throws (Dhall.Parser.exprFromText expressionFileString expressionText)
let status = Dhall.Import.emptyStatus baseDirectoryString
+ where
+ baseDirectoryString = Turtle.encodeString baseDirectory
dependencies <- Turtle.reduce Foldl.nub (State.evalStateT (findExternalDependencies expression) status)
@@ -610,6 +625,7 @@ githubToNixpkgs GitHub{ name, uri, rev = maybeRev, hash, fetchSubmodules, direct
, ("directory", Nix.mkStr (Turtle.format fp directory))
, ("file", Nix.mkStr (Turtle.format fp file))
, ("source", Nix.mkBool source)
+ , ("document", Nix.mkBool document)
, ("dependencies", Nix.mkList (nub (fmap dependencyExpression nixDependencies)))
]
)
@@ -617,7 +633,7 @@ githubToNixpkgs GitHub{ name, uri, rev = maybeRev, hash, fetchSubmodules, direct
Prettyprint.Text.putDoc ((Nix.Pretty.prettyNix nixExpression) <> "\n")
directoryToNixpkgs :: Directory -> IO ()
-directoryToNixpkgs Directory{ name, directory, file, source } = do
+directoryToNixpkgs Directory{ name, directory, file, source, document } = do
let finalName =
case name of
Nothing -> Turtle.format fp (Turtle.dirname directory)
@@ -634,11 +650,14 @@ directoryToNixpkgs Directory{ name, directory, file, source } = do
expressionText <- Turtle.readTextFile expressionFile
- let directoryString = Turtle.encodeString directory
+ let expressionFileString = Turtle.encodeString expressionFile
- expression <- Dhall.Core.throws (Dhall.Parser.exprFromText directoryString expressionText)
+ expression <- Dhall.Core.throws (Dhall.Parser.exprFromText expressionFileString expressionText)
let status = Dhall.Import.emptyStatus directoryString
+ where
+ directoryString =
+ Turtle.encodeString (Turtle.directory expressionFile)
dependencies <- Turtle.reduce Foldl.nub (State.evalStateT (findExternalDependencies expression) status)
@@ -649,6 +668,8 @@ directoryToNixpkgs Directory{ name, directory, file, source } = do
let src | null directoryString = directoryString
| last directoryString == '/' = init directoryString
| otherwise = directoryString
+ where
+ directoryString = Turtle.encodeString directory
let nixExpression =
Nix.mkFunction
@@ -664,6 +685,7 @@ directoryToNixpkgs Directory{ name, directory, file, source } = do
, ("src", Nix.mkPath False src)
, ("file", Nix.mkStr (Turtle.format fp file))
, ("source", Nix.mkBool source)
+ , ("document", Nix.mkBool document)
, ("dependencies", Nix.mkList (nub (fmap dependencyExpression nixDependencies)))
]
)
diff --git a/dhall-nixpkgs.cabal b/dhall-nixpkgs.cabal
index 234d83d..ad0d10b 100644
--- a/dhall-nixpkgs.cabal
+++ b/dhall-nixpkgs.cabal
@@ -1,4 +1,4 @@
-Version: 1.0.2
+Version: 1.0.3
Cabal-Version: >=1.10
Name: dhall-nixpkgs
Synopsis: Convert Dhall projects to Nix packages
@@ -19,9 +19,9 @@ Executable dhall-to-nixpkgs
Build-Depends: base >= 4.11 && < 5
, aeson >= 1.0.0.0 && < 1.5
, data-fix
- , dhall >= 1.32.0 && < 1.37
+ , dhall >= 1.32.0 && < 1.38
, foldl < 1.5
- , hnix >= 0.10.1 && < 0.11
+ , hnix >= 0.10.1 && < 0.12
, lens-family-core >= 1.0.0 && < 2.2
, megaparsec >= 7.0.0 && < 9.1
, mmorph < 1.2