|
46 | 46 | nodejs = pkgs.nodejs-6_x;
|
47 | 47 | };
|
48 | 48 |
|
| 49 | + regen-script = pkgs.writeScriptBin "regen" '' |
| 50 | + export PATH=${makeBinPath [oldHaskellPackages.purescript-derive-lenses cardano-sl-explorer]}:$PATH |
| 51 | + cardano-explorer-hs2purs --bridge-path src/Generated/ |
| 52 | + scripts/generate-explorer-lenses.sh |
| 53 | + ''; |
| 54 | + |
49 | 55 | frontend = { stdenv, python, purescript, mkYarnPackage }:
|
50 | 56 | mkYarnPackage {
|
51 | 57 | name = "cardano-explorer-frontend";
|
|
56 | 62 | oldHaskellPackages.purescript-derive-lenses
|
57 | 63 | cardano-sl-explorer
|
58 | 64 | purescript
|
| 65 | + regen-script |
59 | 66 | ];
|
60 | 67 | passthru = { inherit bowerComponents; };
|
61 | 68 | postConfigure = ''
|
62 | 69 | rm -rf .psci_modules .pulp-cache bower_components output result
|
63 | 70 |
|
64 | 71 | # Purescript code generation
|
65 |
| - cardano-explorer-hs2purs --bridge-path src/Generated/ |
66 |
| - scripts/generate-explorer-lenses.sh |
| 72 | + regen |
67 | 73 |
|
68 | 74 | # Frontend dependencies
|
69 | 75 | ln -s ${bowerComponents}/bower_components .
|
|
85 | 91 | '';
|
86 | 92 | };
|
87 | 93 |
|
| 94 | + # Stamps the frontend with the git revision in a way that avoids |
| 95 | + # a webpack rebuild when the git revision changes. |
| 96 | + # This will just replace @GITREV@ in all javascript files. |
| 97 | + # See also: cardano-sl/scripts/set-git-rev/default.nix |
| 98 | + withGitRev = drvOut: let |
| 99 | + drvOutOutputs = drvOut.outputs or ["out"]; |
| 100 | + in |
| 101 | + pkgs.runCommand drvOut.name { |
| 102 | + outputs = drvOutOutputs; |
| 103 | + passthru = drvOut.drvAttrs |
| 104 | + // (drvOut.passthru or {}) |
| 105 | + // { inherit gitrev; }; |
| 106 | + } |
| 107 | + (concatMapStrings (output: '' |
| 108 | + cp -a "${drvOut.${output}}" "${"$"}${output}" |
| 109 | + chmod -R +w "${"$"}${output}" |
| 110 | + find "${"$"}${output}" -type f -name '*.js' \ |
| 111 | + -exec echo Setting gitrev in {} ';' \ |
| 112 | + -exec sed -i 's/@GITREV@/${gitrev}/g' {} ';' |
| 113 | + '') drvOutOutputs); |
| 114 | + |
88 | 115 | in
|
89 | 116 |
|
90 |
| - pkgs.callPackage frontend { |
| 117 | + withGitRev (pkgs.callPackage frontend { |
91 | 118 | inherit (yarn2nix) mkYarnPackage;
|
92 |
| - } |
| 119 | + }) |
0 commit comments