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>
		
			
				
	
	
		
			22 lines
		
	
	
	
		
			772 B
		
	
	
	
		
			Nix
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
	
		
			772 B
		
	
	
	
		
			Nix
		
	
	
	
	
	
| # Expose all static assets as a folder. The derivation contains a
 | |
| # `drvHash` attribute which can be used for cache-busting.
 | |
| { depot, lib, pkgs, ... }:
 | |
| 
 | |
| let
 | |
|   storeDirLength = with builtins; (stringLength storeDir) + 1;
 | |
|   logo = depot.web.tvl.logo;
 | |
| in lib.fix(self: pkgs.runCommand "tvl-static" {
 | |
|   passthru = {
 | |
|     # 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
 | |
|   cp -r ${./.}/* $out
 | |
|   cp ${logo.pastelRainbow} $out/logo-animated.svg
 | |
|   cp ${logo.redPng} $out/logo-red.png
 | |
| '')
 |