Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
zeme-wana committed Nov 2, 2023
1 parent a741d89 commit 0e770c4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 59 deletions.
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
nixpkgsArgs.config.permittedInsecurePackages = [
"nodejs-14.21.3"
"openssl-1.1.1w"
"python-2.7.18.7"
];
};

Expand Down
100 changes: 41 additions & 59 deletions nix/marlowe-playground-client.nix
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
''
];
}

0 comments on commit 0e770c4

Please sign in to comment.