/
scripts.nix
52 lines (44 loc) · 2.04 KB
/
scripts.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{ pkgs, easyPS, prettier, writeShellScriptBinInRepoRoot }:
let
# Output containing the purescript bridge code
generated-purescript = pkgs.runCommand "marlowe-playground-purescript" { } ''
mkdir $out
${pkgs.playground.hsPkgs.marlowe-playground-server.components.exes.marlowe-playground-server}/bin/marlowe-playground-server psgenerator $out
cp ${builtins.path { name = "tidyrc.json"; path = ../.tidyrc.json; } } $out/.tidyrc.json
cp ${builtins.path { name = "tidyoperators"; path = ../.tidyoperators; } } $out/.tidyoperators
cd $out
${easyPS.purs-tidy}/bin/purs-tidy format-in-place *
${prettier}/bin/prettier -w .
rm -f $out/.tidyrc.json
rm -f $out/.tidyoperators
'';
# generate-purescript = writeShellScriptBinInRepoRoot "marlowe-playground-generate-purs" ''
# generated=./marlowe-playground-client/generated
# rm -rf $generated
# cp -a $(nix-build -A marlowe-playground.generated-purescript --no-out-link "$@") $generated
# chmod -R +w $generated
# '';
marlowe-playground-generate-purs = writeShellScriptBinInRepoRoot "marlowe-playground-generate-purs" ''
generated=./marlowe-playground-client/generated
# Clean old build
rm -rf $generated
# Re-generate the files
cp -a $(nix build .#generated-purescript --no-link --print-out-paths) $generated
chmod -R +w $generated
'';
build-ghc-with-marlowe = "$(nix build .#ghc-with-marlowe --no-link --print-out-paths)";
# start-backend: script to start the plutus-playground-server
#
# Note: We need to add ghc to the path because the server provides /runghc
# which needs ghc and dependencies.
start-backend = writeShellScriptBinInRepoRoot "marlowe-playground-server" ''
echo "marlowe-playground-server: for development use only"
GHC_WITH_PKGS=${build-ghc-with-marlowe}
export PATH=$GHC_WITH_PKGS/bin:$PATH
export FRONTEND_URL=https://localhost:8009
nix run .#marlowe-playground-server:exe:marlowe-playground-server -- webserver
'';
in
{
inherit marlowe-playground-generate-purs start-backend generated-purescript;
}