From b0cabae36622e888b71d3a09bba3c6edb01ce4f8 Mon Sep 17 00:00:00 2001 From: Paolo Capriotti Date: Mon, 9 Apr 2012 20:39:58 +0100 Subject: [PATCH 1/2] Add option to specify cabal-dev sandbox explicitly. --- CabalDev.hs | 14 +++++++++++--- GHCMod.hs | 3 +++ Types.hs | 2 ++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CabalDev.hs b/CabalDev.hs index c7a32b1..f6deb0b 100644 --- a/CabalDev.hs +++ b/CabalDev.hs @@ -17,11 +17,19 @@ import Types modifyOptions :: Options -> IO Options modifyOptions opts = found ||> notFound where - found = addPath opts <$> findCabalDev + found = do + path <- findCabalDev (sandbox opts) + return $ addPath opts path notFound = return opts -findCabalDev :: IO String -findCabalDev = getCurrentDirectory >>= searchIt . splitPath +findCabalDev :: Maybe String -> IO FilePath +findCabalDev (Just path) = do + a <- doesDirectoryExist path + if a then + findConf path + else + findCabalDev Nothing +findCabalDev Nothing = getCurrentDirectory >>= searchIt . splitPath addPath :: Options -> String -> Options addPath orig_opts path = do diff --git a/GHCMod.hs b/GHCMod.hs index f2f5a06..1c84c05 100644 --- a/GHCMod.hs +++ b/GHCMod.hs @@ -57,6 +57,9 @@ argspec = [ Option "l" ["tolisp"] , Option "o" ["operators"] (NoArg (\opts -> opts { operators = True })) "print operators, too" + , Option "s" ["sandbox"] + (ReqArg (\s opts -> opts { sandbox = Just s }) "path") + "specify cabal-dev sandbox (default 'cabal-dev`)" ] parseArgs :: [OptDescr (Options -> Options)] -> [String] -> (Options, [String]) diff --git a/Types.hs b/Types.hs index 0be01be..0fb53e2 100644 --- a/Types.hs +++ b/Types.hs @@ -10,6 +10,7 @@ data Options = Options { , ghcOpts :: [String] , operators :: Bool , expandSplice :: Bool + , sandbox :: Maybe String } defaultOptions :: Options @@ -19,6 +20,7 @@ defaultOptions = Options { , ghcOpts = [] , operators = False , expandSplice = False + , sandbox = Nothing } ---------------------------------------------------------------- From 3d487d0e337ee1e954187c201469e6cb08408b53 Mon Sep 17 00:00:00 2001 From: Paolo Capriotti Date: Mon, 9 Apr 2012 20:43:08 +0100 Subject: [PATCH 2/2] Ignore global package conf when using cabal-dev. --- CabalDev.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CabalDev.hs b/CabalDev.hs index f6deb0b..a76485c 100644 --- a/CabalDev.hs +++ b/CabalDev.hs @@ -34,7 +34,7 @@ findCabalDev Nothing = getCurrentDirectory >>= searchIt . splitPath addPath :: Options -> String -> Options addPath orig_opts path = do let orig_ghcopt = ghcOpts orig_opts - orig_opts { ghcOpts = orig_ghcopt ++ ["-package-conf", path] } + orig_opts { ghcOpts = orig_ghcopt ++ ["-package-conf", path, "-no-user-package-conf"] } searchIt :: [FilePath] -> IO FilePath searchIt [] = throwIO $ userError "Not found"