Skip to content

Commit

Permalink
Split web common (#2611)
Browse files Browse the repository at this point in the history
There is code that is shared between plutus playground and plutus SCB that is not used by marlowe playground or marlowe dashboard. The same will be true for Marlowe once SCP-1672 is implemented. There is also code that is useful to all web projects. We wouldn't normally mind mixing these 3 types in one location however some of the purescript code depends on code generated by the psgenerator scripts. If we have them all together we have to add lots of superfluous types to our psgenerators. It started to get our of hand when I looked at implementing SCP-1672. This commit splits these 3 types into 3 different directories and should allow the psgenerator scripts to be simplified.

web-common-marlowe doesn't have anything in it yet but it will do with SCP-1672

Currently we're sticking with the model of "add an extra source directory" rather than having full on purescript or node modules. This is because it's currently much simpler, also spago2nix can't handle local modules yet (justinwoo/spago2nix#19). Finally, it makes it much easier to make changes to web-common and web-common-* during development of the main client projects because they are symlinks in the project, this means (in VSCode at least) that intellisense etc work perfectly.
  • Loading branch information
shmish111 authored Jan 18, 2021
1 parent 9b09eef commit 061f4b1
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions nix/lib/purescript.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
, nix-gitignore
}:

{
# path to generated purescript sources
psSrc
{ pkgs
# path to project sources
, src
# name of the project
Expand All @@ -15,8 +13,8 @@
, packages
# spago packages as generated by spago2nix
, spagoPackages
# web-common project
, webCommon
# a map of source directory name to contents that will be symlinked into the environment before building
, extraSrcs ? { }
# node_modules to use
, nodeModules
# control execution of unit tests
Expand All @@ -26,6 +24,9 @@ let
# Cleans the source based on the patterns in ./.gitignore and the additionalIgnores
cleanSrcs = nix-gitignore.gitignoreSource [ "/*.adoc" "/*.nix" ] src;

addExtraSrc = k: v: "ln -sf ${v} ${k}";
addExtraSrcs = builtins.concatStringsSep "\n" (builtins.attrValues (pkgs.lib.mapAttrs addExtraSrc extraSrcs));
extraPSPaths = builtins.concatStringsSep " " (map (d: "${d}/**/*.purs") (builtins.attrNames extraSrcs));
in
stdenv.mkDerivation {
inherit name checkPhase;
Expand All @@ -35,11 +36,10 @@ stdenv.mkDerivation {
export HOME=$NIX_BUILD_TOP
shopt -s globstar
ln -s ${nodeModules}/node_modules node_modules
ln -s ${psSrc} generated
ln -sf ${webCommon} web-common
${addExtraSrcs}
ls generated
sh ${spagoPackages.installSpagoStyle}
sh ${spagoPackages.buildSpagoStyle} src/**/*.purs test/**/*.purs generated/**/*.purs web-common/**/*.purs
sh ${spagoPackages.buildSpagoStyle} src/**/*.purs test/**/*.purs ${extraPSPaths}
${nodejs}/bin/npm run webpack
'';
doCheck = true;
Expand Down

0 comments on commit 061f4b1

Please sign in to comment.