forked from purescript/purescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSetup.hs
38 lines (31 loc) · 1.14 KB
/
Setup.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{-# LANGUAGE CPP #-}
#ifndef POSIX_LIKE
#define POSIX_LIKE !(defined(_WIN32_HOST_OS) || defined(_WIN64_HOST_OS)) && \
(defined(unix_HOST_OS) || defined(__unix___HOST_OS) || \
defined(__unix_HOST_OS) || defined(linux_HOST_OS) || \
defined(__linux___HOST_OS) || defined(__linux_HOST_OS) || \
(defined(__APPLE___HOST_OS) && defined(__MACH___HOST_OS)))
#endif
module Main where
import Control.Monad
import Distribution.PackageDescription
import Distribution.Simple
import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.Setup
import System.Directory
import System.Environment.XDG.BaseDir
#if POSIX_LIKE
import System.Posix.Files
#endif
main :: IO ()
main = defaultMainWithHooks $ simpleUserHooks {postInst = setupXDG}
setupXDG :: Args -> InstallFlags -> PackageDescription -> LocalBuildInfo -> IO ()
setupXDG _ _ _ _ = do
configDir <- getUserConfigDir "purescript"
configExists <- doesDirectoryExist configDir
unless configExists $ do
createDirectoryIfMissing True configDir
#if POSIX_LIKE
setFileMode configDir ownerModes
#endif
#undef POSIX_LIKE