on master help sign in
Checkpoint
commit2dcdabe62ea7b0ed9fb767884987e2cd82de8e4a authorLuigy Leon <luichi.19@gmail.com> dateMon 19 Nov 2018, 13:08 (8 years ago) parent1bb4438
5 files changed+43−27
default.nix+19−18 lib/command/src/Obelisk/Command.hs+7−6 lib/command/src/Obelisk/Command/Deploy.hs+13−1 lib/command/src/Obelisk/Command/Nix.hs+1 lib/executable-config/default.nix+3−2
default.nix+19−18
@@ -260,8 +260,7 @@ in rec {
260260
261261 # An Obelisk project is a reflex-platform project with a predefined layout and role for each component
262262 project = base: projectDefinition:
263− let configPath = base + "/config";
264− projectOut = sys: (getReflexPlatform sys).project (args@{ nixpkgs, ... }:
263+ let projectOut = sys: (getReflexPlatform sys).project (args@{ nixpkgs, ... }:
265264 let mkProject = { android ? null #TODO: Better error when missing
266265 , ios ? null #TODO: Better error when missing
267266 , packages ? {}
@@ -294,7 +293,21 @@ in rec {
294293 privateConfigDirs = ["config/backend"];
295294 injectableConfig = builtins.filterSource (path: _:
296295 !(lib.lists.any (x: hasPrefix (toString base + "/" + toString x) (toString path)) privateConfigDirs)
297− ) configPath;
296+ );
297+ __android = configPath: {
298+ ${if android == null then null else frontendName} = {
299+ executableName = "frontend";
300+ ${if builtins.pathExists staticFiles then "assets" else null} =
301+ nixpkgs.obeliskExecutableConfig.platforms.android.inject (injectableConfig configPath) processedStatic.symlinked;
302+ } // android;
303+ };
304+ __ios = configPath: {
305+ ${if ios == null then null else frontendName} = {
306+ executableName = "frontend";
307+ ${if builtins.pathExists staticFiles then "staticSrc" else null} =
308+ nixpkgs.obeliskExecutableConfig.platforms.ios.inject (injectableConfig configPath) processedStatic.symlinked;
309+ } // ios;
310+ };
298311 in {
299312 inherit shellToolOverrides tools withHoogle;
300313 overrides = totalOverrides;
@@ -314,21 +327,9 @@ in rec {
314327 commonName
315328 ];
316329 };
317− android = {
318− ${if android == null then null else frontendName} = {
319− executableName = "frontend";
320− ${if builtins.pathExists staticFiles then "assets" else null} =
321− nixpkgs.obeliskExecutableConfig.platforms.android.inject injectableConfig processedStatic.symlinked;
322− } // android;
323− };
324− ios = {
325− ${if ios == null then null else frontendName} = {
326− executableName = "frontend";
327− ${if builtins.pathExists staticFiles then "staticSrc" else null} =
328− nixpkgs.obeliskExecutableConfig.platforms.ios.inject injectableConfig processedStatic.symlinked;
329− } // ios;
330− };
331− passthru = { inherit android ios packages overrides tools shellToolOverrides withHoogle staticFiles staticFilesImpure __closureCompilerOptimizationLevel; };
330+ android = __android null;
331+ ios = __ios null;
332+ passthru = { inherit android ios packages overrides tools shellToolOverrides withHoogle staticFiles staticFilesImpure __closureCompilerOptimizationLevel processedStatic __ios __android; };
332333 };
333334 in mkProject (projectDefinition args));
334335 serverOn = sys: version: serverExe
lib/command/src/Obelisk/Command.hs+7−6
@@ -142,8 +142,8 @@ deployCommand cfg = hsubparser $ mconcat
142142 ]
143143 where
144144 platformP = hsubparser $ mconcat
145− [ command "android" $ info (pure Android) mempty
146− , command "ios" $ info (pure IOS <*> strArgument (metavar "TEAMID" <> help "Your Team ID - found in the Apple developer portal")) mempty
145+ [ command "android" $ info (pure (Android, [])) mempty
146+ , command "ios" $ info ((,) <$> pure IOS <*> strArgument (metavar "TEAMID" <> help "Your Team ID - found in the Apple developer portal")) mempty
147147 ]
148148
149149 remoteBuilderParser :: Parser (Maybe RemoteBuilder)
@@ -173,7 +173,7 @@ deployInitOpts = DeployInitOpts
173173 <*> flag True False (long "disable-https" <> help "Disable automatic https configuration for the backend")
174174
175175type TeamID = String
176−data PlatformDeployment = Android | IOS TeamID
176+data PlatformDeployment = Android | IOS
177177 deriving (Show)
178178
179179data RemoteBuilder = RemoteBuilder_ObeliskVM
@@ -182,7 +182,7 @@ data RemoteBuilder = RemoteBuilder_ObeliskVM
182182data DeployCommand
183183 = DeployCommand_Init DeployInitOpts
184184 | DeployCommand_Push (Maybe RemoteBuilder)
185− | DeployCommand_Test PlatformDeployment
185+ | DeployCommand_Test (PlatformDeployment, [String])
186186 | DeployCommand_Update
187187 deriving Show
188188
@@ -341,8 +341,9 @@ ob = \case
341341 Nothing -> pure []
342342 Just RemoteBuilder_ObeliskVM -> (:[]) <$> VmBuilder.getNixBuildersArg
343343 DeployCommand_Update -> deployUpdate "."
344− DeployCommand_Test Android -> deployMobile "android" []
345− DeployCommand_Test (IOS teamID) -> deployMobile "ios" [teamID]
344+ DeployCommand_Test (platform, args) -> deployMobile platform args
345+ -- DeployCommand_Test Android -> deployMobile "__android" []
346+ -- DeployCommand_Test (IOS teamID) -> deployMobile "__ios" [teamID]
346347 ObCommand_Run -> inNixShell' $ static run
347348 -- inNixShell ($(mkClosure 'ghcidAction) ())
348349 ObCommand_Thunk tc -> case tc of
lib/command/src/Obelisk/Command/Deploy.hs+13−1
@@ -160,9 +160,21 @@ deployUpdate deployPath = updateThunkToLatest $ deployPath </> "src"
160160deployMobile :: MonadObelisk m => String -> [String] -> m ()
161161deployMobile platform mobileArgs = withProjectRoot "." $ \root -> do
162162 let srcDir = root </> "src"
163+ configDir = root </> "config"
163164 exists <- liftIO $ doesDirectoryExist srcDir
164165 unless exists $ failWith "ob test should be run inside of a deploy directory"
165− result <- nixBuildAttrWithCache srcDir $ platform <> ".frontend"
166+ -- result <- nixBuildAttrWithCache srcDir $ platform <> ".frontend"
167+ let expr = mconcat
168+ [ "with (import ", srcDir, " {});"
169+ -- , "android.frontend.override (_: { staticSrc = (passthru.__android ", configDir, ").frontend.staticSrc; })"
170+ , "ios.frontend.override (_: { staticSrc = (passthru.__ios ", configDir, ").frontend.staticSrc; })"
171+ ]
172+ target = Target
173+ { _target_path = Nothing
174+ , _target_attr = Nothing
175+ , _target_expr = Just expr
176+ }
177+ result <- nixCmd $ NixCmd_Build $ def & nixBuildConfig_common .~ (def & nixCmdConfig_target .~ target)
166178 callProcessAndLogOutput (Notice, Error) $ proc (result </> "bin" </> "deploy") mobileArgs
167179
168180-- | Simplified deployment configuration mechanism. At one point we may revisit this.
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 = {