Skip to main content

Install Pandoc via Cabal OpenBSD 6.7

Install Cabal

UsingCabal cabalis ona OpenBSD Quick rundownpackagemanager for usingHaskell very much like pip is for Python. You can install it from ports:

doas pkg_add -i ghc cabal-install

Prepare system to compile programs via cabal

Enable wxallowed in a/home W^X'dand world. Posted on Tue, 12 Sep 2017 16:35:00 MDT by Aaron Bieber Tags: OpenBSD, Software, Haskell/tmp:

SinceYou W^Xcan becamedo mandatoryso via editing your /etc/fstab like this (this is my personal fstab. don't blindly copy paste, you have to insert the wxallowed in OpenBSD,the W^X’right place in your own /etc/fstab.

.b none swap sw
.a / ffs rw,softdep,noatime 1 1
.k /home ffs rw,softdep,wxallowed,noatime,nodev,nosuid 1 2
.d binaries/tmp areffs onlyrw,softdep,wxallowed,noatime,nodev,nosuid allowed1 to2
be.f executed/usr fromffs designatedrw,softdep,wxallowed,noatime,nodev locations1 2
.g /usr/X11R6 ffs rw,softdep,noatime,nodev 1 2
.h /usr/local ffs rw,softdep,wxallowed,noatime,nodev 1 2
.j /usr/obj ffs rw,softdep,noatime,wxallowed,nodev,nosuid 1 2
.i /usr/src ffs rw,softdep,noatime,nodev,nosuid 1 2
.e /var ffs rw,softdep,noatime,nodev,nosuid 1 2

then reboot.

(mountoptional) points).enable multithreating

If you usedwant theto autoenable partitionhyperthreating layouttempoary, duringdo:

install,
doas sysctl hw.smt=1

if you want to make it permanent edit your /usr/local/etc/sysctl.conf and paste the following at the end:

hw.smt=1

notice: without rebooting you have once to enable it manually, after the fist reboot, it will be mounted with wxallowed. For example, here is the entry for my current machine:active

sysctl hw.smt=1

you can check that hyperthreating is active, with programs like top or htop

raise ulimit:

put the following into your

~/dev/sd2g.profile
on
ulimit -d 4096*1024

If you haven't relogged, you have to manually paste this everytime you open a terminal in which you want to compile, since it's a command for your shell.

ulimit -d 4096*1024

Correct you PATH

edit this into you .profile

PATH=$HOME/bin:/bin:/sbin:/usr/localbin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/usr/games:$HOME/.cabal/bin/:.
type
ffs

install pandoc or pandoc-citeproc

if you want to convert LATEX you probably want pandoc-citeproc, it automatically pulls pandoc as dependency:

as a user (local,not nodev,root) wxallowed,execute:

softdep)
ulimit -d 4096*1024
cabal update
cabal install pandoc-citeproc

This iswill need a great feature, but if you build applications outsidelot of thetime wxallowedand partition, you are goingresources to run into some issues, especially in the case of cabal (python as well).

Here is an example of what you would see when attempting to do cabal install pandoc:

qbit@slip[1]:~λ cabal update
Config file path source is default config file.
Config file /home/qbit/.cabal/config not found.
Writing default configuration to /home/qbit/.cabal/config
Downloading the latest package list from hackage.haskell.org
qbit@slip[0]:~λ cabal install pandoc
Resolving dependencies...
.....
cabal: user error (Error: some packages failed to install:
JuicyPixels-3.2.8.3 failed during the configure step. The exception was:
/home/qbit/.cabal/setup-exe-cache/setup-Simple-Cabal-1.22.5.0-x86_64-openbsd-ghc-7.10.3: runProcess: runInteractiveProcess: exec: permission denied (Permission denied)

The error isn’t actually what it says. The untrained eye would assume permissions issue. A quick check of dmesg reveals what is really happening:

/home/qbit/.cabal/setup-exe-cache/setup-Simple-Cabal-1.22.5.0-x86_64-openbsd-ghc-7.10.3(22924): W^X binary outside wxallowed mountpoint

OpenBSD is killing the above binary because it is violating W^X and hasn’t been safely kept in its /usr/local corral!

We could solve this problem quickly by marking our /home as wxallowed, however, this wouldcompile, be heavypacient. handed and reckless (we don’t want to allow other potentially unsafe binaries to execute.. just the cabal stuff).

Instead, we will build all our cabal stuff in /usr/local by using a symlink!

doas mkdir -p /usr/local/{cabal,cabal/build} # make our cabal and build dirs
doas chown -R user:wheel /usr/local/cabal    # set perms
rm -rf ~/.cabal                              # kill the old non-working cabal
ln -s /usr/local/cabal ~/.cabal              # link it!

We are almost there! Some cabal packages build outside of ~/.cabal:

cabal install hakyll
.....
Building foundation-0.0.14...                                                   Preprocessing library foundation-0.0.14...
hsc2hs: dist/build/Foundation/System/Bindings/Posix_hsc_make: runProcess: runInteractiveProcess: exec: permission denied (Permission denied)
Downloading time-locale-compat-0.1.1.3...
.....

Fortunately, all of the packages I have come across that do this all respect the TMPDIR environment variable!

alias cabal='env TMPDIR=/usr/local/cabal/build/ cabal'

With this alias, youPandoc should now be able to cabalbe withoutcompiled.

issue

After (socompilation faris pandoc,finished, shellcheckdon't be surpised if nothing happens when you execute pandoc and hakyll/ or getting an error, read clearly, you may have allthe builtbinary fine)!successfully TL;DRcompiled and it just couldn't symlink. you probably can find pandoc in:

~/.cabal/bin/pandoc

if nothig happens when you execute this binary, it probably does work as inteded anyways, try to give it an argument like:

# This assumes /usr/local/ is mounted as wxallowed.
#
doas mkdir -p /usr/local/{cabal,cabal/build}
doas chown -R user:wheel /usr/local/cabal
rm -rf ~/.cabal
lncabal/bin/pandoc -s /usr/local/cabal ~/.cabal
alias cabal='env TMPDIR=/usr/local/cabal/build/ cabal'
cabal install pandocv

Congratulations! You have successfully compiled and installed pandoc in OpenBSD