yellowtides/owenbot-hs

Make Owen portable

jacobjwalters opened this issue · 3 comments

Currently, we assume a POSIX-compliant system in a few places. It'd be nice if we could support Windows also, as this would allow those who do not have WSL/access to a Unix system to help contribute.

We rely on POSIX features in:

  • :instance (with getProcessID)
  • :update (we assume a shell with && for command sequencing)

Providing a generic getProcessID should be fairly simple. The idea is to add a new file that abstracts over OS differences using the CPP extension, which allows us to use the C Pre-Processor to conditionally import a library.

Replacing the chained call in update should be fairly simple, as I believe that System.Process provides methods to choose where to spawn a process.

Additionally, we depend on the following (Unix) utilities

  • git
  • cd (note that this is a shell built-in, and thus can't be installed!)
  • fortune
  • cowsay
  • sh (implicitly in :update)

Fixing the above would remove the sh and cd dependencies, but the others are hard dependencies of owen features, so short of reimplementing them in Haskell we're stuck with them.

Conditionally enabling these features by using #29 would perhaps be the most elegant way of handling this.

As it is expected Git and Stack would be installed if they are doing Haskell stuff on Windows (sorry pure cabal users), we should be fine with those two. cd is universal and works with the same syntax. && works as expected (it executes the second command only if the first was successful).

&& does rely on a POSIX-compliant shell though. That should be fairly easy to fix though (since the idiomatic way of doing so would be chaining Process.spawnCommand calls in an IO monad (there's a version of Process.spawnCommand that accepts a working directory IIRC)

This is almost very nearly complete, but the git repo is hardcoded to ~/owenbot.hs, meaning that :update won't work on Windows (and likewise, it won't be able to find the git info at startup).

In the future, this will get moved to a config file.

Since this is mostly for convenience with the production instance (which runs on Linux), it's not a big problem. Closing this issue.