Skip to content

Commit

Permalink
Merge pull request #284 from dmjio/derivation-info
Browse files Browse the repository at this point in the history
Expose derivation info from cabal2nix'
  • Loading branch information
peti authored Jul 10, 2017
2 parents f81ab11 + 4e9e46d commit cb2265e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/Cabal2nix.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{-# LANGUAGE OverloadedStrings #-}

module Cabal2nix
( main, cabal2nix
( main, cabal2nix, cabal2nix'
)
where

Expand Down Expand Up @@ -118,8 +118,8 @@ main :: IO ()
main = bracket (return ()) (\() -> hFlush stdout >> hFlush stderr) $ \() ->
cabal2nix =<< getArgs

cabal2nix :: [String] -> IO ()
cabal2nix args = do
cabal2nix' :: [String] -> IO (Either Doc Derivation)
cabal2nix' args = do
Options {..} <- handleParseResult $ execParserPure defaultPrefs pinfo args

pkg <- getPackage optHackageDb $ Source optUrl (fromMaybe "" optRevision) (maybe UnknownHash Guess optSha256) (fromMaybe "" optSubpath)
Expand Down Expand Up @@ -165,8 +165,14 @@ cabal2nix args = do
, text ""
, text " if pkgs.lib.inNixShell then drv.env else drv"
]
pure $ if optNixShellOutput then Left shell else Right deriv

print (if optNixShellOutput then shell else pPrint deriv)
cabal2nix :: [String] -> IO ()
cabal2nix args = do
v <- cabal2nix' args
print $ case v of
Left shell -> shell
Right d -> pPrint d

readFlagList :: [String] -> FlagAssignment
readFlagList = map tagWithValue
Expand Down

0 comments on commit cb2265e

Please sign in to comment.