@@ -3,6 +3,7 @@
33{-# LANGUAGE MultiParamTypeClasses #-}
44{-# LANGUAGE OverloadedStrings #-}
55{-# LANGUAGE ScopedTypeVariables #-}
6+{-# LANGUAGE TemplateHaskell #-}
67module Obelisk.Command.Run where
78
89import Control.Exception (bracket)
@@ -32,6 +33,7 @@ import System.Directory
3233import System.FilePath
3334import System.Process (proc)
3435import System.IO.Temp (withSystemTempDirectory)
36+import System.Which (staticWhich)
3537import Data.ByteString (ByteString)
3638
3739import Obelisk.App (MonadObelisk, ObeliskT)
@@ -56,6 +58,7 @@ data CabalPackageInfo = CabalPackageInfo
5658-- NOTE: `run` is not polymorphic like the rest because we use StaticPtr to invoke it.
5759run :: ObeliskT IO ()
5860run = do
61+ let nixPath = $(staticWhich "nix")
5962 pkgs <- getLocalPkgs
6063 withGhciScript pkgs $ \dotGhciPath -> do
6164 freePort <- getFreePort
@@ -64,7 +67,7 @@ run = do
6467 then root
6568 else "./" <> root
6669 isDerivation <- readProcessAndLogStderr Debug $
67− proc "nix"
70+ proc nixPath
6871 [ "eval"
6972 , "-f"
7073 , root
@@ -76,12 +79,12 @@ run = do
7679 -- Check whether the impure static files are a derivation (and so must be built)
7780 if isDerivation == "1"
7881 then fmap T.strip $ readProcessAndLogStderr Debug $ -- Strip whitespace here because nix-build has no --raw option
79− proc "nix-build"
82+ proc (nixPath <> "-build")
8083 [ "--no-out-link"
8184 , "-E", "(import " <> importableRoot <> "{}).passthru.staticFilesImpure"
8285 ]
8386 else readProcessAndLogStderr Debug $
84− proc "nix" ["eval", "-f", root, "passthru.staticFilesImpure", "--raw"]
87+ proc nixPath ["eval", "-f", root, "passthru.staticFilesImpure", "--raw"]
8588 putLog Debug $ "Assets impurely loaded from: " <> assets
8689 runGhcid dotGhciPath $ Just $ unwords
8790 [ "Obelisk.Run.run"