This build is a mix of several methods, with the addition of some simple management scripts to help with adding new packages. The stack development environment manager is geared towards projects, which makes it a little awkward for a more open-ended case like an IHaskell notebook environment. As has been stated many times in many forums, "Stack is not a package manager," so we have to pick up the slack.
The biggest problem is that, for some packages that require dependencies outside of the curated Stackage system, we must add specific versions from Hackage to the extra-deps section of stack.yaml. This is easy enough with sed, but changing stack.yaml also has the effect of resetting things so that the next stack build will make many currently built packages inaccessible (their builds are still cached, but they cannot be imported).
In order to get around this and have the effect of 'adding' packages to our current setup, we need to keep a list of currently installed packages, add to that, and then rebuild the whole environment. To accomplish this:
The global stack.yaml is initialized to a reasonable state for IHaskell.
The script stack-add-deps.sh is provided. Run with a list of versioned Hackage packages, and it will insert them into the extra-deps section of stack.yaml.
The file /opt/stack/build.list has the set of packages to build.
The file /opt/stack/install.list has packages with binaries to make globally available (i.e. they can be run directly in Bash).
The script update.sh reads the two lists above, and makes the current state of the environment match what they say.
The workflow is thus:
echo <new packages> >> /opt/stack/build.list
echo <new global binaries> >> /opt/stack/install.list (optional)
This environment is used for compilation, and also as a base for the install. Kept minimal so that it can be rebuilt and an existing Stack/Haskell compilation carried over via tarfile, eliminating recompilation for small changes.
Clone and install IHaskell, and copy its resolver to global stack.yaml.
git clone https://github.com/gibiansky/IHaskell
IHaskell Build (Bash)
Insert IHaskell deps and suchlike. All the IHaskell packages are listed as extra-deps rather than packages, because we never want to build anything automatically, we always want to select exactly what we build for the IHaskell notebook environment. For example, `stack ghci` tries to load every package listed in `packages`, and we don't want that behavior. Several of these packages are unbuildable at the time of this writing.
See the Dockerfile for the list of packages which are pre-built into the Docker image.