on master help sign in
ensure nix is available to ob run through store path
commit5481bccd6dbcf1bbc0f5b978506a4d7b20bb56ea authorJoe Betz <joebetz91@gmail.com> dateFri 22 Nov 2019, 20:34 (7 years ago) parent0722c55
3 files changed+8−4
default.nix+1−1 lib/command/obelisk-command.cabal+1 lib/command/src/Obelisk/Command/Run.hs+6−3
default.nix+1−1
@@ -59,7 +59,7 @@ let
5959 obelisk-asset-serve-snap = self.callCabal2nix "obelisk-asset-serve-snap" (cleanSource ./lib/asset/serve-snap) {};
6060 obelisk-backend = self.callCabal2nix "obelisk-backend" (cleanSource ./lib/backend) {};
6161 obelisk-cliapp = self.callCabal2nix "obelisk-cliapp" (cleanSource ./lib/cliapp) {};
62− obelisk-command = self.callCabal2nix "obelisk-command" (cleanSource ./lib/command) {};
62+ obelisk-command = haskellLib.overrideCabal (self.callCabal2nix "obelisk-command" (cleanSource ./lib/command) {}) { librarySystemDepends = [ pkgs.nix ]; };
6363 obelisk-frontend = self.callCabal2nix "obelisk-frontend" (cleanSource ./lib/frontend) {};
6464 obelisk-run = self.callCabal2nix "obelisk-run" (cleanSource ./lib/run) {};
6565 obelisk-route = self.callCabal2nix "obelisk-route" (cleanSource ./lib/route) {};
lib/command/obelisk-command.cabal+1
@@ -46,6 +46,7 @@ library
4646 , transformers
4747 , unix
4848 , unordered-containers
49+ , which
4950 , yaml
5051 exposed-modules:
5152 Obelisk.App
lib/command/src/Obelisk/Command/Run.hs+6−3
@@ -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"