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

Commit 55614dd

Browse files
committed
[DEVOPS-999] explorer frontend: Replace @gitrev@ with actual rev
This is done in a way that avoids a webpack rebuild every time the git revision changes.
1 parent 8830a72 commit 55614dd

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

explorer/frontend/default.nix

+23-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,29 @@ let
9191
'';
9292
};
9393

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+
94115
in
95116

96-
pkgs.callPackage frontend {
117+
withGitRev (pkgs.callPackage frontend {
97118
inherit (yarn2nix) mkYarnPackage;
98-
}
119+
})

0 commit comments

Comments
 (0)