about summary refs log tree commit diff
path: root/tools/nixery/server/builder/builder.go
diff options
context:
space:
mode:
Diffstat (limited to 'tools/nixery/server/builder/builder.go')
-rw-r--r--tools/nixery/server/builder/builder.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/tools/nixery/server/builder/builder.go b/tools/nixery/server/builder/builder.go
index 46301d6c6a0c..a249384d9fef 100644
--- a/tools/nixery/server/builder/builder.go
+++ b/tools/nixery/server/builder/builder.go
@@ -27,6 +27,7 @@ import (
 	"log"
 	"os"
 	"os/exec"
+	"sort"
 	"strings"
 
 	"cloud.google.com/go/storage"
@@ -50,12 +51,21 @@ type Image struct {
 //
 // It will expand convenience names under the hood (see the `convenienceNames`
 // function below).
+//
+// Once assembled the image structure uses a sorted representation of
+// the name. This is to avoid unnecessarily cache-busting images if
+// only the order of requested packages has changed.
 func ImageFromName(name string, tag string) Image {
-	packages := strings.Split(name, "/")
+	pkgs := strings.Split(name, "/")
+	expanded := convenienceNames(pkgs)
+
+	sort.Strings(pkgs)
+	sort.Strings(expanded)
+
 	return Image{
-		Name:     name,
+		Name:     strings.Join(pkgs, "/"),
 		Tag:      tag,
-		Packages: convenienceNames(packages),
+		Packages: expanded,
 	}
 }