on cac2016 help sign in

master and cac2016 have 2 merge bases. This is what cac2016 changed since the first, 9acce71, as git diff master...cac2016 shows it.

7 files changed+101−101
since splitsnapshots
unifiedsplit
all-builds.nix+1−1 default.nix+37−35 dep/reflex-platform/github.json+3−3 lib/command/src/Obelisk/Command/Deploy.hs+22−17 lib/command/src/Obelisk/Command/Thunk.hs+34−42 lib/executable-config/default.nix+3−2 skeleton/default.nix+1−1
all-builds.nix+1−1
@@ -1,6 +1,6 @@
11{ self-args ? {
22 config.android_sdk.accept_license = true;
3− iosSdkVersion = "10.2";
3+ iosSdkVersion = "13.2";
44 }
55, local-self ? import ./. self-args
66, supportedSystems ? [ builtins.currentSystem ]
default.nix+37−35
@@ -1,6 +1,6 @@
11{ system ? builtins.currentSystem
22, profiling ? false
3−, iosSdkVersion ? "10.2"
3+, iosSdkVersion ? "13.2"
44, config ? {}
55, reflex-platform-func ? import ./dep/reflex-platform
66}:
@@ -131,6 +131,7 @@ in rec {
131131 }: {...}: {
132132 services.nginx = {
133133 enable = true;
134+ recommendedProxySettings = true;
134135 virtualHosts."${routeHost}" = {
135136 enableACME = enableHttps;
136137 forceSSL = enableHttps;
@@ -328,40 +329,39 @@ in rec {
328329 });
329330 in allConfig;
330331 in (mkProject (projectDefinition args)).projectConfig);
331− mainProjectOut = projectOut { inherit system; };
332+ projectOutHost = projectOut { inherit system; };
332333 serverOn = projectInst: version: serverExe
333334 projectInst.ghc.backend
334− mainProjectOut.ghcjs.frontend
335+ projectOutHost.ghcjs.frontend
335336 projectInst.passthru.staticFiles
336337 projectInst.passthru.__closureCompilerOptimizationLevel
337338 version;
338− linuxExe = serverOn (projectOut { system = "x86_64-linux"; });
339339 dummyVersion = "Version number is only available for deployments";
340− in mainProjectOut // {
341− __unstable__.profiledObRun = let
342− profiled = projectOut { inherit system; enableLibraryProfiling = true; };
343− exeSource = builtins.toFile "ob-run.hs" ''
344− {-# LANGUAGE NoImplicitPrelude #-}
345− {-# LANGUAGE PackageImports #-}
346− module Main where
347−
348− -- Explicitly import Prelude from base lest there be multiple modules called Prelude
349− import "base" Prelude (IO, (++), read)
350−
351− import "base" Control.Exception (finally)
352− import "reflex" Reflex.Profiled (writeProfilingData)
353− import "base" System.Environment (getArgs)
354−
355− import qualified "obelisk-run" Obelisk.Run
356− import qualified Frontend
357− import qualified Backend
358−
359− main :: IO ()
360− main = do
361− [portStr, assets, profFileName] <- getArgs
362− Obelisk.Run.run (read portStr) (Obelisk.Run.runServeAsset assets) Backend.backend Frontend.frontend
363− `finally` writeProfilingData (profFileName ++ ".rprof")
364− '';
340+ profiledObRun =
341+ let
342+ profiled = projectOut { inherit system; enableLibraryProfiling = true; };
343+ exeSource = builtins.toFile "ob-run-profiled.hs" ''
344+ {-# LANGUAGE NoImplicitPrelude #-}
345+ {-# LANGUAGE PackageImports #-}
346+ module Main where
347+
348+ -- Explicitly import Prelude from base lest there be multiple modules called Prelude
349+ import "base" Prelude (IO, (++), read)
350+
351+ import "base" Control.Exception (finally)
352+ import "reflex" Reflex.Profiled (writeProfilingData)
353+ import "base" System.Environment (getArgs)
354+
355+ import qualified "obelisk-run" Obelisk.Run
356+ import qualified Frontend
357+ import qualified Backend
358+
359+ main :: IO ()
360+ main = do
361+ [portStr, assets, profFileName] <- getArgs
362+ Obelisk.Run.run (read portStr) (Obelisk.Run.runServeAsset assets) Backend.backend Frontend.frontend
363+ `finally` writeProfilingData (profFileName ++ ".rprof")
364+ '';
365365 in nixpkgs.runCommand "ob-run" {
366366 buildInputs = [ (profiled.ghc.ghcWithPackages (p: [p.backend p.frontend])) ];
367367 } ''
@@ -369,14 +369,16 @@ in rec {
369369 mkdir -p $out/bin
370370 ghc -x hs -prof -fno-prof-auto -threaded ob-run.hs -o $out/bin/ob-run
371371 '';
372−
373− linuxExeConfigurable = linuxExe;
374− linuxExe = linuxExe dummyVersion;
375− exe = serverOn mainProjectOut dummyVersion;
372+ in projectOutHost // lib.makeExtensible (self: {
373+ __unstable__.profiledObRun = profiledObRun;
374+ exeConfigurable = { system, version }: serverOn (projectOut { inherit system; }) version;
375+ exe = self.exeConfigurable { inherit system; version = dummyVersion; };
376+ linuxExeConfigurable = version: self.exeConfigurable { system = "x86_64-linux"; inherit version; };
377+ linuxExe = self.linuxExeConfigurable dummyVersion;
376378 server = args@{ hostName, adminEmail, routeHost, enableHttps, version, module ? serverModules.mkBaseEc2 }:
377− server (args // { exe = linuxExe version; });
379+ server (args // { exe = self.linuxExeConfigurable version; });
378380 obelisk = import (base' + "/.obelisk/impl") {};
379− };
381+ });
380382 haskellPackageSets = {
381383 inherit (reflex-platform) ghc ghcjs;
382384 };
dep/reflex-platform/github.json+3−3
@@ -1,8 +1,8 @@
11{
22 "owner": "reflex-frp",
33 "repo": "reflex-platform",
4− "branch": "develop",
4+ "branch": "eac@tweaks-from-wrinkl",
55 "private": false,
6− "rev": "c21ec7036c8351185cd2feef9ce577b6a61c4f22",
7− "sha256": "0m4sdpz6qvngralpyprrbvsyi2zmfh2l3q5vhihwfp3842blvbfg"
6+ "rev": "7ae363f19849f7e97422b7a4d44ec25d5faa3838",
7+ "sha256": "0xhx6x5h0yaq581g7ibcfsw0h8wh4mn0pzl9zn4w9ish54mbn9fz"
88}
lib/command/src/Obelisk/Command/Deploy.hs+22−17
@@ -17,6 +17,7 @@ import Data.Bits
1717import qualified Data.ByteString.Lazy as BSL
1818import Data.Default
1919import qualified Data.Map as Map
20+import Data.Maybe (isJust, listToMaybe)
2021import qualified Data.Set as Set
2122import Data.String.Here.Interpolated (i)
2223import qualified Data.Text as T
@@ -124,15 +125,18 @@ deployPush deployPath getNixBuilders = do
124125 enableHttps <- read <$> readDeployConfig deployPath "enable_https"
125126 route <- readDeployConfig deployPath $ "config" </> "common" </> "route"
126127 routeHost <- getHostFromRoute enableHttps route
127− let srcPath = deployPath </> "src"
128− thunkPtr <- readThunk srcPath >>= \case
129− Right (ThunkData_Packed _ ptr) -> return ptr
130− Right ThunkData_Checkout -> do
131− checkGitCleanStatus srcPath True >>= \case
132− True -> packThunk (ThunkPackConfig False (ThunkConfig Nothing)) srcPath
133− False -> failWith $ T.pack $ "ob deploy push: ensure " <> srcPath <> " has no pending changes and latest is pushed upstream."
134− Left err -> failWith $ "ob deploy push: couldn't read src thunk: " <> T.pack (show err)
135− let version = show . _thunkRev_commit $ _thunkPtr_rev thunkPtr
128+ let
129+ srcPath = deployPath </> "src"
130+ handleUnpackedWith f = checkGitCleanStatus srcPath True >>= \case
131+ True -> f
132+ False -> failWith $ "ob deploy push: ensure " <> T.pack srcPath <> " has no pending changes and latest is pushed upstream."
133+
134+ version' <- readThunk srcPath >>= \case
135+ Right (ThunkData_Packed _ ptr) -> return $ Just $ show $ _thunkRev_commit $ _thunkPtr_rev ptr
136+ Right ThunkData_Checkout -> handleUnpackedWith $ Just . show . _thunkRev_commit . _thunkPtr_rev <$> packThunk (ThunkPackConfig False (ThunkConfig Nothing)) srcPath
137+ Left err -> do
138+ putLog Warning [i|No valid thunk found at ${srcPath} due to ${err}: Attempting to find commit hash anyway.|]
139+ handleUnpackedWith $ fmap show . listToMaybe . T.lines <$> readGitProcess srcPath ["rev-parse", "HEAD"]
136140 builders <- getNixBuilders
137141 let moduleFile = deployPath </> "module.nix"
138142 moduleFileExists <- liftIO $ doesFileExist moduleFile
@@ -149,7 +153,7 @@ deployPush deployPath getNixBuilders = do
149153 [ strArg "hostName" host
150154 , strArg "adminEmail" adminEmail
151155 , strArg "routeHost" routeHost
152− , strArg "version" version
156+ , strArg "version" $ maybe "Deployment was done with a dirty source tree" id version'
153157 , boolArg "enableHttps" enableHttps
154158 ] <> [rawArg "module" ("import " <> toNixPath moduleFile) | moduleFileExists ])
155159 & nixCmdConfig_builders .~ builders
@@ -179,13 +183,14 @@ deployPush deployPath getNixBuilders = do
179183 , "/nix/var/nix/profiles/system/bin/switch-to-configuration switch"
180184 ]
181185 ]
182− isClean <- checkGitCleanStatus deployPath True
183− when (not isClean) $ do
184− withSpinner "Committing changes to Git" $ do
185− callProcessAndLogOutput (Debug, Error) $ proc "git"
186− ["-C", deployPath, "add", "."]
187− callProcessAndLogOutput (Debug, Error) $ proc "git"
188− ["-C", deployPath, "commit", "-m", "New deployment"]
186+ when (isJust version') $ do
187+ isClean <- checkGitCleanStatus deployPath True
188+ when (not isClean) $ do
189+ withSpinner "Committing changes to Git" $ do
190+ callProcessAndLogOutput (Debug, Error) $ proc "git"
191+ ["-C", deployPath, "add", "."]
192+ callProcessAndLogOutput (Debug, Error) $ proc "git"
193+ ["-C", deployPath, "commit", "-m", "New deployment"]
189194 putLog Notice $ "Deployed => " <> T.pack route
190195 where
191196 callProcess' envMap cmd args = do
lib/command/src/Obelisk/Command/Thunk.hs+34−42
@@ -26,9 +26,8 @@ import qualified Data.ByteString.Lazy as LBS
2626import Data.Containers.ListUtils (nubOrd)
2727import Data.Default
2828import Data.Either.Combinators (fromRight', rightToMaybe)
29−import Data.Foldable (toList)
29+import Data.Foldable (for_, toList)
3030import Data.Function ((&))
31−import Data.Functor ((<&>))
3231import Data.Git.Ref (Ref)
3332import qualified Data.Git.Ref as Ref
3433import qualified Data.List as L
@@ -238,35 +237,38 @@ matchThunkSpecToDir
238237 -> Set FilePath -- ^ Set of file paths relative to the given directory
239238 -> m ThunkData
240239matchThunkSpecToDir thunkSpec dir dirFiles = do
241− case nonEmpty (toList $ dirFiles `Set.difference` expectedPaths) of
242− Just fs -> throwError $ ReadThunkError_UnrecognizedPaths $ (dir </>) <$> fs
243− Nothing -> pure ()
244− case nonEmpty (toList $ requiredPaths `Set.difference` dirFiles) of
245− Just fs -> throwError $ ReadThunkError_MissingPaths $ (dir </>) <$> fs
246− Nothing -> pure ()
247− datas <- fmap toList $ flip Map.traverseMaybeWithKey (_thunkSpec_files thunkSpec) $ \expectedPath -> \case
248− ThunkFileSpec_AttrCache -> Nothing <$ dirMayExist expectedPath
249− ThunkFileSpec_CheckoutIndicator -> liftIO (doesDirectoryExist (dir </> expectedPath)) <&> \case
250− False -> Nothing
251− True -> Just ThunkData_Checkout
252− ThunkFileSpec_FileMatches expectedContents -> handle (\(e :: IOError) -> throwError $ ReadThunkError_FileError e) $ do
253− actualContents <- liftIO (T.readFile $ dir </> expectedPath)
254− case T.strip expectedContents == T.strip actualContents of
255− True -> pure Nothing
256− False -> throwError $ ReadThunkError_FileDoesNotMatch (dir </> expectedPath) expectedContents
257− ThunkFileSpec_Ptr parser -> handle (\(e :: IOError) -> throwError $ ReadThunkError_FileError e) $ do
258− let path = dir </> expectedPath
259− liftIO (doesFileExist path) >>= \case
260− False -> pure Nothing
261− True -> do
262− actualContents <- liftIO $ LBS.readFile path
263− case parser actualContents of
264− Right v -> pure $ Just (ThunkData_Packed thunkSpec v)
265− Left e -> throwError $ ReadThunkError_UnparseablePtr (dir </> expectedPath) e
266−
267− case nonEmpty datas of
268− Nothing -> throwError ReadThunkError_UnrecognizedThunk
269− Just xs -> fold1WithM xs $ \a b -> either throwError pure (mergeThunkData a b)
240+ isCheckout <- fmap or $ flip Map.traverseWithKey (_thunkSpec_files thunkSpec) $ \expectedPath -> \case
241+ ThunkFileSpec_CheckoutIndicator -> liftIO (doesDirectoryExist (dir </> expectedPath))
242+ _ -> pure False
243+ case isCheckout of
244+ True -> pure ThunkData_Checkout
245+ False -> do
246+ for_ (nonEmpty (toList $ dirFiles `Set.difference` expectedPaths)) $ \fs ->
247+ throwError $ ReadThunkError_UnrecognizedPaths $ (dir </>) <$> fs
248+ for_ (nonEmpty (toList $ requiredPaths `Set.difference` dirFiles)) $ \fs ->
249+ throwError $ ReadThunkError_MissingPaths $ (dir </>) <$> fs
250+ datas <- fmap toList $ flip Map.traverseMaybeWithKey (_thunkSpec_files thunkSpec) $ \expectedPath -> \case
251+ ThunkFileSpec_AttrCache -> Nothing <$ dirMayExist expectedPath
252+ ThunkFileSpec_CheckoutIndicator -> pure Nothing -- Handled above
253+ ThunkFileSpec_FileMatches expectedContents -> handle (\(e :: IOError) -> throwError $ ReadThunkError_FileError e) $ do
254+ actualContents <- liftIO (T.readFile $ dir </> expectedPath)
255+ case T.strip expectedContents == T.strip actualContents of
256+ True -> pure Nothing
257+ False -> throwError $ ReadThunkError_FileDoesNotMatch (dir </> expectedPath) expectedContents
258+ ThunkFileSpec_Ptr parser -> handle (\(e :: IOError) -> throwError $ ReadThunkError_FileError e) $ do
259+ let path = dir </> expectedPath
260+ liftIO (doesFileExist path) >>= \case
261+ False -> pure Nothing
262+ True -> do
263+ actualContents <- liftIO $ LBS.readFile path
264+ case parser actualContents of
265+ Right v -> pure $ Just (thunkSpec, v)
266+ Left e -> throwError $ ReadThunkError_UnparseablePtr (dir </> expectedPath) e
267+
268+ uncurry ThunkData_Packed <$> case nonEmpty datas of
269+ Nothing -> throwError ReadThunkError_UnrecognizedThunk
270+ Just xs -> fold1WithM xs $ \a@(_, ptrA) (_, ptrB) ->
271+ if ptrA == ptrB then pure a else throwError $ ReadThunkError_AmbiguousPackedState ptrA ptrB
270272 where
271273 rootPathsOnly = Set.fromList . mapMaybe takeRootDir . Map.keys
272274 takeRootDir = fmap NonEmpty.head . nonEmpty . splitPath
@@ -282,15 +284,6 @@ matchThunkSpecToDir thunkSpec dir dirFiles = do
282284 True -> throwError $ ReadThunkError_UnrecognizedPaths $ expectedPath :| []
283285 False -> pure ()
284286
285− -- Combine 'ThunkData' from different files, preferring "Checkout" over "Packed"
286− mergeThunkData ThunkData_Checkout ThunkData_Checkout = Right ThunkData_Checkout
287− mergeThunkData ThunkData_Checkout ThunkData_Packed{} = Left bothPackedAndUnpacked
288− mergeThunkData ThunkData_Packed{} ThunkData_Checkout = Left bothPackedAndUnpacked
289− mergeThunkData a@(ThunkData_Packed _ ptrA) (ThunkData_Packed _ ptrB) =
290− if ptrA == ptrB then Right a else Left $ ReadThunkError_AmbiguousPackedState ptrA ptrB
291−
292− bothPackedAndUnpacked = ReadThunkError_UnrecognizedState "Both packed data and checkout present"
293−
294287 fold1WithM (x :| xs) f = foldM f x xs
295288
296289readThunkWith
@@ -305,8 +298,7 @@ readThunkWith specTypes dir = do
305298 Left e -> putLog Debug [i|Thunk specification ${_thunkSpec_name spec} did not match ${dir}: ${e}|] *> loop rest
306299 x@(Right _) -> x <$ putLog Debug [i|Thunk specification ${_thunkSpec_name spec} matched ${dir}|]
307300
308−-- | Read a thunk and validate that it is exactly a packed thunk.
309−-- If additional data is present, fail.
301+-- | Read a packed or unpacked thunk based on predefined thunk specifications.
310302readThunk :: (MonadObelisk m) => FilePath -> m (Either ReadThunkError ThunkData)
311303readThunk = readThunkWith thunkSpecTypes
312304
lib/executable-config/default.nix+3−2
@@ -5,13 +5,14 @@
55{ lib
66, runCommand
77, obeliskCleanSource
8+, staticDirName ? ""
89}:
910
1011let
1112 injectConfig = config: assets: runCommand "inject-config" {} (''
1213 set -x
13− mkdir -p $out
14− cp --no-preserve=mode -Lr "${assets}" $out/static
14+ mkdir -p "$out"/'${staticDirName}'
15+ cp --no-preserve=mode -Lr "${assets}"/. "$out"/'${staticDirName}'/
1516 chmod +w "$out"
1617 '' + lib.optionalString (!(builtins.isNull config)) ''
1718 if ! mkdir $out/config; then
skeleton/default.nix+1−1
@@ -1,6 +1,6 @@
11{ obelisk ? import ./.obelisk/impl {
22 system = builtins.currentSystem;
3− iosSdkVersion = "10.2";
3+ iosSdkVersion = "13.2";
44 # You must accept the Android Software Development Kit License Agreement at
55 # https://developer.android.com/studio/terms in order to build Android apps.
66 # Uncomment and set this to `true` to indicate your acceptance: