From 71a6c71ac18e343b2f484af8e8d0722428117d78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=B6xtermann?= Date: Tue, 9 Sep 2025 12:12:20 +0200 Subject: [PATCH] feat(nixery): make default tag configurable --- README.md | 1 + config/pkgsource.go | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 40009b0..c337430 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ variables: * `NIXERY_CHANNEL`: The name of a Nix/NixOS channel to use for building * `NIXERY_PKGS_REPO`: URL of a git repository containing a package set (uses locally configured SSH/git credentials) +* `NIXERY_DEFAULT_TAG`: rev/ref to use as the default for `latest`/empty * `NIXERY_PKGS_PATH`: A local filesystem path containing a Nix package set to use for building * `NIXERY_STORAGE_BACKEND`: The type of backend storage to use, currently diff --git a/config/pkgsource.go b/config/pkgsource.go index eb52cfc..5688593 100644 --- a/config/pkgsource.go +++ b/config/pkgsource.go @@ -49,10 +49,14 @@ func (g *GitSource) Render(tag string) (string, string) { "url": g.repository, } - // The 'git' source requires a tag to be present. If the user - // has not specified one, it is assumed that 'HEAD' should be used. + // If the user has not specified a non-default tag, + // use $NIXERY_DEFAULT_TAG or HEAD as the tag. if tag == "latest" || tag == "" { - tag = "HEAD" + if default_tag := os.Getenv("NIXERY_DEFAULT_TAG"); default_tag != "" { + tag = default_tag + } else { + tag = "HEAD" + } } if commitRegex.MatchString(tag) {