mirror of
https://github.com/nmattia/snack.git
synced 2024-09-11 11:55:36 +03:00
Use ghc-options in HPack
This commit is contained in:
parent
443bb89c5b
commit
5d4bada51d
@ -34,6 +34,7 @@ in
|
|||||||
mkDeps = obj: dropVersionBounds (optAttr obj "dependencies" []);
|
mkDeps = obj: dropVersionBounds (optAttr obj "dependencies" []);
|
||||||
topDeps = mkDeps package;
|
topDeps = mkDeps package;
|
||||||
topExtensions = optAttr package "default-extensions" [];
|
topExtensions = optAttr package "default-extensions" [];
|
||||||
|
topGhcOpts = optAttr package "ghc-options" [];
|
||||||
packageLib = withAttr package "library" null (component:
|
packageLib = withAttr package "library" null (component:
|
||||||
{ src =
|
{ src =
|
||||||
let
|
let
|
||||||
@ -48,6 +49,7 @@ in
|
|||||||
builtins.toPath "${builtins.toString base}/${source-dirs}";
|
builtins.toPath "${builtins.toString base}/${source-dirs}";
|
||||||
dependencies = topDeps ++ mkDeps component;
|
dependencies = topDeps ++ mkDeps component;
|
||||||
extensions = topExtensions ++ (optAttr component "extensions" []);
|
extensions = topExtensions ++ (optAttr component "extensions" []);
|
||||||
|
ghcOpts = topGhcOpts ++ (optAttr component "ghc-options" []);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -76,7 +78,8 @@ in
|
|||||||
builtins.toPath "${builtins.toString base}/${source-dirs}";
|
builtins.toPath "${builtins.toString base}/${source-dirs}";
|
||||||
dependencies = topDeps ++ dropVersionBounds depOrPack.wrong;
|
dependencies = topDeps ++ dropVersionBounds depOrPack.wrong;
|
||||||
extensions = topExtensions ++ (optAttr component "extensions" []);
|
extensions = topExtensions ++ (optAttr component "extensions" []);
|
||||||
packages = map (_: packageLib) depOrPack.right;
|
ghcOpts = topGhcOpts ++ (optAttr component "ghc-options" []);
|
||||||
|
packages = map (_: packageLib) depOrPack.right;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{ library = packageLib;
|
{ library = packageLib;
|
||||||
|
5
tests/ghc-options/Main.hs
Normal file
5
tests/ghc-options/Main.hs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module Main where
|
||||||
|
|
||||||
|
import Data.Text
|
||||||
|
|
||||||
|
main = putStrLn $ unpack "hello"
|
1
tests/ghc-options/golden
Normal file
1
tests/ghc-options/golden
Normal file
@ -0,0 +1 @@
|
|||||||
|
hello
|
5
tests/ghc-options/package.nix
Normal file
5
tests/ghc-options/package.nix
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{ main = "Main";
|
||||||
|
src = ./.;
|
||||||
|
dependencies = [ "text" ];
|
||||||
|
ghcOpts = ["-XOverloadedStrings"];
|
||||||
|
}
|
9
tests/ghc-options/package.yaml
Normal file
9
tests/ghc-options/package.yaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
name: snack-extensions-test
|
||||||
|
|
||||||
|
ghc-options:
|
||||||
|
- -XOverloadedStrings
|
||||||
|
dependencies:
|
||||||
|
- text
|
||||||
|
executable:
|
||||||
|
main: Main.hs
|
||||||
|
source-dirs: .
|
20
tests/ghc-options/test
Executable file
20
tests/ghc-options/test
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# vim: ft=sh sw=2 et
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
test() {
|
||||||
|
$SNACK build
|
||||||
|
$SNACK run | diff golden -
|
||||||
|
|
||||||
|
TMP_FILE=$(mktemp)
|
||||||
|
|
||||||
|
capture_io "$TMP_FILE" main | $SNACK ghci
|
||||||
|
|
||||||
|
diff golden $TMP_FILE
|
||||||
|
rm $TMP_FILE
|
||||||
|
}
|
||||||
|
|
||||||
|
SNACK="snack --package-file ./package.nix" test
|
||||||
|
SNACK="snack --package-file ./package.nix -l ../../snack-lib" test
|
||||||
|
SNACK="snack --package-file ./package.yaml" test
|
Loading…
Reference in New Issue
Block a user