on master help sign in
Merge branch 'eac@make-project-out-extensible' into eac@wrinkl-tweaks
91e497e3noch
default.nix+35−34
@@ -328,40 +328,39 @@ in rec {
328 });
328 });
329 in allConfig;
329 in allConfig;
330 in (mkProject (projectDefinition args)).projectConfig);
330 in (mkProject (projectDefinition args)).projectConfig);
331− mainProjectOut = projectOut { inherit system; };
331+ projectOutHost = projectOut { inherit system; };
332 serverOn = projectInst: version: serverExe
332 serverOn = projectInst: version: serverExe
333 projectInst.ghc.backend
333 projectInst.ghc.backend
334− mainProjectOut.ghcjs.frontend
334+ projectOutHost.ghcjs.frontend
335 projectInst.passthru.staticFiles
335 projectInst.passthru.staticFiles
336 projectInst.passthru.__closureCompilerOptimizationLevel
336 projectInst.passthru.__closureCompilerOptimizationLevel
337 version;
337 version;
338− linuxExe = serverOn (projectOut { system = "x86_64-linux"; });
339 dummyVersion = "Version number is only available for deployments";
338 dummyVersion = "Version number is only available for deployments";
340− in mainProjectOut // {
341− __unstable__.profiledObRun = let
339+ profiledObRun =
340+ let
342− profiled = projectOut { inherit system; enableLibraryProfiling = true; };
341+ profiled = projectOut { inherit system; enableLibraryProfiling = true; };
343− exeSource = builtins.toFile "ob-run.hs" ''
342+ exeSource = builtins.toFile "ob-run-profiled.hs" ''
344− {-# LANGUAGE NoImplicitPrelude #-}
343+ {-# LANGUAGE NoImplicitPrelude #-}
345− {-# LANGUAGE PackageImports #-}
344+ {-# LANGUAGE PackageImports #-}
346− module Main where
345+ module Main where
347−
346+
348− -- Explicitly import Prelude from base lest there be multiple modules called Prelude
347+ -- Explicitly import Prelude from base lest there be multiple modules called Prelude
349− import "base" Prelude (IO, (++), read)
348+ import "base" Prelude (IO, (++), read)
350−
349+
351− import "base" Control.Exception (finally)
350+ import "base" Control.Exception (finally)
352− import "reflex" Reflex.Profiled (writeProfilingData)
351+ import "reflex" Reflex.Profiled (writeProfilingData)
353− import "base" System.Environment (getArgs)
352+ import "base" System.Environment (getArgs)
354−
353+
355− import qualified "obelisk-run" Obelisk.Run
354+ import qualified "obelisk-run" Obelisk.Run
356− import qualified Frontend
355+ import qualified Frontend
357− import qualified Backend
356+ import qualified Backend
358−
357+
359− main :: IO ()
358+ main :: IO ()
360− main = do
359+ main = do
361− [portStr, assets, profFileName] <- getArgs
360+ [portStr, assets, profFileName] <- getArgs
362− Obelisk.Run.run (read portStr) (Obelisk.Run.runServeAsset assets) Backend.backend Frontend.frontend
361+ Obelisk.Run.run (read portStr) (Obelisk.Run.runServeAsset assets) Backend.backend Frontend.frontend
363− `finally` writeProfilingData (profFileName ++ ".rprof")
362+ `finally` writeProfilingData (profFileName ++ ".rprof")
364− '';
363+ '';
365 in nixpkgs.runCommand "ob-run" {
364 in nixpkgs.runCommand "ob-run" {
366 buildInputs = [ (profiled.ghc.ghcWithPackages (p: [p.backend p.frontend])) ];
365 buildInputs = [ (profiled.ghc.ghcWithPackages (p: [p.backend p.frontend])) ];
367 } ''
366 } ''
@@ -369,14 +368,16 @@ in rec {
369 mkdir -p $out/bin
368 mkdir -p $out/bin
370 ghc -x hs -prof -fno-prof-auto -threaded ob-run.hs -o $out/bin/ob-run
369 ghc -x hs -prof -fno-prof-auto -threaded ob-run.hs -o $out/bin/ob-run
371 '';
370 '';
372−
371+ in projectOutHost // lib.makeExtensible (self: {
373− linuxExeConfigurable = linuxExe;
372+ __unstable__.profiledObRun = profiledObRun;
374− linuxExe = linuxExe dummyVersion;
373+ exeConfigurable = { system, version }: serverOn (projectOut { inherit system; }) version;
375− exe = serverOn mainProjectOut dummyVersion;
374+ exe = self.exeConfigurable { inherit system; version = dummyVersion; };
375+ linuxExeConfigurable = version: self.exeConfigurable { system = "x86_64-linux"; inherit version; };
376+ linuxExe = self.linuxExeConfigurable dummyVersion;
376 server = args@{ hostName, adminEmail, routeHost, enableHttps, version, module ? serverModules.mkBaseEc2 }:
377 server = args@{ hostName, adminEmail, routeHost, enableHttps, version, module ? serverModules.mkBaseEc2 }:
377− server (args // { exe = linuxExe version; });
378+ server (args // { exe = self.linuxExeConfigurable version; });
378 obelisk = import (base' + "/.obelisk/impl") {};
379 obelisk = import (base' + "/.obelisk/impl") {};
379− };
380+ });
380 haskellPackageSets = {
381 haskellPackageSets = {
381 inherit (reflex-platform) ghc ghcjs;
382 inherit (reflex-platform) ghc ghcjs;
382 };
383 };