fix(web/static): avoid drvHash unnecessarily inflating closures

The string context of drvPath apparently causes a derivation to
_directly_ reference the whole dependency closure of the derivation
drvPath belongs to. This not only is unnecessary in this case (since we
are using drvHash to construct HTTP URLs which are primarily contigent
on the deployed configuration and not the shape of the nix store), but
also creates a very confusing derivation (e. g. web.tvl's index.html
would *directly* reference pandoc).

Change-Id: I6e9900e9e35fbd639061e53322e4ccb3fbb7e7ec
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3862
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
This commit is contained in:
sterni 2021-11-13 13:43:43 +01:00
parent e2fbc10ebd
commit 53ab5716aa

View file

@ -7,7 +7,12 @@ let
logo = depot.web.tvl.logo;
in lib.fix(self: pkgs.runCommand "tvl-static" {
passthru = {
drvHash = lib.substring storeDirLength 32 self.drvPath;
# Preserving the string context here makes little sense: While we are
# referencing this derivation, we are not doing so via the nix store,
# so it makes little sense for Nix to police the references.
drvHash = builtins.unsafeDiscardStringContext (
lib.substring storeDirLength 32 self.drvPath
);
};
} ''
mkdir $out