nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 buildPackages,
6 postgresql,
7}:
8
9stdenv.mkDerivation (finalAttrs: {
10 pname = "tzdata";
11 version = "2025c";
12
13 srcs = [
14 (fetchurl {
15 url = "https://data.iana.org/time-zones/releases/tzdata${finalAttrs.version}.tar.gz";
16 hash = "sha256-SqeeTv/uU/xAKf/l9uvpeTcoLrzfOG1dLakc6EFC+Vc=";
17 })
18 (fetchurl {
19 url = "https://data.iana.org/time-zones/releases/tzcode${finalAttrs.version}.tar.gz";
20 hash = "sha256-aX6+ZiVESu9QgPWOSdA0JLu1Lgi/SD0921rPEMvRV0A=";
21 })
22 ];
23
24 sourceRoot = ".";
25
26 patches = lib.optionals stdenv.hostPlatform.isWindows [
27 ./0001-Add-exe-extension-for-MS-Windows-binaries.patch
28 ];
29
30 outputs = [
31 "out"
32 "bin"
33 "man"
34 "dev"
35 ];
36 propagatedBuildOutputs = [ ];
37
38 makeFlags = [
39 "TOPDIR=${placeholder "out"}"
40 "TZDIR=${placeholder "out"}/share/zoneinfo"
41 "BINDIR=${placeholder "bin"}/bin"
42 "ZICDIR=${placeholder "bin"}/bin"
43 "ETCDIR=$(TMPDIR)/etc"
44 "TZDEFAULT=tzdefault-to-remove"
45 "LIBDIR=${placeholder "dev"}/lib"
46 "MANDIR=${placeholder "man"}/share/man"
47 "AWK=awk"
48 "CURL=:" # disable network access
49 "CFLAGS=-DHAVE_LINK=0"
50 "CFLAGS+=-DZIC_BLOAT_DEFAULT=\\\"fat\\\""
51 "cc=${stdenv.cc.targetPrefix}cc"
52 "AR=${stdenv.cc.targetPrefix}ar"
53 ]
54 ++ lib.optionals stdenv.hostPlatform.isWindows [
55 "CFLAGS+=-DHAVE_DIRECT_H"
56 "CFLAGS+=-DHAVE_SETENV=0"
57 "CFLAGS+=-DHAVE_SYMLINK=0"
58 "CFLAGS+=-DRESERVE_STD_EXT_IDS"
59 ]
60 ++ lib.optionals stdenv.hostPlatform.isFreeBSD [
61 "CFLAGS+=-DNETBSD_INSPIRED=0"
62 "CFLAGS+=-DSTD_INSPIRED=0"
63 "CFLAGS+=-DUSE_TIMEX_T=1"
64 "CFLAGS+=-DMKTIME_FITS_IN\\(min,max\\)=0"
65 "CFLAGS+=-DEXTERN_TIMEOFF=1"
66 ];
67
68 enableParallelBuilding = true;
69
70 doCheck = true;
71 checkTarget = "check";
72
73 installFlags = lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
74 "zic=${buildPackages.tzdata.bin}/bin/zic"
75 ];
76
77 postInstall = ''
78 rm $out/share/zoneinfo-posix
79 rm $out/share/zoneinfo/tzdefault-to-remove
80 mkdir $out/share/zoneinfo/posix
81 ( cd $out/share/zoneinfo/posix; ln -s ../* .; rm posix )
82 mv $out/share/zoneinfo-leaps $out/share/zoneinfo/right
83
84 cp leap-seconds.list $out/share/zoneinfo
85
86 mkdir -p "$dev/include"
87 cp tzfile.h "$dev/include/tzfile.h"
88 '';
89
90 setupHook = ./tzdata-setup-hook.sh;
91
92 # PostgreSQL is sensitive to tzdata updates, because the test-suite often breaks.
93 # Upstream provides patches very quickly, we just need to apply them until the next
94 # minor releases.
95 passthru.tests = postgresql;
96
97 meta = {
98 homepage = "http://www.iana.org/time-zones";
99 description = "Database of current and historical time zones";
100 changelog = "https://github.com/eggert/tz/blob/${finalAttrs.version}/NEWS";
101 license = with lib.licenses; [
102 bsd3 # tzcode
103 publicDomain # tzdata
104 ];
105 platforms = lib.platforms.all;
106 maintainers = with lib.maintainers; [
107 ajs124
108 fpletz
109 ];
110 };
111})