1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 fetchpatch,
6 cmake,
7 enableShared ? !stdenv.hostPlatform.isStatic,
8
9 # tests
10 mpd,
11 openimageio,
12 fcitx5,
13 spdlog,
14}:
15
16let
17 generic =
18 {
19 version,
20 hash,
21 patches ? [ ],
22 }:
23 stdenv.mkDerivation {
24 pname = "fmt";
25 inherit version;
26
27 outputs = [
28 "out"
29 "dev"
30 ];
31
32 src = fetchFromGitHub {
33 owner = "fmtlib";
34 repo = "fmt";
35 rev = version;
36 inherit hash;
37 };
38
39 inherit patches;
40
41 nativeBuildInputs = [ cmake ];
42
43 cmakeFlags = [ (lib.cmakeBool "BUILD_SHARED_LIBS" enableShared) ];
44
45 doCheck = true;
46
47 passthru.tests = {
48 inherit
49 mpd
50 openimageio
51 fcitx5
52 spdlog
53 ;
54 };
55
56 meta = with lib; {
57 description = "Small, safe and fast formatting library";
58 longDescription = ''
59 fmt (formerly cppformat) is an open-source formatting library. It can be
60 used as a fast and safe alternative to printf and IOStreams.
61 '';
62 homepage = "https://fmt.dev/";
63 changelog = "https://github.com/fmtlib/fmt/blob/${version}/ChangeLog.rst";
64 downloadPage = "https://github.com/fmtlib/fmt/";
65 maintainers = [ maintainers.jdehaas ];
66 license = licenses.mit;
67 platforms = platforms.all;
68 };
69 };
70in
71{
72 fmt_9 = generic {
73 version = "9.1.0";
74 hash = "sha256-rP6ymyRc7LnKxUXwPpzhHOQvpJkpnRFOt2ctvUNlYI0=";
75 patches = [
76 # Fixes the build with Clang ≥ 18.
77 (fetchpatch {
78 url = "https://github.com/fmtlib/fmt/commit/c4283ec471bd3efdb114bc1ab30c7c7c5e5e0ee0.patch";
79 hash = "sha256-YyB5GY/ZqJQIhhGy0ICMPzfP/OUuyLnciiyv8Nscsec=";
80 })
81 ];
82 };
83
84 fmt_10 = generic {
85 version = "10.2.1";
86 hash = "sha256-pEltGLAHLZ3xypD/Ur4dWPWJ9BGVXwqQyKcDWVmC3co=";
87 };
88
89 fmt_11 = generic {
90 version = "11.0.2";
91 hash = "sha256-IKNt4xUoVi750zBti5iJJcCk3zivTt7nU12RIf8pM+0=";
92 patches = [
93 (fetchpatch {
94 name = "get-rid-of-std-copy-fix-clang.patch";
95 url = "https://github.com/fmtlib/fmt/commit/6e462b89aa22fd5f737ed162d0150e145ccb1914.patch";
96 hash = "sha256-tRU1y1VCxtQ5J2yvFmwUx+YNcQs8izzLImD37KBiCFk=";
97 })
98 ];
99 };
100}