-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
42 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,55 @@ | ||
{ repoRoot, inputs, pkgs, system, lib }: | ||
{ repoRoot, inputs, pkgs, ... }: | ||
|
||
let | ||
spago-pkgs = import ./spago-packages.nix { inherit pkgs; }; | ||
in | ||
|
||
pkgs.buildNpmPackage { | ||
|
||
pname = "marlowe-playground-client"; | ||
|
||
version = "0.1.0"; | ||
|
||
src = lib.sourceByRegex (inputs.self + /marlowe-playground-client) [ | ||
"^prototype.*" | ||
"^generated.*" | ||
"^src.*" | ||
"^static.*" | ||
"^test.*" | ||
"^entry.*" | ||
"^grammar.ne$" | ||
"^package.*" | ||
"^postcss.*" | ||
"^spago.*" | ||
"^tailwind.*" | ||
"^tsconfig.*" | ||
"^webpack.*" | ||
]; | ||
|
||
dontNpmBuild = true; | ||
dontNpmInstall = true; | ||
npmlock2nix = import inputs.npmlock2nix { inherit pkgs; }; | ||
|
||
# buildNpmPackage is able to make a pure nix build by using npmDepsHash. | ||
# That is the hash of package-lock.json. | ||
# Its value is generated using the prefetch-npm-deps command (see shell.nix). | ||
# We set dontNpmBuild and dontNpmInstall to true to significantly speed up the | ||
# build: this works because we have a custom buildPhase that invokes webpack-cli | ||
# explicitely. | ||
npmDepsHash = import ./npm-deps-hash.nix; | ||
spagoPkgs = import ./spago-packages.nix { inherit pkgs; }; | ||
in | ||
|
||
nativeBuildInputs = [ | ||
spago-pkgs.installSpagoStyle | ||
spago-pkgs.buildSpagoStyle | ||
npmlock2nix.v1.build { | ||
src = inputs.self + "/marlowe-playground-client"; | ||
installPhase = '' | ||
mkdir -p $out/share/marlowe-playground-client/ | ||
cp -r dist $out/share/marlowe-playground-client/static | ||
''; | ||
node_modules_attrs = { | ||
githubSourceHashMap = { | ||
shmish111.nearley-webpack-loader."939360f9d1bafa9019b6ff8739495c6c9101c4a1" = "1brx669dgsryakf7my00m25xdv7a02snbwzhzgc9ylmys4p8c10x"; | ||
ankitrohatgi.tarballjs."64ea5eb78f7fc018a223207e67f4f863fcc5d3c5" = "04r9yap0ka4y3yirg0g7xb63mq7jzc2qbgswbixxj8s60k6zdqsm"; | ||
}; | ||
buildInputs = [ pkgs.python ]; | ||
}; | ||
buildInputs = [ | ||
spagoPkgs.installSpagoStyle | ||
spagoPkgs.buildSpagoStyle | ||
pkgs.nodejs-14_x | ||
repoRoot.nix.easy-purescript-nix.purs | ||
repoRoot.nix.easy-purescript-nix.spago2nix | ||
pkgs.nodejs_14 | ||
pkgs.nodejs_14.pkgs.webpack | ||
pkgs.nodejs_14.pkgs.webpack-cli | ||
]; | ||
|
||
buildPhase = '' | ||
mkdir -p {marlowe-playground-client,web-common-marlowe,web-common} | ||
unpackPhase = '' | ||
mkdir -p marlowe-playground-client | ||
cp -r $src/* marlowe-playground-client | ||
mkdir -p web-common-marlowe | ||
cp -r ${inputs.self + "/web-common-marlowe"}/* web-common-marlowe | ||
mkdir -p web-common | ||
cp -r ${inputs.self + "/web-common"}/* web-common | ||
cd marlowe-playground-client | ||
cd marlowe-playground-client | ||
install-spago-style | ||
build-spago-style \ | ||
"./src/**/*.purs" \ | ||
"./generated/**/*.purs" \ | ||
"../web-common-marlowe/src/**/*.purs" \ | ||
"../web-common/src/**/*.purs" | ||
npm run build:webpack:prod | ||
mkdir -p $out/share/marlowe-playground-client/static | ||
cp -r dist $out/share/marlowe-playground-client/static | ||
cd .. | ||
''; | ||
buildCommands = [ | ||
'' | ||
cd marlowe-playground-client | ||
build-spago-style \ | ||
"./src/**/*.purs" \ | ||
"./generated/**/*.purs" \ | ||
"../web-common-marlowe/src/**/*.purs" \ | ||
"../web-common/src/**/*.purs" | ||
rm -rf ./dist | ||
npm run build:webpack:prod | ||
'' | ||
]; | ||
} |