on master help sign in
Merge branch 'develop' into readme-install-source
commit3d89b2baed15cbca3c2250a5551cf1523cadc4bc authorAli Abrar <aliabrar@gmail.com> dateWed 2 Oct 2019, 22:11 (7 years ago) parentb2aed54513a12a
12 files changed+48−35
README.md+18−9 dep/reflex-platform/github.json+3−3 lib/command/src/Obelisk/Command/Deploy.hs+1−1 lib/command/src/Obelisk/Command/Project.hs+1 lib/command/src/Obelisk/Command/Run.hs+9 lib/selftest/src/Obelisk/SelfTest.hs+1−1 release.nix+3−6 skeleton/backend/src/Backend.hs−2 skeleton/common/src/Common/Route.hs+4−6 skeleton/default.nix+6−6 skeleton/frontend/src/Frontend.hs+1−1 skeleton/shell.nix+1
README.md+18−9
@@ -121,14 +121,14 @@ In order to add package dependencies, declare them under the build-depends field
121121
122122### Adding package overrides
123123
124−To add a version override to any Haskell package, or to add a Haskell package that doesn't exist in the nixpkgs used by Obelisk, use the `overrides` attribute in your project's `default.nix`. For example, to use a specific version of the `aeson` package, your `default.nix` will look like:
124+To add a version override to any Haskell package, or to add a Haskell package that doesn't exist in the nixpkgs used by Obelisk, use the `overrides` attribute in your project's `default.nix`. For example, to use a specific version of the `aeson` package fetched from GitHub and a specific version of the `waargonaut` package fetched from Hackage, your `default.nix` will look like:
125125
126126```nix
127127# ...
128128project ./. ({ pkgs, ... }: {
129129# ...
130130 overrides = self: super: let
131− aeson = pkgs.fetchFromGitHub {
131+ aesonSrc = pkgs.fetchFromGitHub {
132132 owner = "obsidiansystems";
133133 repo = "aeson-gadt-th";
134134 rev = "ed573c2cccf54d72aa6279026752a3fecf9c1383";
@@ -136,7 +136,12 @@ project ./. ({ pkgs, ... }: {
136136 };
137137 in
138138 {
139− aeson = self.callCabal2nix "aeson" aeson {};
139+ aeson = self.callCabal2nix "aeson" aesonSrc {};
140+ waargonaut = self.callHackageDirect {
141+ pkg = "waargonaut";
142+ ver = "0.8.0.1";
143+ sha256 = "1zv28np3k3hg378vqm89v802xr0g8cwk7gy3mr77xrzy5jbgpa39";
144+ } {};
140145 };
141146# ...
142147```
@@ -150,14 +155,16 @@ For further information see [the Haskell section](https://nixos.org/nixpkgs/manu
150155Build everything:
151156
152157```
153−nix-build -A exe -o result-exe
158+nix-build -A exe --no-out-link
154159```
155160
156−Run the server:
161+Copy the result to a new directory, add configuration, and run!
157162
158163```
159−cd result-exe
160−./backend
164+mkdir test-app
165+ln -s $(nix-build -A exe --no-out-link)/* test-app/
166+cp -r config test-app
167+(cd test-app && ./backend)
161168```
162169
163170### EC2
@@ -189,9 +196,11 @@ ob deploy init \
189196 ~/code/myapp-deploy
190197```
191198
192−NOTE: HTTPS is enabled by default; to disable https, pass `--disable-https` to the `ob deploy init` command above.
199+HTTPS is enabled by default; to disable https, pass `--disable-https` to the `ob deploy init` command above.
193200
194−Then go to that created deployment configuration directory, and initiate the deployment:
201+This step will also require that you manually verify the authenticity of the host `$SERVER`. Obelisk will save the fingerprint in a deployment-specific configuration. **Obelisk deployments do *not* rely on the `known_hosts` of your local machine.** This is because, in the event that you need to switch from one deploy machine / bastion host to another, you want to be absolutely sure that you're still connecting to the machines you think you are, even if that deploy machine / bastion host has never connected to them before. Obelisk explicitly avoids a workflow that encourages people to accept host keys without checking them, since that could result in leaking production secrets to anyone who manages to MITM you, e.g. via DNS spoofing or cache poisoning. (Note that an active attack is a circumstance where you may need to quickly switch bastion hosts, e.g. because the attacker has taken one down or you have taken it down in case it was compromised. In this circumstance you might need to deploy to production to fix an exploit or rotate keys, etc.) When you run `ob deploy` later it will rely on the saved verification in this step.
202+
203+Next, go to the deployment directory that you just initialized and deploy!
195204
196205```
197206cd ~/code/myapp-deploy
dep/reflex-platform/github.json+3−3
@@ -1,7 +1,7 @@
11{
22 "owner": "reflex-frp",
33 "repo": "reflex-platform",
4− "branch": "aa-split-these",
5− "rev": "4b4a2c8679d6f3042180d2974b31c43bfc506b91",
6− "sha256": "185i8ccqk0xc05ckd921fs7nnaj88gihmlazny1dk004hxq78cj2"
4+ "branch": "develop",
5+ "rev": "9e306f72ed0dbcdccce30a4ba0eb37aa03cf91e3",
6+ "sha256": "1crlwfw6zsx2izwsd57i5651p5pfyrpkfjwp6fc1yd4q4d4n7g2m"
77}
lib/command/src/Obelisk/Command/Deploy.hs+1−1
@@ -275,7 +275,7 @@ instance ToJSON KeytoolConfig
275275createKeystore :: MonadObelisk m => FilePath -> KeytoolConfig -> m ()
276276createKeystore root config = do
277277 let expr = "with (import " <> toImplDir root <> ").reflex-platform.nixpkgs; pkgs.mkShell { buildInputs = [ pkgs.jdk ]; }"
278− callProcessAndLogOutput (Notice,Notice) $ (proc "nix-shell" ["-E" , expr, "--run" , keytoolCmd]) { cwd = Just root }
278+ callProcessAndLogOutput (Notice,Notice) $ (proc "nix-shell" ["default.nix", "-E" , expr, "--run" , keytoolCmd]) { cwd = Just root }
279279 where
280280 keytoolCmd = processToShellString "keytool"
281281 [ "-genkeypair", "-noprompt"
lib/command/src/Obelisk/Command/Project.hs+1
@@ -205,6 +205,7 @@ inImpureProjectShell shellName command = withProjectRoot "." $ \root ->
205205projectShell :: MonadObelisk m => FilePath -> Bool -> String -> Maybe String -> m ()
206206projectShell root isPure shellName command = do
207207 (_, _, _, ph) <- createProcess_ "runNixShellAttr" $ setCtlc $ setCwd (Just root) $ proc "nix-shell" $
208+ [ "default.nix"] <>
208209 [ "--pure" | isPure ] <>
209210 [ "-A"
210211 , "shells." <> shellName
lib/command/src/Obelisk/Command/Run.hs+9
@@ -14,6 +14,7 @@ import qualified Data.List as L
1414import qualified Data.List.NonEmpty as NE
1515import Data.Maybe
1616import qualified Data.Text as T
17+import Distribution.Compiler (CompilerFlavor(..))
1718import Distribution.PackageDescription.Parsec (parseGenericPackageDescription)
1819import Distribution.Parsec.ParseResult (runParseResult)
1920import Distribution.Pretty
@@ -48,6 +49,8 @@ data CabalPackageInfo = CabalPackageInfo
4849 -- ^ List of globally enable extensions of the library component
4950 , _cabalPackageInfo_defaultLanguage :: Maybe Language
5051 -- ^ List of globally set languages of the library component
52+ , _cabalPackageInfo_compilerOptions :: [(CompilerFlavor, [String])]
53+ -- ^ List of compiler-specific options (e.g., the "ghc-options" field of the cabal file)
5154 }
5255
5356-- NOTE: `run` is not polymorphic like the rest because we use StaticPtr to invoke it.
@@ -143,6 +146,7 @@ parseCabalPackage dir = do
143146 defaultExtensions $ libBuildInfo lib
144147 , _cabalPackageInfo_defaultLanguage =
145148 defaultLanguage $ libBuildInfo lib
149+ , _cabalPackageInfo_compilerOptions = options $ libBuildInfo lib
146150 }
147151 Left (_, errors) -> do
148152 putLog Error $ T.pack $ "Failed to parse " <> cabalFp <> ":"
@@ -178,8 +182,13 @@ withGhciScript pkgs f = do
178182 extensionsLine = if extensions == mempty
179183 then ""
180184 else ":set " <> intercalate " " ((("-X" <>) . prettyShow) <$> extensions)
185+ ghcOptions = concat $ mapMaybe (\case (GHC, xs) -> Just xs; _ -> Nothing) $
186+ packageInfos >>= _cabalPackageInfo_compilerOptions
181187 dotGhci = unlines $
182188 [ ":set -i" <> intercalate ":" (packageInfos >>= rootedSourceDirs)
189+ , case ghcOptions of
190+ [] -> ""
191+ xs -> ":set " <> intercalate " " xs
183192 , extensionsLine
184193 , ":set " <> intercalate " " (("-X" <>) . prettyShow <$> language)
185194 , ":load Backend Frontend"
lib/selftest/src/Obelisk/SelfTest.hs+1−1
@@ -162,7 +162,7 @@ main = do
162162 forM_ ["ghc", "ghcjs"] $ \compiler -> do
163163 let
164164 shell = "shells." <> compiler
165− inShell cmd' = run "nix-shell" ["-A", fromString shell, "--run", cmd']
165+ inShell cmd' = run "nix-shell" ["default.nix", "-A", fromString shell, "--run", cmd']
166166 it ("can enter " <> shell) $ inTmpObInit $ \_ -> inShell "exit"
167167 it ("can build in " <> shell) $ inTmpObInit $ \_ -> inShell $ "cabal new-build --" <> fromString compiler <> " all"
168168
release.nix+3−6
@@ -58,6 +58,7 @@ let
5858 (builtins.attrValues ghcjs)
5959 (concatDepends ghc)
6060 (concatDepends ghcjs)
61+ [command serverExeSkeleton iosSkeleton androidSkeleton]
6162 ];
6263 command = local-self.command;
6364 serverExeSkeleton = (import ./skeleton { obelisk = local-self; }).exe;
@@ -77,15 +78,11 @@ let
7778 serverExeSkeleton
7879 iosSkeleton
7980 androidSkeleton;
80− cache = reflex-platform.pinBuildInputs
81− "obelisk-${system}"
82− cachePackages
83− [command serverExeSkeleton iosSkeleton androidSkeleton];
81+ cache = reflex-platform.pinBuildInputs "obelisk-${system}" cachePackages;
8482 });
8583
8684 metaCache = local-self.pinBuildInputs
8785 "obelisk-everywhere"
88− (map (a: a.cache) (builtins.attrValues perPlatform))
89− [];
86+ (map (a: a.cache) (builtins.attrValues perPlatform));
9087
9188in perPlatform // { inherit metaCache; }
skeleton/backend/src/Backend.hs−2
@@ -1,6 +1,4 @@
1−{-# LANGUAGE EmptyCase #-}
21{-# LANGUAGE FlexibleContexts #-}
3−{-# LANGUAGE LambdaCase #-}
42{-# LANGUAGE RankNTypes #-}
53{-# LANGUAGE TypeFamilies #-}
64module Backend where
skeleton/common/src/Common/Route.hs+4−6
@@ -1,15 +1,13 @@
11{-# LANGUAGE EmptyCase #-}
22{-# LANGUAGE FlexibleContexts #-}
3+{-# LANGUAGE FlexibleInstances #-}
34{-# LANGUAGE GADTs #-}
4−{-# LANGUAGE LambdaCase #-}
5−{-# LANGUAGE RankNTypes #-}
6−{-# LANGUAGE TemplateHaskell #-}
75{-# LANGUAGE KindSignatures #-}
8−{-# LANGUAGE EmptyCase #-}
6+{-# LANGUAGE LambdaCase #-}
97{-# LANGUAGE MultiParamTypeClasses #-}
10−{-# LANGUAGE FlexibleInstances #-}
118{-# LANGUAGE OverloadedStrings #-}
12−
9+{-# LANGUAGE RankNTypes #-}
10+{-# LANGUAGE TemplateHaskell #-}
1311module Common.Route where
1412
1513{- -- You will probably want these imports for composing Encoders.
skeleton/default.nix+6−6
@@ -1,10 +1,10 @@
11{ obelisk ? import ./.obelisk/impl {
2− system = builtins.currentSystem;
3− iosSdkVersion = "10.2";
4− # You must accept the Android Software Development Kit License Agreement at
5− # https://developer.android.com/studio/terms in order to build Android apps.
6− # Uncomment and set this to `true` to indicate your acceptance:
7− # config.android_sdk.accept_license = false;
2+ system = builtins.currentSystem;
3+ iosSdkVersion = "10.2";
4+ # You must accept the Android Software Development Kit License Agreement at
5+ # https://developer.android.com/studio/terms in order to build Android apps.
6+ # Uncomment and set this to `true` to indicate your acceptance:
7+ # config.android_sdk.accept_license = false;
88 }
99}:
1010with obelisk;
skeleton/frontend/src/Frontend.hs+1−1
@@ -22,7 +22,7 @@ frontend = Frontend
2222 el "p" $ text $ T.pack commonStuff
2323 elAttr "img" ("src" =: static @"obelisk.jpg") blank
2424 el "div" $ do
25− exampleConfig <- getConfig "common/example"
25+ exampleConfig <- getConfig "common/example"
2626 case exampleConfig of
2727 Nothing -> text "No config file found in config/common/example"
2828 Just s -> text (T.decodeUtf8 s)
skeleton/shell.nixnew file+1
@@ -0,0 +1 @@
1+(import ./. {}).shells.ghc