@@ -80,48 +80,30 @@ you'll get config compilation errors due to missing modules.
8080To sandbox, navigate to your source yi directory. For me it's
8181` ~/programming/yi/yi ` .
8282
83- Once there, run ` cabal sandbox init ` as you normally would, then
84- ` cabal install ` . Now check your ` .cabal-sandbox ` directory. You should
85- see a bunch of files but we're looking for the directory storing all
86- the sandboxed packages. For me, it's
87- ` i386-linux-ghc-7.6.3-packages.conf.d ` . If you ` cabal install ` with
88- different versions of the compiler, you might have more than one of
89- these directories. I also have
90- ` i386-linux-ghc-7.9.20140129-packages.conf.d ` . This is important if
91- you want to work on Yi with multiple compiler versions but most people
92- will only have a single such directory.
93-
94- Next, we need to somehow tell Yi/GHC where to look for these packages
95- when compiling our config. Thankfully, a ` GHC_PACKAGE_PATH ` environment
96- variable can do just that, in combination with passing the ` -package-db ` option
97- through to ghc. Here's mine, called ` runyi ` that I put in my ` $PATH ` for easy
98- access:
83+ We then setup a cabal sandbox following instructions from the
84+ [ cabal userguide] ( http://www.haskell.org/cabal/users-guide/installing-packages.html#sandboxes-basic-usage ) :
85+
86+ ```
87+ $ cabal sandbox init
88+ $ cabal install --only-dependencies
89+ $ cabal build
90+ ```
91+
92+ From cabal-install 1.20, Yi can be launched in an environment using the
93+ sandbox's package DB using ` cabal exec dist/build/Yi/yi ` . It may be useful
94+ to create an alias or small script for this, along the lines of:
9995
10096```
10197#!/bin/bash
102- SANDBOX_DB=$HOME/programming/yi/yi/.cabal-sandbox/i386-linux-ghc-7.6.3-packages.conf.d
103- export GHC_PACKAGE_PATH=$SANDBOX_DB:/usr/lib/ghc-7.6.3/package.conf.d
104- $HOME/programming/yi/yi/.cabal-sandbox/bin/yi --ghc-option="-package-db $SANDBOX_DB" "$@"
98+ YI_DIR=$HOME/programming/yi/yi
99+ env CABAL_SANDBOX_CONFIG=$YI_DIR/cabal.sandbox.config cabal exec $YI_DIR/dist/build/Yi/yi "$@"
105100```
106101
107- What it does is it sets ` GHC_PACKAGE_PATH ` to the directory we have
108- found inside ` .cabal-sandbox ` earlier and then runs the ` yi ` binary
109- which is also in the sandbox. The ` "$@" ` part means that all the
102+ The ` "$@" ` part means that all the
110103arguments we pass to this script are passed on to the Yi binary which
111104means we can still use all the regular flags, such as `runyi
112105--as=emacs`. Of course, you'll need to adjust the paths used to match
113- your sandbox and package directories. Pick the version that your
114- compiler is going to be when running Yi.
115-
116- Note that cabal sandboxes still inherit some packages (such as ` base ` ) from the
117- global package database, so it is necessary to include the global package
118- (` /usr/lib/ghc-7.6.3/package.conf.d ` in the example above) directory in
119- ` GHC_PACKAGE_PATH ` . The path may vary per system, and can be found with a
120- command like:
121-
122- ```
123- find / -name package.conf.d 2>/dev/null
124- ```
106+ your sandbox and package directories.
125107
126108There's one more thing to mention in this section and that is config
127109dependencies. One of the great things about Yi is that we have access
@@ -140,6 +122,10 @@ patched version, you'll have to use `cabal sandbox add-source`
140122command. As an example, I'm developing a ` yi-haskell-utils ` package
141123and my config depends on it. To accommodate for this, I ran `cabal
142124sandbox add-source ~ /programming/yi-haskell-utils`.
125+ You can then ` cabal install yi-haskell-utils ` to add the package to
126+ the sandbox. You should call ` cabal build ` in the sandbox directory
127+ after you modify a local package so that the sandbox has an up-to-date
128+ version of the package.
143129
144130I suspect that it'd be perfectly possible to make your config file
145131into a cabal project and manage the dependencies that way but I have
0 commit comments