Commit f3487e08 authored by Marc Coiffier's avatar Marc Coiffier
Browse files

Change the default Curly locations to follow the XDG specification when possible

parent b1bda62f
......@@ -48,7 +48,7 @@ library
AllowAmbiguousTypes
LambdaCase
other-extensions: UndecidableInstances, ScopedTypeVariables, StandaloneDeriving, PatternSynonyms, ViewPatterns, TypeFamilies, CPP, RecursiveDo, GADTs, DeriveGeneric, OverloadedStrings, NoMonomorphismRestriction, DeriveDataTypeable, ExistentialQuantification, BangPatterns
build-depends: AES >=0.2 && <0.3,base >=4.9 && <4.10,base64-bytestring >=1.0 && <1.1,bytestring >=0.10 && <0.11,containers >=0.5 && <0.6,deepseq >=1.4 && <1.5,definitive-base >=2.6 && <2.7,definitive-filesystem >=2.1 && <2.2,definitive-network >=1.4 && <1.5,definitive-parser >=3.1 && <3.2,directory >=1.3 && <1.4,entropy >=0.3 && <0.4,fsnotify >=0.2 && <0.3,network >=2.6 && <2.7,process >=1.4 && <1.5,zlib >=0.6 && <0.7
build-depends: AES >=0.2 && <0.3,base >=4.9 && <4.10,base64-bytestring >=1.0 && <1.1,bytestring >=0.10 && <0.11,containers >=0.5 && <0.6,deepseq >=1.4 && <1.5,definitive-base >=2.6 && <2.7,definitive-filesystem >=2.1 && <2.2,definitive-network >=1.4 && <1.5,definitive-parser >=3.1 && <3.2,directory >=1.3 && <1.4,entropy >=0.3 && <0.4,fsnotify >=0.2 && <0.3,network >=2.6 && <2.7,process >=1.4 && <1.5,zlib >=0.6 && <0.7, xdg-basedir
if flag(paranoid)
ghc-options: -Wall -Werror
hs-source-dirs: src
......
......@@ -10,7 +10,8 @@ module Curly.Core(
-- ** Utilities
c'Expression,syntax,semantic,mapParams,
-- * Environment
envVar,curlyUserDir,curlyKeysFile,curlyCacheDir,curlyCommitDir,curlyPort,
envVar,curlyDataRoot,curlyConfigRoot,curlyCacheRoot,
curlyKeysFile,curlyCacheDir,curlyCommitDir,curlyPort,
-- * Logging facilities
LogLevel(..),LogMessage(..),serialWriteHBytes,addLogCallback,removeLogCallback,withLogCallback,envLogLevel,logLine,logMessage,logAction,trylogLevel,trylog,liftIOLog,cyDebug,
-- * Misc
......@@ -18,23 +19,24 @@ module Curly.Core(
Compressed(..),noCurlySuf,(</>),format
) where
import Definitive
import Language.Format
import Curly.Core.Documentation
import Codec.Compression.Zlib (compress,decompress)
import Control.Concurrent.Chan
import Control.Concurrent (forkIO,MVar,newEmptyMVar,putMVar,readMVar)
import Control.DeepSeq
import Control.Exception (bracket)
import Curly.Core.Documentation
import Data.IORef
import Definitive
import IO.Filesystem ((</>),takeFileName,dropFileName)
import IO.Network.Socket (PortNumber,connect,getAddrInfo)
import Language.Format
import qualified Curly.Core.Security.SHA256 as SHA256
import qualified Data.ByteString.Base64 as Base64
import qualified System.FSNotify as FSNotify
import System.Directory (createDirectoryIfMissing,doesDirectoryExist)
import System.Environment (lookupEnv)
import qualified System.FSNotify as FSNotify
import System.Environment.XDG.BaseDir
import System.IO (openFile,IOMode(AppendMode),hSetBuffering,BufferMode(LineBuffering))
import qualified Data.ByteString.Base64 as Base64
import Codec.Compression.Zlib (compress,decompress)
import Data.IORef
import Control.Concurrent.Chan
import Control.Concurrent (forkIO,MVar,newEmptyMVar,putMVar,readMVar)
import Control.Exception (bracket)
import qualified Curly.Core.Security.SHA256 as SHA256
{-| The type of an expression node
......@@ -187,20 +189,23 @@ curlyDirPath dir = (createDirectoryIfMissing True dir^.thunk)`seq`dir
curlyPort :: PortNumber
curlyPort = fromMaybe 25465 $ matches Just number (envVar "" "CURLY_PORT")
-- | A user-writable directory to store Curly configurations
curlyUserDir :: FilePath
curlyUserDir = curlyDirPath $ envVar "/tmp" "HOME"+"/.curly"
curlyDataRoot :: FilePath
curlyDataRoot = curlyDirPath $ getUserDataDir "curly"^.thunk
curlyConfigRoot :: FilePath
curlyConfigRoot = curlyDirPath $ getUserConfigDir "curly"^.thunk
curlyCacheRoot :: FilePath
curlyCacheRoot = curlyDirPath $ getUserCacheDir "curly"^.thunk
-- | The path of the Curly key wallet
curlyKeysFile :: FilePath
curlyKeysFile = curlyUserDir + "/keys"
curlyKeysFile = curlyDataRoot + "/keys"
-- | The path to the user's cache directory
curlyCacheDir :: FilePath
curlyCacheDir = curlyDirPath $ envVar (curlyUserDir + "/libraries") "CURLY_LIBCACHE"
curlyCacheDir = curlyDirPath $ envVar (curlyCacheRoot + "/libraries") "CURLY_LIBCACHE"
curlyCommitDir :: FilePath
curlyCommitDir = curlyDirPath (curlyUserDir + "/commits")
curlyCommitDir = curlyDirPath (curlyCacheRoot + "/commits")
-- | A Curly log level
data LogLevel = Quiet | Chatty | Verbose | Debug
......
......@@ -44,7 +44,7 @@ main = cli "curly" $ do
let prefixes "" = []
prefixes f = let (h,t) = splitFileName f in f:prefixes (init h)
args <- parseCurlyArgs <$> getArgs
let defaultConfig = curlyUserDir</>"default.curly"
let defaultConfig = curlyConfigRoot</>"default.curly"
do ex <- doesFileExist defaultConfig
unless ex $ do
createFileDirectory defaultConfig
......
{-# LANGUAGE ViewPatterns,TypeFamilies #-}
module Curly.UI(
-- * Variables
curlyPort,curlyUserDir,curlyHistoryFile,
curlyPort,curlyHistoryFile,
-- * Arguments
CurlyConfig,
......@@ -371,7 +371,7 @@ sourceLibs = symList $ fromPList [(p,sourceFile b (f,c) (getFile f^.thunk)) | (p
symList (Join (ModDir l)) = join [symList a <&> l'1 %~ (s:) | (s,a) <- l]
curlyHistoryFile :: String
curlyHistoryFile = curlyUserDir </> "history"
curlyHistoryFile = curlyDataRoot </> "history"
getVCSBranches :: MonadIO m => String -> m StampedBranches
getVCSBranches name = liftIO $ do
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment