on master help sign in
Merge remote-tracking branch 'origin/master' into ts-hydration

* origin/master: Strip whitespace when nix-building staticFilesImpure Add a FAQ item for issue #351 Check whether staticFilesImpure is a derivation and build it if so Update Spinner.hs

commit43fe1008f0d7029a1515167bfdbcc7ea417f6a0d authorAli Abrar <aliabrar@gmail.com> dateWed 13 Feb 2019, 11:00 (8 years ago) parentaa316f5fb0473a
3 files changed+52−12
FAQ.md+31 lib/cliapp/src/Obelisk/CliApp/Spinner.hs+1−7 lib/command/src/Obelisk/Command/Run.hs+20−5
FAQ.md+31
@@ -1,6 +1,7 @@
11# Frequently Asked Questions
22
331. [How do I fix invalid entitlements? ](#how-do-i-fix-invalid-entitlements)
4+1. [`ob thunk update` or `ob deploy update` fails](#ob-thunk-update-or-ob-deploy-update-fails)
45
56### How do I fix invalid entitlements?
67
@@ -13,3 +14,33 @@ When this happens you'll see an error something like this:
1314
1415Fixing the value of `ios.bundleIdentifier` should fix the error.
1516
17+### `ob thunk update` or `ob deploy update` fails
18+Whenever an `ob` command fails, try re-running it with `-v`.
19+
20+If you're using a private repo, and you get a failure in nix-prefetch-url, you may need to unpack and repack the thunk. Here's some example output that shows this issue:
21+
22+```
23+Starting Obelisk </nix/store/j8wls8a89xr6s1a47lg6g83gnbdrfd0l-obelisk-command-0.1/bin/.ob-wrapped> args=["deploy","update","-v"] logging-level=Debug
24+Creating process: 'nix-build' './.obelisk/impl' '-A' 'command' '--no-out-link'
25+✔ Built on ./.obelisk/impl [command]
26+Handing off to /nix/store/j8wls8a89xr6s1a47lg6g83gnbdrfd0l-obelisk-command-0.1/bin/ob
27+Starting Obelisk </nix/store/j8wls8a89xr6s1a47lg6g83gnbdrfd0l-obelisk-command-0.1/bin/.ob-wrapped> args=["--no-handoff","deploy","update","-v"] logging-level=Debug
28+Creating process: 'git' 'ls-remote' '--exit-code' '--symref' 'https://github.com/obsidiansystems/some-private-repo.git' 'refs/heads/master'
29+git ls-remote maps: (fromList [],fromList [(GitRef_Branch "master","8546dfc8be9653f20bb26214e0991dbb957cb290")])
30+Latest commit in branch master from remote repo https://github.com/obsidiansystems/some-private-repo.git is 8546dfc8be9653f20bb26214e0991dbb957cb290
31+Creating process: 'nix-prefetch-url' '--unpack' '--type' 'sha256' 'https://github.com/obsidiansystems/some-private-repo/archive/8546dfc8be9653f20bb26214e0991dbb957cb290.tar.gz'
32+error: unable to download 'https://github.com/obsidiansystems/some-private-repo/archive/8546dfc8be9653f20bb26214e0991dbb957cb290.tar.gz': HTTP error 404
33+Process exited with code 1; 'nix-prefetch-url' '--unpack' '--type' 'sha256' 'https://github.com/obsidiansystems/some-private-repo/archive/8546dfc8be9653f20bb26214e0991dbb957cb290.tar.gz'
34+nix-prefetch-url: Failed to determine sha256 hash of URL https://github.com/obsidiansystems/some-private-repo/archive/8546dfc8be9653f20bb26214e0991dbb957cb290.tar.gz
35+✖ Updating thunk ./src to latest
36+```
37+
38+And here's how you can fix it:
39+
40+```
41+ob thunk unpack $SOME_THUNK
42+ob thunk pack $SOME_THUNK
43+```
44+Substitute the directory of your thunk for `$SOME_THUNK`. In the case of `ob deploy update`, `$SOME_THUNK` will be `src` in the deployment directory.
45+
46+(Based on issue #351).
lib/cliapp/src/Obelisk/CliApp/Spinner.hs+1−7
@@ -133,14 +133,8 @@ runSpinner spinner f = forM_ spinner $ f >=> const delay
133133type SpinnerTheme = [Text]
134134
135135-- Find more spinners at https://github.com/sindresorhus/cli-spinners/blob/master/spinners.json
136−_spinnerCircleHalves :: SpinnerTheme
137−_spinnerCircleHalves = ["◐", "◓", "◑", "◒"]
138−
139−spinnerMoon :: SpinnerTheme
140−spinnerMoon = ["🌑", "🌒", "🌓", "🌔", "🌕", "🌖", "🌗", "🌘"]
141−
142136defaultSpinnerTheme :: SpinnerTheme
143−defaultSpinnerTheme = spinnerMoon
137+defaultSpinnerTheme = ["◐", "◓", "◑", "◒"]
144138
145139-- | Like `bracket` but the `release` function can know whether an exception was raised
146140bracket' :: MonadMask m => m a -> (a -> Maybe c -> m b) -> (a -> m c) -> m c
lib/command/src/Obelisk/Command/Run.hs+20−5
@@ -54,11 +54,26 @@ run = do
5454 pkgs <- getLocalPkgs
5555 withGhciScript pkgs $ \dotGhciPath -> do
5656 freePort <- getFreePort
57− assets <- withProjectRoot "." $ \root ->
58− -- `--raw` is not available with old nix-instantiate. It drops quotation
59− -- marks and trailing newline, so is very convenient for shelling out.
60− readProcessAndLogStderr Debug $
61− proc "nix" ["eval", "-f", root, "passthru.staticFilesImpure", "--raw"]
57+ assets <- withProjectRoot "." $ \root -> do
58+ let importableRoot = if "/" `isInfixOf` root
59+ then root
60+ else "./" <> root
61+ isDerivation <- readProcessAndLogStderr Debug $
62+ proc "nix"
63+ [ "eval"
64+ , "-f"
65+ , root
66+ , "(let a = import " <> importableRoot <> " {}; in toString (a.reflex.nixpkgs.lib.isDerivation a.passthru.staticFilesImpure))"
67+ , "--raw"
68+ -- `--raw` is not available with old nix-instantiate. It drops quotation
69+ -- marks and trailing newline, so is very convenient for shelling out.
70+ ]
71+ -- Check whether the impure static files are a derivation (and so must be built)
72+ if isDerivation == "1"
73+ then fmap T.strip $ readProcessAndLogStderr Debug $ -- Strip whitespace here because nix-build has no --raw option
74+ proc "nix-build" ["-E", "(import " <> importableRoot <> "{}).passthru.staticFilesImpure"]
75+ else readProcessAndLogStderr Debug $
76+ proc "nix" ["eval", "-f", root, "passthru.staticFilesImpure", "--raw"]
6277 putLog Debug $ "Assets impurely loaded from: " <> assets
6378 runGhcid dotGhciPath $ Just $ unwords
6479 [ "run"