File tree Expand file tree Collapse file tree 3 files changed +55
-13
lines changed Expand file tree Collapse file tree 3 files changed +55
-13
lines changed Original file line number Diff line number Diff line change 77 project = externalInterpreter : project' {
88 inherit compiler-nix-name evalPackages ;
99 src = testSrc "th-dlls" ;
10+ # TODO figure out why TH breaks with pkgsStatic for `libsodium` and `HsOpenSSL`
11+ # `libsodium` fails with the unhandled ELF relocation(RelA) type 23
12+ # `HsOpenSSL` segfaults in ghcizm9zi12zi2zminplace_GHCiziObjLink_resolveObjs1_info
13+ cabalProjectLocal = lib . optionalString stdenv . hostPlatform . isStatic ''
14+ package th-dlls
15+ flags: -libsodium -openssl
16+ '' ;
1017 modules = import ../modules.nix ++ [ ( { pkgs , ...} : lib . optionalAttrs externalInterpreter {
1118 packages . th-dlls . components . library . ghcOptions = [ "-fexternal-interpreter" ] ;
1219 # Static openssl seems to fail to load in iserv for musl
Original file line number Diff line number Diff line change 1+ {-# LANGUAGE CPP #-}
12{-# LANGUAGE TemplateHaskell #-}
23module Lib where
34
45import Control.Monad.IO.Class (liftIO )
6+ import Language.Haskell.TH.Syntax (Exp (.. ), Lit (.. ))
7+ import Data.Text as T
8+
9+ #ifdef MIN_VERSION_HsOpenSSL
510import OpenSSL (withOpenSSL )
611import OpenSSL.BN (withBN )
12+ #endif
13+
14+ #ifdef MIN_VERSION_libsodium
715import Libsodium (sodium_init )
8- import Language.Haskell.TH.Syntax (Exp (.. ), Lit (.. ))
9- import Data.Text as T
16+ #endif
17+
18+ #ifdef MIN_VERSION_double_conversion
1019import Data.Double.Conversion.Text (toShortest )
20+ #endif
1121
22+ #ifdef MIN_VERSION_HsOpenSSL
1223x = $ (liftIO (withOpenSSL (withBN 0 (\ _ -> return (LitE (IntegerL 0 ))))))
24+ #endif
25+ #ifdef MIN_VERSION_libsodium
1326y = $ (liftIO (sodium_init >> return (LitE (IntegerL 0 ))))
27+ #endif
28+ #ifdef MIN_VERSION_double_conversion
1429z = $ (liftIO (return (LitE (IntegerL (fromIntegral (T. length (toShortest 1.0 )))))))
30+ #endif
Original file line number Diff line number Diff line change @@ -6,18 +6,37 @@ author: Hamish Mackenzie
6677build-type : Simple
88
9+ flag libsodium
10+ description : Enable libsodium support
11+ default : True
12+ manual : True
13+
14+ flag openssl
15+ description : Enable OpenSSL support
16+ default : True
17+ manual : True
18+
19+ flag double-conversion
20+ description : Enable double-conversion support
21+ default : True
22+ manual : True
23+
924library
10- build-depends : base
11- , HsOpenSSL
12- , libsodium
13- , template-haskell
14- , text
15- , double-conversion
16- , unix-time
17- , th-orphans
18- , ghc-prim
19- , math-functions
20- , erf
25+ build-depends :
26+ base
27+ , template-haskell
28+ , text
29+ , unix-time
30+ , th-orphans
31+ , ghc-prim
32+ , math-functions
33+ , erf
34+ if flag(openssl)
35+ build-depends : HsOpenSSL
36+ if flag(libsodium)
37+ build-depends : libsodium
38+ if flag(double-conversion)
39+ build-depends : double-conversion
2140 exposed-modules : Lib
2241 hs-source-dirs : src
2342 default-language : Haskell2010
You can’t perform that action at this time.
0 commit comments