on master help sign in
Checkpoint
2dcdabeLuigy Leon
default.nix+19−18
@@ -260,8 +260,7 @@ in rec {
260
260
261 # An Obelisk project is a reflex-platform project with a predefined layout and role for each component
261 # An Obelisk project is a reflex-platform project with a predefined layout and role for each component
262 project = base: projectDefinition:
262 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, ... }:
265 let mkProject = { android ? null #TODO: Better error when missing
264 let mkProject = { android ? null #TODO: Better error when missing
266 , ios ? null #TODO: Better error when missing
265 , ios ? null #TODO: Better error when missing
267 , packages ? {}
266 , packages ? {}
@@ -294,7 +293,21 @@ in rec {
294 privateConfigDirs = ["config/backend"];
293 privateConfigDirs = ["config/backend"];
295 injectableConfig = builtins.filterSource (path: _:
294 injectableConfig = builtins.filterSource (path: _:
296 !(lib.lists.any (x: hasPrefix (toString base + "/" + toString x) (toString path)) privateConfigDirs)
295 !(lib.lists.any (x: hasPrefix (toString base + "/" + toString x) (toString path)) privateConfigDirs)
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+ };
297− ) configPath;
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+ };
298 in {
311 in {
299 inherit shellToolOverrides tools withHoogle;
312 inherit shellToolOverrides tools withHoogle;
300 overrides = totalOverrides;
313 overrides = totalOverrides;
@@ -314,21 +327,9 @@ in rec {
314 commonName
327 commonName
315 ];
328 ];
316 };
329 };
317− android = {
330+ android = __android null;
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 = {
331+ ios = __ios null;
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; };
332+ passthru = { inherit android ios packages overrides tools shellToolOverrides withHoogle staticFiles staticFilesImpure __closureCompilerOptimizationLevel processedStatic __ios __android; };
332 };
333 };
333 in mkProject (projectDefinition args));
334 in mkProject (projectDefinition args));
334 serverOn = sys: version: serverExe
335 serverOn = sys: version: serverExe
lib/command/src/Obelisk/Command.hs+7−6
@@ -142,8 +142,8 @@ deployCommand cfg = hsubparser $ mconcat
142 ]
142 ]
143 where
143 where
144 platformP = hsubparser $ mconcat
144 platformP = hsubparser $ mconcat
145− [ command "android" $ info (pure Android) 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
146+ , command "ios" $ info ((,) <$> pure IOS <*> strArgument (metavar "TEAMID" <> help "Your Team ID - found in the Apple developer portal")) mempty
147 ]
147 ]
148
148
149 remoteBuilderParser :: Parser (Maybe RemoteBuilder)
149 remoteBuilderParser :: Parser (Maybe RemoteBuilder)
@@ -173,7 +173,7 @@ deployInitOpts = DeployInitOpts
173 <*> flag True False (long "disable-https" <> help "Disable automatic https configuration for the backend")
173 <*> flag True False (long "disable-https" <> help "Disable automatic https configuration for the backend")
174
174
175type TeamID = String
175type TeamID = String
176−data PlatformDeployment = Android | IOS TeamID
176+data PlatformDeployment = Android | IOS
177 deriving (Show)
177 deriving (Show)
178
178
179data RemoteBuilder = RemoteBuilder_ObeliskVM
179data RemoteBuilder = RemoteBuilder_ObeliskVM
@@ -182,7 +182,7 @@ data RemoteBuilder = RemoteBuilder_ObeliskVM
182data DeployCommand
182data DeployCommand
183 = DeployCommand_Init DeployInitOpts
183 = DeployCommand_Init DeployInitOpts
184 | DeployCommand_Push (Maybe RemoteBuilder)
184 | DeployCommand_Push (Maybe RemoteBuilder)
185− | DeployCommand_Test PlatformDeployment
185+ | DeployCommand_Test (PlatformDeployment, [String])
186 | DeployCommand_Update
186 | DeployCommand_Update
187 deriving Show
187 deriving Show
188
188
@@ -341,8 +341,9 @@ ob = \case
341 Nothing -> pure []
341 Nothing -> pure []
342 Just RemoteBuilder_ObeliskVM -> (:[]) <$> VmBuilder.getNixBuildersArg
342 Just RemoteBuilder_ObeliskVM -> (:[]) <$> VmBuilder.getNixBuildersArg
343 DeployCommand_Update -> deployUpdate "."
343 DeployCommand_Update -> deployUpdate "."
344+ DeployCommand_Test (platform, args) -> deployMobile platform args
344− DeployCommand_Test Android -> deployMobile "android" []
345+ -- DeployCommand_Test Android -> deployMobile "__android" []
345− DeployCommand_Test (IOS teamID) -> deployMobile "ios" [teamID]
346+ -- DeployCommand_Test (IOS teamID) -> deployMobile "__ios" [teamID]
346 ObCommand_Run -> inNixShell' $ static run
347 ObCommand_Run -> inNixShell' $ static run
347 -- inNixShell ($(mkClosure 'ghcidAction) ())
348 -- inNixShell ($(mkClosure 'ghcidAction) ())
348 ObCommand_Thunk tc -> case tc of
349 ObCommand_Thunk tc -> case tc of
lib/command/src/Obelisk/Command/Deploy.hs+13−1
@@ -160,9 +160,21 @@ deployUpdate deployPath = updateThunkToLatest $ deployPath </> "src"
160deployMobile :: MonadObelisk m => String -> [String] -> m ()
160deployMobile :: MonadObelisk m => String -> [String] -> m ()
161deployMobile platform mobileArgs = withProjectRoot "." $ \root -> do
161deployMobile platform mobileArgs = withProjectRoot "." $ \root -> do
162 let srcDir = root </> "src"
162 let srcDir = root </> "src"
163+ configDir = root </> "config"
163 exists <- liftIO $ doesDirectoryExist srcDir
164 exists <- liftIO $ doesDirectoryExist srcDir
164 unless exists $ failWith "ob test should be run inside of a deploy directory"
165 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)
166 callProcessAndLogOutput (Notice, Error) $ proc (result </> "bin" </> "deploy") mobileArgs
178 callProcessAndLogOutput (Notice, Error) $ proc (result </> "bin" </> "deploy") mobileArgs
167
179
168-- | Simplified deployment configuration mechanism. At one point we may revisit this.
180-- | 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
15 , nixCmdConfig_args
15 , nixCmdConfig_args
16 , nixCmdConfig_builders
16 , nixCmdConfig_builders
17 , NixBuildConfig (..)
17 , NixBuildConfig (..)
18+ , nixBuildConfig_common
18 , nixBuildConfig_outLink
19 , nixBuildConfig_outLink
19 , NixInstantiateConfig (..)
20 , NixInstantiateConfig (..)
20 , nixInstantiateConfig_eval
21 , nixInstantiateConfig_eval
lib/executable-config/default.nix+3−2
@@ -5,17 +5,18 @@
5{ nixpkgs
5{ nixpkgs
6, filterGitSource # TODO define this in obelisk
6, filterGitSource # TODO define this in obelisk
7}:
7}:
8−let injectConfig = config: assets: nixpkgs.runCommand "inject-config" {} ''
8+let injectConfig = config: assets: nixpkgs.runCommand "inject-config" {} (''
9 set -x
9 set -x
10 mkdir -p $out
10 mkdir -p $out
11 cp --no-preserve=mode -Lr "${assets}" $out/static
11 cp --no-preserve=mode -Lr "${assets}" $out/static
12 chmod +w "$out"
12 chmod +w "$out"
13+ '' + nixpkgs.lib.optionalString (!(builtins.isNull config)) ''
13 if ! mkdir $out/config; then
14 if ! mkdir $out/config; then
14 2>&1 echo config directory already exists or could not be created
15 2>&1 echo config directory already exists or could not be created
15 exit 1
16 exit 1
16 fi
17 fi
17 cp -a "${config}"/* "$out/config"
18 cp -a "${config}"/* "$out/config"
18− '';
19+ '');
19in with nixpkgs.haskell.lib; {
20in with nixpkgs.haskell.lib; {
20 haskellPackage = self: self.callPackage (filterGitSource ./lookup) {};
21 haskellPackage = self: self.callPackage (filterGitSource ./lookup) {};
21 platforms = {
22 platforms = {