Software requiring time zone info is unable to locate tz database without this environment variable on nix.
Code working with time zones might (and probably often does) use similar logic:
getTzDir = fromMaybe defaultTzDir . lookup "TZDIR" <$> getEnvironment
defaultTzDir = "/usr/share/zoneinfo"
More examples:
Alternatively provide way to specify which variables should be preserved(?) (Probably not best idea.)
Note that as a workaround you may put export TZDIR=/etc/zoneinfo at the beginning of your ~/.bashrc.
If an expression depends on tzdata then it should probably be set there, for example https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/compilers/rust/rustc.nix#L149.
@orivej
Indeed, workaround is a good thing to mention. However I am not the only one to work on the project and I am afraid that baking such workarounds into build environment will lead to it being less understandable/maintainable.
My current workaround is to not use pure. To be more concrete: I have Haskell project with this in stack.yaml:
enable: true
# pure: true
pure: false
packages:
- cairo
- pkgconfig
- tzdata
- zlib
(pure is false as workaround for now)
@LnL7 sounds reasonable but for now I am not sure how to do this... but will look into it, thanks for reference. Still, TZDIR is kinda baked even in (g)libc implementations... so would expect this being issue for more sw (even if not noticed)...?
(@LnL7 btw.: I have added tzdata dependency only in hope that it would influence environment of my package… obviously I was mistaken, still nix(os) is still new to me).
Actually it would make sense for tzdata to set TZDIR via some hook.
This is going to be fixed by https://github.com/NixOS/nixpkgs/pull/32237
Alternatively provide way to specify which variables should be preserved(?) (Probably not best idea.)
For reference, we do have impureEnvVars, but it's understandably restricted to fixed-output derivations.
Awesome, thank you :-).
You are welcome! Could you close the issue?
Tested (successfully) with
NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz stack build --bench
(fails without NIX_PATH). Thank you once more.