Skip to content

Commit

Permalink
Merge pull request #2608 from input-output-hk/purs-tooling
Browse files Browse the repository at this point in the history
Improve nix/purescript workflow
  • Loading branch information
gilligan committed Jan 14, 2021
2 parents 1dab11e + 977a202 commit 50620d5
Show file tree
Hide file tree
Showing 20 changed files with 60 additions and 30 deletions.
5 changes: 2 additions & 3 deletions marlowe-playground-client/README.md
Expand Up @@ -11,10 +11,9 @@ Check the [backend documentation](../marlowe-playground-server/README.md) for mo

Now we will build and run the front end:
```bash
# First generate the purescript bridge files
$(nix-build -A marlowe-playground.server-invoker)/bin/marlowe-playground psgenerator ./marlowe-playground-client/generated
# Now we will build and run the client on localhost
cd marlowe-playground-client
# Generate the purescript bridge files
marlowe-playground-generate-purs
# Download javascript dependencies
npm install
# Install purescript depdendencies
Expand Down
2 changes: 1 addition & 1 deletion marlowe-playground-client/package.json
Expand Up @@ -7,7 +7,7 @@
"webpack:server": "webpack-dev-server --progress --inline --hot --mode=development --host 0.0.0.0 --display verbose",
"webpack:server:debug": "DEBUG=purs-loader* DEBUG_DEPTH=100 webpack-dev-server --progress --inline --hot",
"purs:compile": "spago build",
"purs:ide": "purs ide server --log-level=debug 'src/**/*.purs' 'generated/**/*.purs' 'test/**/*.purs' '../web-common/**/*.purs'",
"purs:ide": "purs ide server --log-level=debug 'src/**/*.purs' 'generated/**/*.purs' 'test/**/*.purs' 'web-common/**/*.purs'",
"test": "NODE_OPTIONS=\"--max-old-space-size=8192\" webpack --config webpack.test.config.js --mode=development && node --max-old-space-size=8192 dist/test.js",
"docs": "spago docs",
"repl": "spago repl"
Expand Down
2 changes: 1 addition & 1 deletion marlowe-playground-client/spago.dhall
Expand Up @@ -37,6 +37,6 @@ You can edit this file as you like.
[ "src/**/*.purs"
, "test/**/*.purs"
, "generated/**/*.purs"
, "../web-common/**/*.purs"
, "web-common/**/*.purs"
]
}
1 change: 1 addition & 0 deletions marlowe-playground-client/web-common
7 changes: 5 additions & 2 deletions marlowe-playground-client/webpack.config.js
Expand Up @@ -71,7 +71,7 @@ module.exports = {
'src/**/*.purs',
'generated/**/*.purs',
'.spago/*/*/src/**/*.purs',
'../web-common/**/*.purs'
'web-common/**/*.purs'
],
psc: null,
bundle: !(isWebpackDevServer || isWatch),
Expand Down Expand Up @@ -107,7 +107,10 @@ module.exports = {

resolve: {
modules: [
'node_modules'
// We need the second entry for node to be able to
// locate `node_modules` from client directory when
// modules are referenced from inside `web-common`.
'node_modules', path.resolve(__dirname, './node_modules')
],
alias: {
grammar: path.resolve(__dirname, './grammar.ne'),
Expand Down
7 changes: 5 additions & 2 deletions marlowe-playground-client/webpack.test.config.js
Expand Up @@ -40,7 +40,7 @@ module.exports = {
'src/**/*.purs',
'generated/**/*.purs',
'.spago/*/*/src/**/*.purs',
'../web-common/**/*.purs',
'web-common/**/*.purs',
'test/**/*.purs'
],
}
Expand All @@ -56,7 +56,10 @@ module.exports = {

resolve: {
modules: [
'node_modules'
// We need the second entry for node to be able to
// locate `node_modules` from client directory when
// modules are referenced from inside `web-common`.
'node_modules', path.resolve(__dirname, './node_modules')
],
alias: {
grammar: path.resolve(__dirname, './grammar.ne'),
Expand Down
4 changes: 2 additions & 2 deletions nix/lib/purescript.nix
Expand Up @@ -36,10 +36,10 @@ stdenv.mkDerivation {
shopt -s globstar
ln -s ${nodeModules}/node_modules node_modules
ln -s ${psSrc} generated
ln -s ${webCommon} ../web-common
ln -sf ${webCommon} web-common
sh ${spagoPackages.installSpagoStyle}
sh ${spagoPackages.buildSpagoStyle} src/**/*.purs test/**/*.purs generated/**/*.purs ../web-common/**/*.purs
sh ${spagoPackages.buildSpagoStyle} src/**/*.purs test/**/*.purs generated/**/*.purs web-common/**/*.purs
${nodejs}/bin/npm run webpack
'';
doCheck = true;
Expand Down
5 changes: 2 additions & 3 deletions plutus-playground-client/README.md
Expand Up @@ -7,10 +7,9 @@ Please view the instructions for building the server [here](../plutus-playground
## Client

```sh
# First generate the purescript bridge files
$(nix-build -A plutus-playground.server-invoker)/bin/plutus-playground psgenerator ./plutus-playground-client/generated
# Now we will build and run the client on localhost
cd plutus-playground-client
# Generate the purescript bridge files
plutus-playground-generate-purs
# Download javascript dependencies
npm install
# Install purescript depdendencies
Expand Down
2 changes: 1 addition & 1 deletion plutus-playground-client/package.json
Expand Up @@ -7,7 +7,7 @@
"webpack:server": "webpack-dev-server --progress --inline --hot --mode=development",
"webpack:server:debug": "DEBUG=purs-loader* DEBUG_DEPTH=100 webpack-dev-server --progress --inline --hot",
"purs:compile": "spago build",
"purs:ide": "purs ide server --log-level=debug 'src/**/*.purs' 'generated/**/*.purs' 'test/**/*.purs' '../web-common/**/*.purs'",
"purs:ide": "purs ide server --log-level=debug 'src/**/*.purs' 'generated/**/*.purs' 'test/**/*.purs' 'web-common/**/*.purs'",
"test": "spago --no-psa test",
"test:watch": "spago test --no-psa --watch",
"docs": "spago docs",
Expand Down
2 changes: 1 addition & 1 deletion plutus-playground-client/spago.dhall
Expand Up @@ -33,6 +33,6 @@ You can edit this file as you like.
[ "src/**/*.purs"
, "test/**/*.purs"
, "generated/**/*.purs"
, "../web-common/**/*.purs"
, "web-common/**/*.purs"
]
}
2 changes: 1 addition & 1 deletion plutus-playground-client/static/main.scss
@@ -1,7 +1,7 @@
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;700');

@import 'variables.scss';
@import '../../web-common/static/bootstrap.scss';
@import '../web-common/static/bootstrap.scss';

@import 'layout.scss';
@import 'subheader.scss';
Expand Down
4 changes: 2 additions & 2 deletions plutus-playground-client/static/transactions.scss
Expand Up @@ -4,8 +4,8 @@ $chart-tooltip: $gray-900;
$chart-title: $gray-900;
$chart-label: $gray-900;
$chart-grid-stroke: $gray-500;
@import '../../web-common/static/chartist.scss';
@import '../../web-common/static/chain.scss';
@import '../web-common/static/chartist.scss';
@import '../web-common/static/chain.scss';

.transactions {
border: 1px solid $gray-border-color;
Expand Down
1 change: 1 addition & 0 deletions plutus-playground-client/web-common
9 changes: 6 additions & 3 deletions plutus-playground-client/webpack.config.js
Expand Up @@ -58,7 +58,7 @@ module.exports = {
'src/**/*.purs',
'generated/**/*.purs',
'.spago/*/*/src/**/*.purs',
'../web-common/**/*.purs'
'web-common/**/*.purs'
],
psc: null,
bundle: !(isWebpackDevServer || isWatch),
Expand Down Expand Up @@ -101,7 +101,10 @@ module.exports = {

resolve: {
modules: [
'node_modules'
// We need the second entry for node to be able to
// locate `node_modules` from client directory when
// modules are referenced from inside `web-common`.
'node_modules', path.resolve(__dirname, './node_modules')
],
alias: {
static: path.resolve(__dirname, './static'),
Expand All @@ -119,7 +122,7 @@ module.exports = {

plugins: [
new HtmlWebpackPlugin({
template: '../web-common/static/index.html',
template: 'web-common/static/index.html',
favicon: 'static/favicon.ico',
title: 'Plutus Playground',
productName: 'plutus',
Expand Down
2 changes: 1 addition & 1 deletion plutus-scb-client/package.json
Expand Up @@ -7,7 +7,7 @@
"webpack:server": "webpack-dev-server --progress --inline --hot --mode=development",
"webpack:server:debug": "DEBUG=purs-loader* DEBUG_DEPTH=100 webpack-dev-server --progress --inline --hot",
"purs:compile": "spago build",
"purs:ide": "purs ide server --log-level=debug 'src/**/*.purs' 'generated/**/*.purs' 'test/**/*.purs' '../web-common/**/*.purs'",
"purs:ide": "purs ide server --log-level=debug 'src/**/*.purs' 'generated/**/*.purs' 'test/**/*.purs' 'web-common/**/*.purs'",
"test": "spago --no-psa test",
"test:watch": "spago test --no-psa --watch",
"docs": "spago docs",
Expand Down
2 changes: 1 addition & 1 deletion plutus-scb-client/spago.dhall
Expand Up @@ -32,6 +32,6 @@ You can edit this file as you like.
[ "src/**/*.purs"
, "test/**/*.purs"
, "generated/**/*.purs"
, "../web-common/**/*.purs"
, "web-common/**/*.purs"
]
}
4 changes: 2 additions & 2 deletions plutus-scb-client/static/main.scss
Expand Up @@ -13,8 +13,8 @@ $nav-link-hover: $white;
$nav-link-border-radius: 3px;
$clipboard-button-color: $white;

@import '../../web-common/static/common.scss';
@import '../../web-common/static/chain.scss';
@import '../web-common/static/common.scss';
@import '../web-common/static/chain.scss';
@include chain (
$balances-table-background-color: $gray-800,
$balances-table-border-color: $gray-700,
Expand Down
1 change: 1 addition & 0 deletions plutus-scb-client/web-common
7 changes: 5 additions & 2 deletions plutus-scb-client/webpack.config.js
Expand Up @@ -63,7 +63,7 @@ module.exports = {
'src/**/*.purs',
'generated/**/*.purs',
'.spago/*/*/src/**/*.purs',
'../web-common/**/*.purs'
'web-common/**/*.purs'
],
psc: null,
bundle: !(isWebpackDevServer || isWatch),
Expand Down Expand Up @@ -92,7 +92,10 @@ module.exports = {

resolve: {
modules: [
'node_modules'
// We need the second entry for node to be able to
// locate `node_modules` from client directory when
// modules are referenced from inside `web-common`.
'node_modules', path.resolve(__dirname, './node_modules')
],
extensions: [ '.purs', '.js']
},
Expand Down
21 changes: 19 additions & 2 deletions shell.nix
Expand Up @@ -3,10 +3,10 @@
, config ? { allowUnfreePredicate = (import ./lib.nix).unfreePredicate; }
, rev ? "in-nix-shell"
, sourcesOverride ? { }
, packages ? import ./nix { inherit crossSystem config sourcesOverride rev; }
, packages ? import ./. { inherit crossSystem config sourcesOverride rev; }
}:
let
inherit (packages) pkgs plutus plutusMusl;
inherit (packages) pkgs plutus plutusMusl plutus-playground marlowe-playground plutus-scb;
inherit (pkgs) stdenv lib utillinux python3 nixpkgs-fmt;
inherit (plutus) haskell agdaPackages stylish-haskell sphinxcontrib-haddock nix-pre-commit-hooks;
inherit (plutus) agdaWithStdlib;
Expand Down Expand Up @@ -57,6 +57,20 @@ let
zlib
] ++ (lib.optionals (!stdenv.isDarwin) [ rPackages.plotly R ]));

plutus-playground-generate-purs = pkgs.writeShellScriptBin "plutus-playground-generate-purs" ''
rm -rf ./generated
${plutus-playground.server-invoker}/bin/plutus-playground psgenerator generated
'';
marlowe-playground-generate-purs = pkgs.writeShellScriptBin "marlowe-playground-generate-purs" ''
rm -rf ./generated
${marlowe-playground.server-invoker}/bin/marlowe-playground psgenerator generated
'';
plutus-scb-generate-purs = pkgs.writeShellScriptBin "plutus-scb-generate-purs" ''
rm -rf ./generated
cp ${haskell.packages.plutus-scb.src}/plutus-scb.yaml.sample plutus-scb.yaml
${plutus-scb.server-invoker}/bin/plutus-scb psgenerator generated
'';

# local build inputs ( -> ./nix/pkgs/default.nix )
localInputs = (with plutus; [
cabal-install
Expand All @@ -66,6 +80,9 @@ let
hie-bios
gen-hie
hlint
marlowe-playground-generate-purs
plutus-scb-generate-purs
plutus-playground-generate-purs
purs
purty
spago
Expand Down

0 comments on commit 50620d5

Please sign in to comment.