Skip to content

Commit 3b63abc

Browse files
committed
use $KOKA_ROOT by default in the interpreter
1 parent 88ce64b commit 3b63abc

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/Compile/Options.hs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ import Data.Hashable
4040
import Control.Monad ( when )
4141
import Control.Concurrent ( myThreadId )
4242
import qualified System.Info ( os, arch )
43-
import System.Environment ( getArgs )
44-
import System.Directory ( doesFileExist, doesDirectoryExist, getHomeDirectory, getTemporaryDirectory, getXdgDirectory, XdgDirectory(XdgCache) )
43+
import System.Environment ( getArgs, lookupEnv )
44+
import System.Directory ( doesFileExist, doesDirectoryExist, getHomeDirectory, getTemporaryDirectory, getXdgDirectory, XdgDirectory(XdgData) )
4545
import Platform.GetOptions
4646
import Platform.Config
4747
import Lib.PPrint
@@ -905,8 +905,15 @@ getKokaBuildDir "" eval
905905
then return kkbuild
906906
else do -- avoid the tmp directory as it does not always have execute permissions
907907
-- tmp <- getTemporaryDirectory
908-
-- instead use `$XDG_DATA_HOME/koka` if in the interpreter
909-
getXdgDirectory XdgData "koka"
908+
-- if in the interpreter, use the user-defined $KOKA_ROOT, if it doesn't exist
909+
-- fall back to `$XDG_DATA_HOME/kkbuild`
910+
root <- lookupEnv "KOKA_ROOT"
911+
case root of
912+
Nothing ->
913+
getXdgDirectory XdgData "kkbuild"
914+
Just path ->
915+
return path
916+
910917
else return kkbuild
911918
getKokaBuildDir buildDir _ = return buildDir
912919

0 commit comments

Comments
 (0)