1
1
mirror of https://github.com/nmattia/snack.git synced 2024-11-28 03:45:45 +03:00

Fix nested modules

This commit is contained in:
Nicolas Mattia 2018-07-25 20:43:32 +02:00
parent 89f6c30aa0
commit c5c04957be
6 changed files with 24 additions and 7 deletions

View File

@ -117,9 +117,16 @@ rec {
};
phases =
[ "unpackPhase" "buildPhase" ];
imports = map (mmm: mmm.moduleName) modSpec.moduleImports;
buildPhase =
''
echo "Building module ${modSpec.moduleName}"
echo "Local imports are:"
for foo in $imports; do
echo " - $foo"
done
mkdir -p $out
echo "Creating dependencies symtree for module ${modSpec.moduleName}"
${makeSymtree}
@ -132,6 +139,8 @@ rec {
-outputdir $out \
${ghcOptsArgs} \
2>&1
ls $out
echo "Done building module ${modSpec.moduleName}"
'';

View File

@ -12,7 +12,7 @@ rec {
basePrefix = (builtins.toString base) + "/";
pred = file: path: type:
let
actual = (lib.strings.removePrefix basePrefix path);
actual = lib.strings.removePrefix basePrefix path;
expected = file;
in
(expected == actual) ||
@ -20,11 +20,19 @@ rec {
# TODO: even though we're doing a lot of cleaning, there's sitll some
# 'does-file-exist' happening
src0 = lib.cleanSource base;
name = # Makes the file name derivation friendly
lib.stringAsChars
(x:
if x == "/" then "_"
else if builtins.isNull (builtins.match "[a-zA-Z0-9.+=-_?]" x)
then ""
else x
) file;
in stdenv.mkDerivation {
name = file;
inherit name;
src = lib.cleanSourceWith { filter = (pred file); src = src0; };
builder = writeScript (file + "-single-out")
builder = writeScript (name + "-single-out")
# TODO: make sure the file actually exists and that there's only one
''
echo "Singling out file ${file}"

View File

@ -2,5 +2,5 @@ name: snack-packages-test
dependencies:
- conduit
executable:
main: Foo/Foo.hs
main: Bar/Foo.hs
source-dirs: src

View File

@ -1,4 +1,4 @@
{ main = "Foo.Foo";
{ main = "Bar.Foo";
src = ./src;
dependencies = ["conduit"];
}

View File

@ -1,5 +1,5 @@
import Conduit
import FooBar
import Bar.FooBar
main :: IO ()
main = runConduit $ spitOut .| takeC 5 .| digest

View File

@ -1,4 +1,4 @@
module FooBar where
module Bar.FooBar where
import Conduit