From b6bfa31b950f9bce9520a58ca9e6d43fb4438258 Mon Sep 17 00:00:00 2001 From: Nicolas Mattia Date: Sat, 9 Jun 2018 12:37:23 +0200 Subject: [PATCH] Pass in ghc opts everywhere --- snack-lib/default.nix | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/snack-lib/default.nix b/snack-lib/default.nix index d7bb5ff..27d6674 100644 --- a/snack-lib/default.nix +++ b/snack-lib/default.nix @@ -86,10 +86,11 @@ let (dirsByModuleName modName) ) true; - buildModule = ghc: base: mod: + buildModule = ghc: ghcOpts: base: mod: let + ghcOptsArgs = lib.strings.escapeShellArgs ghcOpts; objectName = mod.moduleName; - builtDeps = map (buildModule ghc base) mod.moduleDependencies; + builtDeps = map (buildModule ghc ghcOpts base) mod.moduleDependencies; depsDirs = map (x: x + "/") builtDeps; makeSymtree = if lib.lists.length depsDirs >= 1 @@ -146,6 +147,7 @@ let mkdir -p tmp ghc -tmpdir tmp/ ${moduleToFile mod.moduleName} -c \ -outputdir $out \ + ${ghcOptsArgs} \ 2>&1 echo "Done building module ${mod.moduleName}" ''; @@ -217,7 +219,7 @@ let # Returns an attribute set where the keys are the module names and the values # are the '.o's - flattenModuleObjects = ghc: base: mod': + flattenModuleObjects = ghc: ghcOpts: base: mod': let go = mod: attrs0: let @@ -234,7 +236,7 @@ let then acc else acc // { "${elem.moduleName}" = - "${buildModule ghc base elem}/${objectName elem}"; + "${buildModule ghc ghcOpts base elem}/${objectName elem}"; }; in lib.lists.foldl f attrs1 mod.moduleDependencies; @@ -243,7 +245,7 @@ let # TODO: it's sad that we pass ghcWithDeps + dependencies linkModuleObjects = ghc: ghcOpts: dependencies: base: mod: let - objAttrs = flattenModuleObjects ghc base mod; + objAttrs = flattenModuleObjects ghc ghcOpts base mod; objList = lib.attrsets.mapAttrsToList (x: y: y) objAttrs; ghcOptsArgs = lib.strings.escapeShellArgs ghcOpts; packageList = map (p: "-package ${p}") dependencies;