1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 cmake,
6 enableShared ? !stdenv.hostPlatform.isStatic,
7
8 # tests
9 mpd,
10 openimageio,
11 fcitx5,
12 spdlog,
13}:
14
15let
16 generic =
17 {
18 version,
19 sha256,
20 patches ? [ ],
21 }:
22 stdenv.mkDerivation {
23 pname = "fmt";
24 inherit version;
25
26 outputs = [
27 "out"
28 "dev"
29 ];
30
31 src = fetchFromGitHub {
32 owner = "fmtlib";
33 repo = "fmt";
34 rev = version;
35 inherit sha256;
36 };
37
38 inherit patches;
39
40 nativeBuildInputs = [ cmake ];
41
42 cmakeFlags = [ "-DBUILD_SHARED_LIBS=${if enableShared then "ON" else "OFF"}" ];
43
44 doCheck = true;
45
46 passthru.tests = {
47 inherit
48 mpd
49 openimageio
50 fcitx5
51 spdlog
52 ;
53 };
54
55 meta = with lib; {
56 description = "Small, safe and fast formatting library";
57 longDescription = ''
58 fmt (formerly cppformat) is an open-source formatting library. It can be
59 used as a fast and safe alternative to printf and IOStreams.
60 '';
61 homepage = "https://fmt.dev/";
62 changelog = "https://github.com/fmtlib/fmt/blob/${version}/ChangeLog.rst";
63 downloadPage = "https://github.com/fmtlib/fmt/";
64 maintainers = [ maintainers.jdehaas ];
65 license = licenses.mit;
66 platforms = platforms.all;
67 };
68 };
69in
70{
71 fmt_8 = generic {
72 version = "8.1.1";
73 sha256 = "sha256-leb2800CwdZMJRWF5b1Y9ocK0jXpOX/nwo95icDf308=";
74 };
75
76 fmt_9 = generic {
77 version = "9.1.0";
78 sha256 = "sha256-rP6ymyRc7LnKxUXwPpzhHOQvpJkpnRFOt2ctvUNlYI0=";
79 };
80
81 fmt_10 = generic {
82 version = "10.2.1";
83 sha256 = "sha256-pEltGLAHLZ3xypD/Ur4dWPWJ9BGVXwqQyKcDWVmC3co=";
84 };
85
86 fmt_11 = generic {
87 version = "11.0.1";
88 sha256 = "sha256-EPidbZxCvysrL64AzbpJDowiNxqy4ii+qwSWAFwf/Ps=";
89 };
90}