about summary refs log tree commit diff
path: root/tools/nixery
diff options
context:
space:
mode:
Diffstat (limited to 'tools/nixery')
-rw-r--r--tools/nixery/README.md1
-rw-r--r--tools/nixery/build-image/build-image.nix8
-rw-r--r--tools/nixery/build-image/default.nix2
-rw-r--r--tools/nixery/server/builder/builder.go4
-rw-r--r--tools/nixery/server/config/config.go2
5 files changed, 12 insertions, 5 deletions
diff --git a/tools/nixery/README.md b/tools/nixery/README.md
index 3bc6df845a7f..3026451c74e0 100644
--- a/tools/nixery/README.md
+++ b/tools/nixery/README.md
@@ -83,6 +83,7 @@ variables:
   for building
 * `NIX_TIMEOUT`: Number of seconds that any Nix builder is allowed to run
   (defaults to 60
+* `NIX_POPULARITY_URL`: URL to a file containing popularity data for the package set (see `popcount/`)
 * `GCS_SIGNING_KEY`: A Google service account key (in PEM format) that can be
   used to sign Cloud Storage URLs
 * `GCS_SIGNING_ACCOUNT`: Google service account ID that the signing key belongs
diff --git a/tools/nixery/build-image/build-image.nix b/tools/nixery/build-image/build-image.nix
index cd0ef91b3135..8f54f53261b2 100644
--- a/tools/nixery/build-image/build-image.nix
+++ b/tools/nixery/build-image/build-image.nix
@@ -35,6 +35,9 @@
   # layers. To allow for some extensibility (via additional layers),
   # the default here is set to something a little less than that.
   maxLayers ? 96,
+  # Popularity data for layer solving is fetched from the URL passed
+  # in here.
+  popularityUrl ? "https://storage.googleapis.com/nixery-layers/popularity/popularity-19.03.173490.5271f8dddc0.json",
 
   ...
 }:
@@ -101,10 +104,7 @@ let
         fetched = (map (deepFetch pkgs) (fromJSON packages));
     in foldl' splitter init fetched;
 
-  popularity = builtins.fetchurl {
-    url = "https://storage.googleapis.com/nixery-layers/popularity/nixos-19.03-20190812.json";
-    sha256 = "16sxd49vqqg2nrhwynm36ba6bc2yff5cd5hf83wi0hanw5sx3svk";
-  };
+  popularity = builtins.fetchurl popularityUrl;
 
   # Before actually creating any image layers, the store paths that need to be
   # included in the image must be sorted into the layers that they should go
diff --git a/tools/nixery/build-image/default.nix b/tools/nixery/build-image/default.nix
index 6b1cea6f0ca2..3bb5d62fb0d5 100644
--- a/tools/nixery/build-image/default.nix
+++ b/tools/nixery/build-image/default.nix
@@ -22,7 +22,7 @@
   # all arguments of build-image.nix.
 , srcType ? "nixpkgs"
 , srcArgs ? "nixos-19.03"
-, tag ? null, name ? null, packages ? null, maxLayers ? null
+, tag ? null, name ? null, packages ? null, maxLayers ? null, popularityUrl ? null
 }@args:
 
 let pkgs = import ./load-pkgs.nix { inherit srcType srcArgs; };
diff --git a/tools/nixery/server/builder/builder.go b/tools/nixery/server/builder/builder.go
index 0ded94dfad01..b2e183b5a2b7 100644
--- a/tools/nixery/server/builder/builder.go
+++ b/tools/nixery/server/builder/builder.go
@@ -134,6 +134,10 @@ func BuildImage(ctx *context.Context, cfg *config.Config, cache *LocalCache, ima
 			"--argstr", "srcArgs", srcArgs,
 		}
 
+		if cfg.PopUrl != "" {
+			args = append(args, "--argstr", "popularityUrl", cfg.PopUrl)
+		}
+
 		cmd := exec.Command("nixery-build-image", args...)
 
 		outpipe, err := cmd.StdoutPipe()
diff --git a/tools/nixery/server/config/config.go b/tools/nixery/server/config/config.go
index ea1bb1ab4532..ac8820f23116 100644
--- a/tools/nixery/server/config/config.go
+++ b/tools/nixery/server/config/config.go
@@ -68,6 +68,7 @@ type Config struct {
 	Pkgs    PkgSource                 // Source for Nix package set
 	Timeout string                    // Timeout for a single Nix builder (seconds)
 	WebDir  string                    // Directory with static web assets
+	PopUrl  string                    // URL to the Nix package popularity count
 }
 
 func FromEnv() (*Config, error) {
@@ -83,5 +84,6 @@ func FromEnv() (*Config, error) {
 		Signing: signingOptsFromEnv(),
 		Timeout: getConfig("NIX_TIMEOUT", "Nix builder timeout", "60"),
 		WebDir:  getConfig("WEB_DIR", "Static web file dir", ""),
+		PopUrl:  os.Getenv("NIX_POPULARITY_URL"),
 	}, nil
 }