on master help sign in
Pass arguments in attrset
commitbaac8b6a495694dec9335461c19d2f82c97a030a authorAlexandre Esteves <alexandre.fmp.esteves@gmail.com> dateTue 19 May 2020, 00:33 (6 years ago) parent75621c2
1 file changed+21−13
default.nix+21−13
default.nix+21−13
@@ -167,7 +167,7 @@ in rec {
167167
168168 inherit mkAssets;
169169
170− serverExe = backend: frontend: assets: optimizationLevel: bundledConfig: version:
170+ serverExe = { backend, frontend, assets, optimizationLevel, version, bundledConfig }:
171171 pkgs.runCommand "serverExe" {} ''
172172 mkdir $out
173173 set -eux
@@ -317,17 +317,23 @@ in rec {
317317 in allConfig;
318318 in (mkProject (projectDefinition args)).projectConfig);
319319 mainProjectOut = projectOut { inherit system; };
320− serverOn = projectInst: bundledConfig: version: serverExe
321− projectInst.ghc.backend
322− mainProjectOut.ghcjs.frontend
323− projectInst.passthru.staticFiles
324− projectInst.passthru.__closureCompilerOptimizationLevel
325− bundledConfig
326− version;
327− linuxExe = serverOn (projectOut { system = "x86_64-linux"; }) null;
328− ovaExe = serverOn (projectOut { system = "x86_64-linux"; }) (base' + /config);
320+ serverOn = { projectInst, bundledConfig ? null, version } : serverExe {
321+ inherit bundledConfig version;
322+ inherit (projectInst.ghc) backend;
323+ inherit (mainProjectOut.ghcjs) frontend;
324+ assets = projectInst.passthru.staticFiles;
325+ optimizationLevel = projectInst.passthru.__closureCompilerOptimizationLevel;
326+ };
327+ linuxExe = version: serverOn {
328+ inherit version;
329+ projectInst = projectOut { system = "x86_64-linux"; };
330+ };
331+ ovaExe = version: serverOn {
332+ inherit version;
333+ projectInst = projectOut { system = "x86_64-linux"; };
334+ bundledConfig = base' + /config;
335+ };
329336 dummyVersion = "Version number is only available for deployments";
330−
331337 vm = args@{ hostName, adminEmail, routeHost, enableHttps, version, module ? (_:_:{}) }:
332338 mkVM (args // { inherit module; exe = ovaExe version; });
333339
@@ -337,7 +343,6 @@ in rec {
337343 ova = args@{ hostName, adminEmail, routeHost, enableHttps, version, module ? (_: _: {}) }:
338344 (vm args).config.system.build.virtualBoxOVA;
339345 profiledObRun = let
340−
341346 profiled = projectOut { inherit system; enableLibraryProfiling = true; };
342347 exeSource = builtins.toFile "ob-run.hs" ''
343348 module Main where
@@ -369,7 +374,10 @@ in rec {
369374
370375 linuxExeConfigurable = linuxExe;
371376 linuxExe = linuxExe dummyVersion;
372− exe = serverOn mainProjectOut null dummyVersion;
377+ exe = serverOn {
378+ projectInst = mainProjectOut;
379+ version = dummyVersion;
380+ };
373381 server = args@{ hostName, adminEmail, routeHost, enableHttps, version, module ? serverModules.mkBaseEc2 }:
374382 server (args // { exe = linuxExe version; });
375383 obelisk = import (base' + "/.obelisk/impl") {};