Skip to content

Commit e18001f

Browse files
committed
web: use node binaries from nix store
1 parent e3192be commit e18001f

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

support/nix/build-shake.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ stdenv.mkDerivation {
3636
propagatedBuildInputs = [ lua5_3 gmp ];
3737

3838
buildPhase = ''
39-
ghc -o ${main} app/${main} -threaded -rtsopts -iapp -O2 -split-sections
39+
ghc -o ${main} app/${main} -threaded -rtsopts -iapp -O2 -split-sections -DNODE_BIN_PATH="\"${nodeDependencies}/bin\""
4040
'';
4141

4242
installPhase = ''

support/shake/app/Shake/Utils.hs

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
module Shake.Utils
23
( nodeCommand
34
, readJSONFile
@@ -7,10 +8,21 @@ import Data.Aeson
78

89
import Development.Shake
910

10-
-- | Invoke a command either from `PATH` or from `node_modules/.bin`
11+
-- | Invoke a Node command. On Nix builds (more generally, if the
12+
-- @NODE_BIN_PATH@ preprocessor macro is set while compiling), this will
13+
-- look for the command in a statically-known path. Otherwise, it'll try
14+
-- from @node_modules/.bin@ or your @PATH@.
1115
nodeCommand :: CmdResult r => [CmdOption] -> String -> [String] -> Action r
16+
#ifdef NODE_BIN_PATH
17+
18+
nodeCommand opts path = command opts ( NODE_BIN_PATH ++ "/" ++ path )
19+
20+
#else
21+
1222
nodeCommand opts = command (opts ++ [AddPath [] ["node_modules/.bin"]])
1323

24+
#endif
25+
1426
-- | Read and decode JSON from a file, tracking it as a dependency.
1527
readJSONFile :: FromJSON b => FilePath -> Action b
1628
readJSONFile path = need [path] >> liftIO (eitherDecodeFileStrict' path) >>= either fail pure

0 commit comments

Comments
 (0)