on master help sign in
Merge branch 'develop' into ts-fix-underflow
e9b5df4Ali Abrar
README.md+5
@@ -5,6 +5,7 @@ Obelisk provides an easy way to develop and deploy your [Reflex](https://github.
5- [Installing Obelisk](#installing-obelisk)
5- [Installing Obelisk](#installing-obelisk)
6- [Developing an Obelisk project](#developing-an-obelisk-project)
6- [Developing an Obelisk project](#developing-an-obelisk-project)
7 - [Hoogle](#hoogle)
7 - [Hoogle](#hoogle)
8+ - [Adding Packages](#adding-packages)
8 - [Adding Package Overrides](#adding-package-overrides)
9 - [Adding Package Overrides](#adding-package-overrides)
9- [Deploying](#deploying)
10- [Deploying](#deploying)
10 - [Locally](#locally)
11 - [Locally](#locally)
@@ -92,6 +93,10 @@ To enter a nix-shell from which you can run the hoogle command-line client or a
92
93
93`nix-shell -A shells.ghc --arg withHoogle true`
94`nix-shell -A shells.ghc --arg withHoogle true`
94
95
96+### Adding packages
97+
98+In order to add package dependencies, declare them under the build-depends field in the appropriate cabal files (backend, common, and frontend each have their own). The corresponding Nix packages will automatically be selected when building.
99+
95### Adding package overrides
100### Adding package overrides
96
101
97To 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:
102To 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:
lib/command/src/Obelisk/Command/Run.hs+4−1
@@ -73,7 +73,10 @@ run = do
73 -- Check whether the impure static files are a derivation (and so must be built)
73 -- Check whether the impure static files are a derivation (and so must be built)
74 if isDerivation == "1"
74 if isDerivation == "1"
75 then fmap T.strip $ readProcessAndLogStderr Debug $ -- Strip whitespace here because nix-build has no --raw option
75 then fmap T.strip $ readProcessAndLogStderr Debug $ -- Strip whitespace here because nix-build has no --raw option
76+ proc "nix-build"
77+ [ "--no-out-link"
76− proc "nix-build" ["-E", "(import " <> importableRoot <> "{}).passthru.staticFilesImpure"]
78+ , "-E", "(import " <> importableRoot <> "{}).passthru.staticFilesImpure"
79+ ]
77 else readProcessAndLogStderr Debug $
80 else readProcessAndLogStderr Debug $
78 proc "nix" ["eval", "-f", root, "passthru.staticFilesImpure", "--raw"]
81 proc "nix" ["eval", "-f", root, "passthru.staticFilesImpure", "--raw"]
79 putLog Debug $ "Assets impurely loaded from: " <> assets
82 putLog Debug $ "Assets impurely loaded from: " <> assets
lib/command/src/Obelisk/Command/VmBuilder.hs+2−1
@@ -156,7 +156,8 @@ testLinuxBuild stateDir
156 | System.Info.os == "linux" = failWith "Using the docker builder is not necessary on linux."
156 | System.Info.os == "linux" = failWith "Using the docker builder is not necessary on linux."
157 | otherwise = do
157 | otherwise = do
158 (exitCode, _stdout, stderr) <- readCreateProcessWithExitCode $ proc "nix-build"
158 (exitCode, _stdout, stderr) <- readCreateProcessWithExitCode $ proc "nix-build"
159+ [ "--no-out-link"
159− [ "-E", "(import <nixpkgs> { system = \"x86_64-linux\"; }).writeText \"test\" builtins.currentTime"
160+ , "-E", "(import <nixpkgs> { system = \"x86_64-linux\"; }).writeText \"test\" builtins.currentTime"
160 , "--builders", nixBuildersArgString stateDir
161 , "--builders", nixBuildersArgString stateDir
161 ]
162 ]
162 unless (exitCode == ExitSuccess) $ do
163 unless (exitCode == ExitSuccess) $ do
lib/selftest/src/Obelisk/SelfTest.hs+10−9
@@ -75,6 +75,7 @@ main = do
75 unless isVerbose $
75 unless isVerbose $
76 putStrLn "Tests may take longer to run if there are unbuilt derivations: use -v for verbose output"
76 putStrLn "Tests may take longer to run if there are unbuilt derivations: use -v for verbose output"
77 let verbosity = bool silently verbosely isVerbose
77 let verbosity = bool silently verbosely isVerbose
78+ nixBuild args = run "nix-build" ("--no-out-link" : args)
78 obeliskImpl <- fromString <$> getEnv "OBELISK_IMPL"
79 obeliskImpl <- fromString <$> getEnv "OBELISK_IMPL"
79 httpManager <- HTTP.newManager HTTP.defaultManagerSettings
80 httpManager <- HTTP.newManager HTTP.defaultManagerSettings
80 [p0, p1, p2, p3] <- liftIO $ getFreePorts 4
81 [p0, p1, p2, p3] <- liftIO $ getFreePorts 4
@@ -141,22 +142,22 @@ main = do
141 testObRunInDir p2 p3 (Just "frontend") httpManager
142 testObRunInDir p2 p3 (Just "frontend") httpManager
142
143
143 describe "obelisk project" $ parallel $ do
144 describe "obelisk project" $ parallel $ do
144− it "can build obelisk command" $ inTmpObInit $ \_ -> run "nix-build" ["-A", "command" , obeliskImpl]
145+ it "can build obelisk command" $ inTmpObInit $ \_ -> nixBuild ["-A", "command" , obeliskImpl]
145− it "can build obelisk skeleton" $ inTmpObInit $ \_ -> run "nix-build" ["-A", "skeleton", obeliskImpl]
146+ it "can build obelisk skeleton" $ inTmpObInit $ \_ -> nixBuild ["-A", "skeleton", obeliskImpl]
146− it "can build obelisk shell" $ inTmpObInit $ \_ -> run "nix-build" ["-A", "shell", obeliskImpl]
147+ it "can build obelisk shell" $ inTmpObInit $ \_ -> nixBuild ["-A", "shell", obeliskImpl]
147 -- See https://github.com/obsidiansystems/obelisk/issues/101
148 -- See https://github.com/obsidiansystems/obelisk/issues/101
148− -- it "can build everything" $ shelly_ $ run "nix-build" [obeliskImpl]
149+ -- it "can build everything" $ shelly_ $ nixBuild [obeliskImpl]
149
150
150 describe "blank initialized project" $ parallel $ do
151 describe "blank initialized project" $ parallel $ do
151
152
152 it "can build ghc.backend" $ inTmpObInit $ \_ -> do
153 it "can build ghc.backend" $ inTmpObInit $ \_ -> do
153− run "nix-build" ["--no-out-link", "-A", "ghc.backend"]
154+ nixBuild ["-A", "ghc.backend"]
154 it "can build ghcjs.frontend" $ inTmpObInit $ \_ -> do
155 it "can build ghcjs.frontend" $ inTmpObInit $ \_ -> do
155− run "nix-build" ["--no-out-link", "-A", "ghcjs.frontend"]
156+ nixBuild ["-A", "ghcjs.frontend"]
156
157
157 if os == "darwin"
158 if os == "darwin"
158− then it "can build ios" $ inTmpObInit $ \_ -> run "nix-build" ["--no-out-link", "-A", "ios.frontend" ]
159+ then it "can build ios" $ inTmpObInit $ \_ -> nixBuild ["-A", "ios.frontend"]
159− else it "can build android" $ inTmpObInit $ \_ -> run "nix-build" ["--no-out-link", "-A", "android.frontend"]
160+ else it "can build android" $ inTmpObInit $ \_ -> nixBuild ["-A", "android.frontend"]
160
161
161 forM_ ["ghc", "ghcjs"] $ \compiler -> do
162 forM_ ["ghc", "ghcjs"] $ \compiler -> do
162 let
163 let
@@ -166,7 +167,7 @@ main = do
166 it ("can build in " <> shell) $ inTmpObInit $ \_ -> inShell $ "cabal new-build --" <> fromString compiler <> " all"
167 it ("can build in " <> shell) $ inTmpObInit $ \_ -> inShell $ "cabal new-build --" <> fromString compiler <> " all"
167
168
168 it "can build reflex project" $ inTmpObInit $ \_ -> do
169 it "can build reflex project" $ inTmpObInit $ \_ -> do
169− run "nix-build" []
170+ nixBuild []
170
171
171 it "has idempotent thunk update" $ inTmpObInit $ \_ -> do
172 it "has idempotent thunk update" $ inTmpObInit $ \_ -> do
172 u <- update
173 u <- update