Take a look at the
os_HOST_OS
flags in combination with the C preprocessor option-cpp
(or using{-# LANGUAGE CPP #-}
) as stated in the GHC documentationAdd
extensions: CPP
to your package description as shown in the Cabal documentation and define a custom flag like this:if os(linux) cpp-options: -DINOTIFY if os(darwin) cpp-options: -DKQUEUE
You can then use #ifdef
in your source.