on master help sign in
Merge pull request #737 from obsidiansystems/eac@fix-custom-prelude-ob-profile

Fix ob profile to work with custom Prelude

commit19a3e70f4f6f47d8f8f9742757a87f83ec419528 authorElliot Cameron <3noch@users.noreply.github.com> dateTue 19 May 2020, 21:33 (6 years ago) parent37d3550e622515
1 file changed+15−12
default.nix+15−12
default.nix+15−12
@@ -321,29 +321,32 @@ in rec {
321321 __unstable__.profiledObRun = let
322322 profiled = projectOut { inherit system; enableLibraryProfiling = true; };
323323 exeSource = builtins.toFile "ob-run.hs" ''
324+ {-# LANGUAGE NoImplicitPrelude #-}
325+ {-# LANGUAGE PackageImports #-}
324326 module Main where
325327
326− import Control.Exception
327− import Reflex.Profiled
328− import System.Environment
328+ -- Explicitly import Prelude from base lest there be multiple modules called Prelude
329+ import "base" Prelude (IO, (++), read)
329330
330− import qualified Obelisk.Run
331+ import "base" Control.Exception (finally)
332+ import "reflex" Reflex.Profiled (writeProfilingData)
333+ import "base" System.Environment (getArgs)
334+
335+ import qualified "obelisk-run" Obelisk.Run
331336 import qualified Frontend
332337 import qualified Backend
333338
334339 main :: IO ()
335340 main = do
336− args <- getArgs
337− let port = read $ args !! 0
338− assets = args !! 1
339− profileFile = (args !! 2) <> ".rprof"
340− Obelisk.Run.run port (Obelisk.Run.runServeAsset assets) Backend.backend Frontend.frontend `finally` writeProfilingData profileFile
341+ [portStr, assets, profFileName] <- getArgs
342+ Obelisk.Run.run (read portStr) (Obelisk.Run.runServeAsset assets) Backend.backend Frontend.frontend
343+ `finally` writeProfilingData (profFileName ++ ".rprof")
341344 '';
342345 in nixpkgs.runCommand "ob-run" {
343− buildInputs = [ (profiled.ghc.ghcWithPackages (p: [ p.backend p.frontend])) ];
346+ buildInputs = [ (profiled.ghc.ghcWithPackages (p: [p.backend p.frontend])) ];
344347 } ''
345− cp ${exeSource} $PWD/ob-run.hs
346− mkdir -p $out/bin/
348+ cp ${exeSource} ob-run.hs
349+ mkdir -p $out/bin
347350 ghc -x hs -prof -fno-prof-auto -threaded ob-run.hs -o $out/bin/ob-run
348351 '';
349352