on master help sign in
static: use symlink to built staticFiles when it's a derivation
commit93bf974d60415bff2434f4db0edd4580d6eed086 authorAli Abrar <aliabrar@gmail.com> dateFri 18 Dec 2020, 01:24 (6 years ago) parent6573d48
2 files changed+8−5
ChangeLog.md+1 lib/command/src/Obelisk/Command/Project.hs+7−5
ChangeLog.md+1
@@ -8,6 +8,7 @@ This project's release branch is `master`. This log is written from the perspect
88 * Migration: All uses of `static @"some/path"` become `$(static "some/path")`. Instead of requiring `TypeApplications` and `DataKinds`, modules calling `static` must now enable `TemplateHaskell`.
99 * Deprecation: Deprecate static asset modules generated via 'obelisk-asset-manifest-generate' in favor of modules generated via 'obelisk-asset-th-generate'. The new executable takes the same arguments as the old and should be a drop-in replacement. To preserve the old behavior, set `__deprecated.useObeliskAssetManifestGenerate = true;` in your obelisk project configuration.
1010 * Feature: Files added to the static directory while `ob run` is active no longer require `ob run` to be restarted
11+* When `staticFiles` is a derivation, as opposed to a regular directory, produce a symlink to the result of that derivation at `static.out` and have `ob run` serve static assets from that symlink. This makes is possible for the static asset derivation to be rebuilt and the new results served without restarting `ob run`.
1112
1213## v0.9.1.0
1314
lib/command/src/Obelisk/Command/Project.hs+7−5
@@ -347,11 +347,13 @@ findProjectAssets root = do
347347 ]
348348 -- Check whether the impure static files are a derivation (and so must be built)
349349 if isDerivation == "1"
350− then fmap T.strip $ readProcessAndLogStderr Debug $ setCwd (Just root) $ -- Strip whitespace here because nix-build has no --raw option
351− proc nixBuildExePath
352− [ "--no-out-link"
353− , "-E", "(import ./. {}).passthru.staticFilesImpure"
354− ]
350+ then do
351+ _ <- readProcessAndLogStderr Debug $ setCwd (Just root) $
352+ proc nixBuildExePath
353+ [ "-o", "static.out"
354+ , "-E", "(import ./. {}).passthru.staticFilesImpure"
355+ ]
356+ pure $ T.pack $ root </> "static.out"
355357 else readProcessAndLogStderr Debug $ setCwd (Just root) $
356358 proc nixExePath ["eval", "-f", ".", "passthru.staticFilesImpure", "--raw"]
357359