on master help sign in
Merge branch 'ts-dont-store-config-wip' into ts-dont-store-config-backup
commit9b38af12c0d7b19a9ade47710225d0bb727cb288 authorLuigy Leon <luichi.19@gmail.com> dateTue 18 Dec 2018, 13:00 (8 years ago) parent019a2b91efa65a
4 files changed+42−26
default.nix+19−18 lib/command/src/Obelisk/Command/Deploy.hs+19−6 lib/command/src/Obelisk/Command/Nix.hs+1 lib/executable-config/default.nix+3−2
default.nix+19−18
@@ -265,8 +265,7 @@ in rec {
265265
266266 # An Obelisk project is a reflex-platform project with a predefined layout and role for each component
267267 project = base: projectDefinition:
268− let configPath = base + "/config";
269− projectOut = sys: (getReflexPlatform sys).project (args@{ nixpkgs, ... }:
268+ let projectOut = sys: (getReflexPlatform sys).project (args@{ nixpkgs, ... }:
270269 let mkProject = { android ? null #TODO: Better error when missing
271270 , ios ? null #TODO: Better error when missing
272271 , packages ? {}
@@ -299,7 +298,21 @@ in rec {
299298 privateConfigDirs = ["config/backend"];
300299 injectableConfig = builtins.filterSource (path: _:
301300 !(lib.lists.any (x: hasPrefix (toString base + "/" + toString x) (toString path)) privateConfigDirs)
302− ) configPath;
301+ );
302+ __android = configPath: {
303+ ${if android == null then null else frontendName} = {
304+ executableName = "frontend";
305+ ${if builtins.pathExists staticFiles then "assets" else null} =
306+ nixpkgs.obeliskExecutableConfig.platforms.android.inject (injectableConfig configPath) processedStatic.symlinked;
307+ } // android;
308+ };
309+ __ios = configPath: {
310+ ${if ios == null then null else frontendName} = {
311+ executableName = "frontend";
312+ ${if builtins.pathExists staticFiles then "staticSrc" else null} =
313+ nixpkgs.obeliskExecutableConfig.platforms.ios.inject (injectableConfig configPath) processedStatic.symlinked;
314+ } // ios;
315+ };
303316 in {
304317 inherit shellToolOverrides tools withHoogle;
305318 overrides = totalOverrides;
@@ -319,21 +332,9 @@ in rec {
319332 commonName
320333 ];
321334 };
322− android = {
323− ${if android == null then null else frontendName} = {
324− executableName = "frontend";
325− ${if builtins.pathExists staticFiles then "assets" else null} =
326− nixpkgs.obeliskExecutableConfig.platforms.android.inject injectableConfig processedStatic.symlinked;
327− } // android;
328− };
329− ios = {
330− ${if ios == null then null else frontendName} = {
331− executableName = "frontend";
332− ${if builtins.pathExists staticFiles then "staticSrc" else null} =
333− nixpkgs.obeliskExecutableConfig.platforms.ios.inject injectableConfig processedStatic.symlinked;
334− } // ios;
335− };
336− passthru = { inherit android ios packages overrides tools shellToolOverrides withHoogle staticFiles staticFilesImpure __closureCompilerOptimizationLevel; };
335+ android = __android null;
336+ ios = __ios null;
337+ passthru = { inherit android ios packages overrides tools shellToolOverrides withHoogle staticFiles staticFilesImpure __closureCompilerOptimizationLevel processedStatic __ios __android; };
337338 };
338339 in mkProject (projectDefinition args));
339340 serverOn = sys: version: serverExe
lib/command/src/Obelisk/Command/Deploy.hs+19−6
@@ -192,6 +192,7 @@ renderPlatformDeployment = \case
192192deployMobile :: MonadObelisk m => PlatformDeployment -> [String] -> m ()
193193deployMobile platform mobileArgs = withProjectRoot "." $ \root -> do
194194 let srcDir = root </> "src"
195+ configDir = root </> "config"
195196 exists <- liftIO $ doesDirectoryExist srcDir
196197 unless exists $ failWith "ob test should be run inside of a deploy directory"
197198 nixBuildTarget <- case platform of
@@ -224,16 +225,28 @@ deployMobile platform mobileArgs = withProjectRoot "." $ \root -> do
224225 Right conf -> do
225226 let nvset = toValue @(HM.HashMap Text (NValueNF Identity)) @Identity @(NValueNF Identity) $ keytoolToAndroidConfig conf
226227 return $ printNix $ runIdentity nvset
228+ let expr = mconcat
229+ [ "with (import ", srcDir, " {});"
230+ , "android.frontend.override (drv: { "
231+ , "releaseKey = (if builtins.isNull drv.releaseKey then {} else drv.releaseKey) // " <> releaseKey <> "; "
232+ , "staticSrc = (passthru.__android ", configDir, ").frontend.staticSrc;"
233+ , "})"
234+ ]
235+ return $ Target
236+ { _target_path = Nothing
237+ , _target_attr = Nothing
238+ , _target_expr = Just expr
239+ }
240+ IOS -> do
241+ let expr = mconcat
242+ [ "with (import ", srcDir, " {});"
243+ , "ios.frontend.override (_: { staticSrc = (passthru.__ios ", configDir, ").frontend.staticSrc; })"
244+ ]
227245 return $ Target
228246 { _target_path = Nothing
229247 , _target_attr = Nothing
230− , _target_expr = Just $ "with (import " <> srcDir <> " {}); " <> renderPlatformDeployment platform <> ".frontend.override (drv: { releaseKey = (if builtins.isNull drv.releaseKey then {} else drv.releaseKey) // " <> releaseKey <> "; })"
248+ , _target_expr = Just expr
231249 }
232− IOS -> return $ Target
233− { _target_path = Nothing
234− , _target_attr = Just "ios.frontend"
235− , _target_expr = Nothing
236− }
237250 result <- nixCmd $ NixCmd_Build $ def
238251 & nixBuildConfig_outLink .~ OutLink_None
239252 & nixCmdConfig_target .~ nixBuildTarget
lib/command/src/Obelisk/Command/Nix.hs+1
@@ -15,6 +15,7 @@ module Obelisk.Command.Nix
1515 , nixCmdConfig_args
1616 , nixCmdConfig_builders
1717 , NixBuildConfig (..)
18+ , nixBuildConfig_common
1819 , nixBuildConfig_outLink
1920 , NixInstantiateConfig (..)
2021 , nixInstantiateConfig_eval
lib/executable-config/default.nix+3−2
@@ -5,17 +5,18 @@
55{ nixpkgs
66, filterGitSource # TODO define this in obelisk
77}:
8−let injectConfig = config: assets: nixpkgs.runCommand "inject-config" {} ''
8+let injectConfig = config: assets: nixpkgs.runCommand "inject-config" {} (''
99 set -x
1010 mkdir -p $out
1111 cp --no-preserve=mode -Lr "${assets}" $out/static
1212 chmod +w "$out"
13+ '' + nixpkgs.lib.optionalString (!(builtins.isNull config)) ''
1314 if ! mkdir $out/config; then
1415 2>&1 echo config directory already exists or could not be created
1516 exit 1
1617 fi
1718 cp -a "${config}"/* "$out/config"
18− '';
19+ '');
1920in with nixpkgs.haskell.lib; {
2021 haskellPackage = self: self.callPackage (filterGitSource ./lookup) {};
2122 platforms = {