@@ -54,11 +54,24 @@ run = do
54 pkgs <- getLocalPkgs
54 pkgs <- getLocalPkgs
55 withGhciScript pkgs $ \dotGhciPath -> do
55 withGhciScript pkgs $ \dotGhciPath -> do
56 freePort <- getFreePort
56 freePort <- getFreePort
57− assets <- withProjectRoot "." $ \root ->
57+ assets <- withProjectRoot "." $ \root -> do
58+ let importableRoot = if "/" `isInfixOf` root
61+ isDerivation <- readProcessAndLogStderr Debug $
66+ , "(let a = import " <> importableRoot <> " {}; in toString (a.reflex.nixpkgs.lib.isDerivation a.passthru.staticFilesImpure))"
58− -- `--raw` is not available with old nix-instantiate. It drops quotation
68+ -- `--raw` is not available with old nix-instantiate. It drops quotation
59− -- marks and trailing newline, so is very convenient for shelling out.
69+ -- marks and trailing newline, so is very convenient for shelling out.
71+ -- Check whether the impure static files are a derivation (and so must be built)
60− readProcessAndLogStderr Debug $
72+ readProcessAndLogStderr Debug $ if isDerivation == "1"
73+ then proc "nix-build" ["-E", "(import " <> importableRoot <> "{}).passthru.staticFilesImpure"]
61− proc "nix" ["eval", "-f", root, "passthru.staticFilesImpure", "--raw"]
74+ else proc "nix" ["eval", "-f", root, "passthru.staticFilesImpure", "--raw"]
62 putLog Debug $ "Assets impurely loaded from: " <> assets
75 putLog Debug $ "Assets impurely loaded from: " <> assets
63 runGhcid dotGhciPath $ Just $ unwords
76 runGhcid dotGhciPath $ Just $ unwords