1{ lib, stdenv, fetchurl, buildPackages }:
2
3stdenv.mkDerivation (finalAttrs: {
4 pname = "tzdata";
5 version = "2024a";
6
7 srcs = [
8 (fetchurl {
9 url = "https://data.iana.org/time-zones/releases/tzdata${finalAttrs.version}.tar.gz";
10 hash = "sha256-DQQ0RZrL0gWaeo2h8zBKhKhlkfbtacYkj/+lArbt/+M=";
11 })
12 (fetchurl {
13 url = "https://data.iana.org/time-zones/releases/tzcode${finalAttrs.version}.tar.gz";
14 hash = "sha256-gAcolK3/WkWPHRQ+FuTKHYsqEiycU5naSCy2jLpqH/g=";
15 })
16 ];
17
18 sourceRoot = ".";
19
20 patches = lib.optionals stdenv.hostPlatform.isWindows [
21 ./0001-Add-exe-extension-for-MS-Windows-binaries.patch
22 ];
23
24 outputs = [ "out" "bin" "man" "dev" ];
25 propagatedBuildOutputs = [ ];
26
27 makeFlags = [
28 "TOPDIR=${placeholder "out"}"
29 "TZDIR=${placeholder "out"}/share/zoneinfo"
30 "BINDIR=${placeholder "bin"}/bin"
31 "ZICDIR=${placeholder "bin"}/bin"
32 "ETCDIR=$(TMPDIR)/etc"
33 "TZDEFAULT=tzdefault-to-remove"
34 "LIBDIR=${placeholder "dev"}/lib"
35 "MANDIR=${placeholder "man"}/share/man"
36 "AWK=awk"
37 "CFLAGS=-DHAVE_LINK=0"
38 "CFLAGS+=-DZIC_BLOAT_DEFAULT=\\\"fat\\\""
39 "cc=${stdenv.cc.targetPrefix}cc"
40 "AR=${stdenv.cc.targetPrefix}ar"
41 ] ++ lib.optionals stdenv.hostPlatform.isWindows [
42 "CFLAGS+=-DHAVE_DIRECT_H"
43 "CFLAGS+=-DHAVE_SETENV=0"
44 "CFLAGS+=-DHAVE_SYMLINK=0"
45 "CFLAGS+=-DRESERVE_STD_EXT_IDS"
46 ];
47
48 doCheck = true;
49 # everything except for:
50 # - check_web, because that needs curl and wants to talk to https://validator.w3.org
51 # - check_now, because that depends on the current time
52 checkTarget = "check_back check_character_set check_white_space check_links check_name_lengths check_slashed_abbrs check_sorted check_tables check_ziguard check_zishrink check_tzs";
53
54 installFlags = lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
55 "zic=${buildPackages.tzdata.bin}/bin/zic"
56 ];
57
58 postInstall =
59 ''
60 rm $out/share/zoneinfo-posix
61 rm $out/share/zoneinfo/tzdefault-to-remove
62 mkdir $out/share/zoneinfo/posix
63 ( cd $out/share/zoneinfo/posix; ln -s ../* .; rm posix )
64 mv $out/share/zoneinfo-leaps $out/share/zoneinfo/right
65
66 cp leap-seconds.list $out/share/zoneinfo
67
68 mkdir -p "$dev/include"
69 cp tzfile.h "$dev/include/tzfile.h"
70 '';
71
72 setupHook = ./tzdata-setup-hook.sh;
73
74 meta = with lib; {
75 homepage = "http://www.iana.org/time-zones";
76 description = "Database of current and historical time zones";
77 changelog = "https://github.com/eggert/tz/blob/${finalAttrs.version}/NEWS";
78 license = with licenses; [
79 bsd3 # tzcode
80 publicDomain # tzdata
81 ];
82 platforms = platforms.all;
83 maintainers = with maintainers; [ ajs124 fpletz ];
84 };
85})