Skip to content

fix(nix): set TZDIR so timezone tests pass in the sandbox - #11019

Merged
jdx merged 1 commit into
jdx:mainfrom
coryzibell:fix/nix-tzdir
Jul 15, 2026
Merged

jdx merged 1 commit into
jdx:mainfrom
coryzibell:fix/nix-tzdir

Conversation

@coryzibell

@coryzibell coryzibell commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

tera-contrib's now() resolves its timezone via a named tzdb lookup (TimeZone::get("UTC")), unlike date() which uses the compiled-in constant, so tera::tests::test_tera_contrib_helpers and task::task_script_parser::tests::test_task_template_tera_contrib_helpers fail with Unknown timezone: UTC in the Nix sandbox, which provides no zoneinfo.

Setting TZDIR makes both pass rather than skipping them: 1662 passed; 0 failed.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed test failures involving timezone resolution in sandboxed build environments.
    • Tests that use the current time now reliably recognize the UTC timezone.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: e2c1a78e-132f-48e2-a2f6-6a9f5294d576

📥 Commits

Reviewing files that changed from the base of the PR and between d2276c3 and 4813dd1.

📒 Files selected for processing (1)
  • default.nix

📝 Walkthrough

Walkthrough

The Nix build environment now sets TZDIR to the packaged tzdata zoneinfo directory, allowing sandboxed tests that call now() to resolve named timezones such as "UTC".

Changes

Timezone test runtime

Layer / File(s) Summary
Configure timezone database access
default.nix
Sets TZDIR to ${pkgs.tzdata}/share/zoneinfo and documents its requirement for timezone-dependent tests.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Suggested reviewers: mise-en-dev

Poem

I’m a rabbit in the sandbox bright,
With tzdata tucked in just right.
now() hops through UTC’s door,
No missing zones to trip anymore.
Nix builds purr; I thump with delight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: setting TZDIR in the Nix sandbox to make timezone-related tests pass.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes failing timezone-related tests in the Nix sandbox by setting the TZDIR environment variable to the bundled pkgs.tzdata zoneinfo directory in default.nix. Without this, tera-contrib's now() function cannot resolve timezone names (e.g., TimeZone::get("UTC")) because the Nix build sandbox provides no system zoneinfo.

  • Sets TZDIR = "${pkgs.tzdata}/share/zoneinfo" directly in the derivation, which makes Nix automatically add pkgs.tzdata as a dependency and allow sandbox access to the store path.
  • Allows tera::tests::test_tera_contrib_helpers and task::task_script_parser::tests::test_task_template_tera_contrib_helpers to pass rather than fail with Unknown timezone: UTC.

Confidence Score: 5/5

A minimal, targeted Nix config change that adds a missing zoneinfo path for tests — no production code is affected.

The change is a single environment variable addition in default.nix. Referencing ${pkgs.tzdata}/share/zoneinfo as a string creates an automatic Nix store dependency, so the sandbox correctly gains access to the zoneinfo data without any explicit buildInputs entry needed. The fix is idiomatic and the comment explains the root cause clearly.

No files require special attention.

Important Files Changed

Filename Overview
default.nix Adds TZDIR env var pointing to pkgs.tzdata zoneinfo directory so timezone-aware tests pass in the Nix sandbox

Reviews (1): Last reviewed commit: "fix(nix): set TZDIR so timezone tests pa..." | Re-trigger Greptile

@jdx
jdx merged commit 2b479dc into jdx:main Jul 15, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants