feat: Add configuration option for popularity data URL

This commit is contained in:
Vincent Ambo 2019-09-21 12:15:38 +01:00 committed by Vincent Ambo
parent e4d03fdb17
commit 64f74abc4d
5 changed files with 12 additions and 5 deletions

View file

@ -83,6 +83,7 @@ variables:
for building for building
* `NIX_TIMEOUT`: Number of seconds that any Nix builder is allowed to run * `NIX_TIMEOUT`: Number of seconds that any Nix builder is allowed to run
(defaults to 60 (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 * `GCS_SIGNING_KEY`: A Google service account key (in PEM format) that can be
used to sign Cloud Storage URLs used to sign Cloud Storage URLs
* `GCS_SIGNING_ACCOUNT`: Google service account ID that the signing key belongs * `GCS_SIGNING_ACCOUNT`: Google service account ID that the signing key belongs

View file

@ -35,6 +35,9 @@
# layers. To allow for some extensibility (via additional layers), # layers. To allow for some extensibility (via additional layers),
# the default here is set to something a little less than that. # the default here is set to something a little less than that.
maxLayers ? 96, 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)); fetched = (map (deepFetch pkgs) (fromJSON packages));
in foldl' splitter init fetched; in foldl' splitter init fetched;
popularity = builtins.fetchurl { popularity = builtins.fetchurl popularityUrl;
url = "https://storage.googleapis.com/nixery-layers/popularity/nixos-19.03-20190812.json";
sha256 = "16sxd49vqqg2nrhwynm36ba6bc2yff5cd5hf83wi0hanw5sx3svk";
};
# Before actually creating any image layers, the store paths that need to be # 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 # included in the image must be sorted into the layers that they should go

View file

@ -22,7 +22,7 @@
# all arguments of build-image.nix. # all arguments of build-image.nix.
, srcType ? "nixpkgs" , srcType ? "nixpkgs"
, srcArgs ? "nixos-19.03" , srcArgs ? "nixos-19.03"
, tag ? null, name ? null, packages ? null, maxLayers ? null , tag ? null, name ? null, packages ? null, maxLayers ? null, popularityUrl ? null
}@args: }@args:
let pkgs = import ./load-pkgs.nix { inherit srcType srcArgs; }; let pkgs = import ./load-pkgs.nix { inherit srcType srcArgs; };

View file

@ -134,6 +134,10 @@ func BuildImage(ctx *context.Context, cfg *config.Config, cache *LocalCache, ima
"--argstr", "srcArgs", srcArgs, "--argstr", "srcArgs", srcArgs,
} }
if cfg.PopUrl != "" {
args = append(args, "--argstr", "popularityUrl", cfg.PopUrl)
}
cmd := exec.Command("nixery-build-image", args...) cmd := exec.Command("nixery-build-image", args...)
outpipe, err := cmd.StdoutPipe() outpipe, err := cmd.StdoutPipe()

View file

@ -68,6 +68,7 @@ type Config struct {
Pkgs PkgSource // Source for Nix package set Pkgs PkgSource // Source for Nix package set
Timeout string // Timeout for a single Nix builder (seconds) Timeout string // Timeout for a single Nix builder (seconds)
WebDir string // Directory with static web assets WebDir string // Directory with static web assets
PopUrl string // URL to the Nix package popularity count
} }
func FromEnv() (*Config, error) { func FromEnv() (*Config, error) {
@ -83,5 +84,6 @@ func FromEnv() (*Config, error) {
Signing: signingOptsFromEnv(), Signing: signingOptsFromEnv(),
Timeout: getConfig("NIX_TIMEOUT", "Nix builder timeout", "60"), Timeout: getConfig("NIX_TIMEOUT", "Nix builder timeout", "60"),
WebDir: getConfig("WEB_DIR", "Static web file dir", ""), WebDir: getConfig("WEB_DIR", "Static web file dir", ""),
PopUrl: os.Getenv("NIX_POPULARITY_URL"),
}, nil }, nil
} }