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 7
7
project = externalInterpreter : project' {
8
8
inherit compiler-nix-name evalPackages ;
9
9
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
+ '' ;
10
17
modules = import ../modules.nix ++ [ ( { pkgs , ...} : lib . optionalAttrs externalInterpreter {
11
18
packages . th-dlls . components . library . ghcOptions = [ "-fexternal-interpreter" ] ;
12
19
# Static openssl seems to fail to load in iserv for musl
Original file line number Diff line number Diff line change
1
+ {-# LANGUAGE CPP #-}
1
2
{-# LANGUAGE TemplateHaskell #-}
2
3
module Lib where
3
4
4
5
import 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
5
10
import OpenSSL (withOpenSSL )
6
11
import OpenSSL.BN (withBN )
12
+ #endif
13
+
14
+ #ifdef MIN_VERSION_libsodium
7
15
import 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
10
19
import Data.Double.Conversion.Text (toShortest )
20
+ #endif
11
21
22
+ #ifdef MIN_VERSION_HsOpenSSL
12
23
x = $ (liftIO (withOpenSSL (withBN 0 (\ _ -> return (LitE (IntegerL 0 ))))))
24
+ #endif
25
+ #ifdef MIN_VERSION_libsodium
13
26
y = $ (liftIO (sodium_init >> return (LitE (IntegerL 0 ))))
27
+ #endif
28
+ #ifdef MIN_VERSION_double_conversion
14
29
z = $ (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
6
6
7
7
build-type : Simple
8
8
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
+
9
24
library
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
21
40
exposed-modules : Lib
22
41
hs-source-dirs : src
23
42
default-language : Haskell2010
You can’t perform that action at this time.
0 commit comments