Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit 4264cca

Browse files
committed
[DEVOPS-398] explorer frontend: add shell.nix for dev
1 parent 13e91c4 commit 4264cca

File tree

2 files changed

+42
-7
lines changed

2 files changed

+42
-7
lines changed

explorer/frontend/default.nix

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,15 @@ let
4040

4141
generatedSrc = pkgs.runCommand "cardano-sl-explorer-frontend-src" {
4242
inherit src bowerComponents;
43-
buildInputs = [
44-
oldHaskellPackages.purescript-derive-lenses
45-
cardano-sl-explorer
46-
];
43+
buildInputs = [ regen-script ];
4744
} ''
4845
cp -R --reflink=auto $src $out
4946
chmod -R u+w $out
5047
cd $out
5148
rm -rf .psci_modules .pulp-cache bower_components output result
5249
5350
# Purescript code generation
54-
cardano-explorer-hs2purs --bridge-path src/Generated/
55-
scripts/generate-explorer-lenses.sh
51+
regen
5652
5753
# Frontend dependencies
5854
ln -s $bowerComponents/bower_components .
@@ -86,11 +82,21 @@ let
8682
nodejs = pkgs.nodejs-6_x;
8783
};
8884

85+
regen-script = pkgs.writeScriptBin "regen" ''
86+
export PATH=${makeBinPath [oldHaskellPackages.purescript-derive-lenses cardano-sl-explorer]}:$PATH
87+
cardano-explorer-hs2purs --bridge-path src/Generated/
88+
scripts/generate-explorer-lenses.sh
89+
'';
90+
8991
frontend = { stdenv, python, purescript, mkYarnPackage }:
9092
mkYarnPackage {
9193
name = "cardano-explorer-frontend";
9294
src = generatedSrc;
93-
extraBuildInputs = [ purescript ];
95+
extraBuildInputs = [
96+
purescript
97+
regen-script
98+
];
99+
passthru = { inherit bowerComponents; };
94100
installPhase = ''
95101
# run the build:prod script
96102
export PATH=$(pwd)/node_modules/.bin:$PATH

explorer/frontend/shell.nix

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{ ... }@args:
2+
3+
let
4+
cardanoPkgs = import ../.. args;
5+
frontend = cardanoPkgs.cardano-sl-explorer-frontend;
6+
7+
in
8+
# fixme: cardano-sl-explorer source is not filtered enough, so
9+
# generating files in frontend will cause a rebuild of explorer
10+
# backend. You will just have to wait a little wait to get a shell.
11+
12+
frontend.overrideAttrs (oldAttrs: {
13+
14+
shellHook = ''
15+
help() {
16+
echo "*** To regenerate purescript code, run \`regen'."
17+
echo
18+
echo "*** To build, run \`yarn build:prod'."
19+
echo "*** For dev, run \`yarn server:dev'."
20+
echo
21+
echo "*** To see this message again, run \`help'."
22+
}
23+
24+
echo; echo; help
25+
26+
export PATH=$(pwd)/node_modules/.bin:$PATH
27+
'';
28+
29+
})

0 commit comments

Comments
 (0)