feat(web/static): Expose drvHash attribute on derivation
This can be used for easy cachebusting of static assets, so that we can serve them all with a really long cache-time easily. Change-Id: I7c9f6beddec58e1caf02cda33bc587590217a939 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3660 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
5c9c4aa566
commit
b1f52b2617
1 changed files with 10 additions and 4 deletions
|
@ -1,6 +1,12 @@
|
||||||
{ pkgs, ... }:
|
# Expose all static assets as a folder. The derivation contains a
|
||||||
|
# `drvHash` attribute which can be used for cache-busting.
|
||||||
|
{ depot, lib, pkgs, ... }:
|
||||||
|
|
||||||
# Needs to be a derivation ...
|
let storeDirLength = with builtins; (stringLength storeDir) + 1;
|
||||||
pkgs.runCommand "tvl-static" {} ''
|
in lib.fix(self: pkgs.runCommand "tvl-static" {
|
||||||
|
passthru = {
|
||||||
|
drvHash = lib.substring storeDirLength 32 self.drvPath;
|
||||||
|
};
|
||||||
|
} ''
|
||||||
cp -r ${./.} $out
|
cp -r ${./.} $out
|
||||||
''
|
'')
|
||||||
|
|
Loading…
Reference in a new issue