Adds a Nix cache proxy which can be used to send a Nix cache lookup to the first available cache that has the given NAR. We will use this for dynamically created builders. Relates to b/432. Change-Id: If970d2393e43ba032b5b7d653f2b92f6ac0eab63 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12949 Tested-by: BuildkiteCI Autosubmit: tazjin <tazjin@tvl.su> Reviewed-by: sterni <sternenseemann@systemli.org>
		
			
				
	
	
		
			42 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
package config
 | 
						|
 | 
						|
import (
 | 
						|
	"flag"
 | 
						|
	"strings"
 | 
						|
)
 | 
						|
 | 
						|
var (
 | 
						|
	Host     = flag.String("host", "localhost", "host on which to listen for incoming requests")
 | 
						|
	Port     = flag.Int("port", 2243, "port on which to listen for incoming requests")
 | 
						|
	Debug    = flag.Bool("debug", false, "whether debug logging should be enabled")
 | 
						|
	JSON     = flag.Bool("json", false, "whether logging should be in JSON format")
 | 
						|
	Ticker   = flag.Int("ticker", 5, "interval in seconds between statistics tickers")
 | 
						|
	Priority = flag.Int("priority", 50, "Nix cache priority with which to serve clients")
 | 
						|
 | 
						|
	Tailscale = flag.Bool("tailscale", false, "whether caches should be discovered on Tailscale")
 | 
						|
	TSTag     = flag.String("tailscale-tag", "tag:nix-cache", "Tailscale tag to use for discovery")
 | 
						|
 | 
						|
	CachePort = flag.Int("cache-port", 80, "port at which to connect to binary cache on each node")
 | 
						|
	CacheHost = flag.String("cache-host", "", "Host header to send to each binary cache")
 | 
						|
 | 
						|
	Caches []string
 | 
						|
)
 | 
						|
 | 
						|
type stringSliceFlag []string
 | 
						|
 | 
						|
func (s *stringSliceFlag) String() string {
 | 
						|
	if len(*s) == 0 {
 | 
						|
		return "[ ]"
 | 
						|
	}
 | 
						|
 | 
						|
	return "[ " + strings.Join(*s, " ") + " ]"
 | 
						|
}
 | 
						|
 | 
						|
func (s *stringSliceFlag) Set(value string) error {
 | 
						|
	*s = append(*s, value)
 | 
						|
	return nil
 | 
						|
}
 | 
						|
 | 
						|
func init() {
 | 
						|
	flag.Var((*stringSliceFlag)(&Caches), "cache", "Upstream cache URL (can be specified multiple times)")
 | 
						|
}
 |