17 # NOTE: Not coming from vcpkg
18 IMGUI_LINK_GLVND ? !stdenv.hostPlatform.isWindows && (IMGUI_BUILD_OPENGL2_BINDING || IMGUI_BUILD_OPENGL3_BINDING),
20 # The intent is to mirror vcpkg's flags[^1],
21 # but we only actually support Linux and glfw3 until someone contributes the rest
22 # [^1]: https://github.com/microsoft/vcpkg/blob/095ee06e7f60dceef7d713e3f8b1c2eb10d650d7/ports/imgui/CMakeLists.txt#L33-L108
23 IMGUI_BUILD_ALLEGRO5_BINDING ? false,
24 IMGUI_BUILD_ANDROID_BINDING ? stdenv.hostPlatform.isAndroid,
25 IMGUI_BUILD_DX9_BINDING ? false,
26 IMGUI_BUILD_DX10_BINDING ? false,
27 IMGUI_BUILD_DX11_BINDING ? false,
28 IMGUI_BUILD_DX12_BINDING ? false,
29 IMGUI_BUILD_GLFW_BINDING ? !stdenv.hostPlatform.isDarwin,
30 IMGUI_BUILD_GLUT_BINDING ? false,
31 IMGUI_BUILD_METAL_BINDING ? stdenv.hostPlatform.isDarwin,
32 IMGUI_BUILD_OPENGL2_BINDING ? false,
33 IMGUI_BUILD_OPENGL3_BINDING ?
34 IMGUI_BUILD_SDL2_BINDING || IMGUI_BUILD_GLFW_BINDING || IMGUI_BUILD_GLUT_BINDING,
35 IMGUI_BUILD_OSX_BINDING ? stdenv.hostPlatform.isDarwin,
36 IMGUI_BUILD_SDL2_BINDING ?
37 !IMGUI_BUILD_GLFW_BINDING && !stdenv.hostPlatform.isDarwin,
38 IMGUI_BUILD_SDL2_RENDERER_BINDING ? IMGUI_BUILD_SDL2_BINDING,
39 IMGUI_BUILD_VULKAN_BINDING ? false,
40 IMGUI_BUILD_WIN32_BINDING ? false,
41 IMGUI_FREETYPE ? false,
42 IMGUI_FREETYPE_LUNASVG ? false,
43 IMGUI_USE_WCHAR32 ? false,
47 vcpkgSource = applyPatches {
50 # Install imgui into split outputs:
52 url = "https://github.com/microsoft/vcpkg/commit/4108dd75ce9731a4fdcf50fd05034405156eaddf.patch";
53 hash = "sha256-jXbR0NfyuO8EESmva5A+H3WmBfCG83OiA8ZCcWsRhQA=";
59 stdenv.mkDerivation rec {
63 # Note: no "dev" because vcpkg installs include/ and imgui-config.cmake
64 # into different prefixes but expects the merged layout at import time
69 src = fetchFromGitHub {
72 rev = "refs/tags/v${version}";
73 hash = "sha256-6j4keBOAzbBDsV0+R4zTNlsltxz2dJDGI43UIrHXDNM=";
76 cmakeRules = "${vcpkgSource}/ports/imgui";
78 cp "$cmakeRules"/{CMakeLists.txt,*.cmake.in} ./
81 nativeBuildInputs = [ cmake ];
83 buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
84 darwin.apple_sdk.frameworks.ApplicationServices
85 darwin.apple_sdk.frameworks.Cocoa
86 darwin.apple_sdk.frameworks.GameController
89 propagatedBuildInputs =
90 lib.optionals IMGUI_LINK_GLVND [ libGL ]
91 ++ lib.optionals IMGUI_BUILD_GLFW_BINDING [ glfw ]
92 ++ lib.optionals IMGUI_BUILD_SDL2_BINDING [ SDL2 ]
93 ++ lib.optionals IMGUI_BUILD_VULKAN_BINDING [
97 ++ lib.optionals IMGUI_BUILD_METAL_BINDING [ darwin.apple_sdk.frameworks.Metal ];
100 (lib.cmakeBool "IMGUI_BUILD_GLFW_BINDING" IMGUI_BUILD_GLFW_BINDING)
101 (lib.cmakeBool "IMGUI_BUILD_ALLEGRO5_BINDING" IMGUI_BUILD_ALLEGRO5_BINDING)
102 (lib.cmakeBool "IMGUI_BUILD_ANDROID_BINDING" IMGUI_BUILD_ANDROID_BINDING)
103 (lib.cmakeBool "IMGUI_BUILD_DX9_BINDING" IMGUI_BUILD_DX9_BINDING)
104 (lib.cmakeBool "IMGUI_BUILD_DX10_BINDING" IMGUI_BUILD_DX10_BINDING)
105 (lib.cmakeBool "IMGUI_BUILD_DX11_BINDING" IMGUI_BUILD_DX11_BINDING)
106 (lib.cmakeBool "IMGUI_BUILD_DX12_BINDING" IMGUI_BUILD_DX12_BINDING)
107 (lib.cmakeBool "IMGUI_BUILD_GLFW_BINDING" IMGUI_BUILD_GLFW_BINDING)
108 (lib.cmakeBool "IMGUI_BUILD_GLUT_BINDING" IMGUI_BUILD_GLUT_BINDING)
109 (lib.cmakeBool "IMGUI_BUILD_METAL_BINDING" IMGUI_BUILD_METAL_BINDING)
110 (lib.cmakeBool "IMGUI_BUILD_OPENGL2_BINDING" IMGUI_BUILD_OPENGL2_BINDING)
111 (lib.cmakeBool "IMGUI_BUILD_OPENGL3_BINDING" IMGUI_BUILD_OPENGL3_BINDING)
112 (lib.cmakeBool "IMGUI_BUILD_OSX_BINDING" IMGUI_BUILD_OSX_BINDING)
113 (lib.cmakeBool "IMGUI_BUILD_SDL2_BINDING" IMGUI_BUILD_SDL2_BINDING)
114 (lib.cmakeBool "IMGUI_BUILD_SDL2_RENDERER_BINDING" IMGUI_BUILD_SDL2_RENDERER_BINDING)
115 (lib.cmakeBool "IMGUI_BUILD_VULKAN_BINDING" IMGUI_BUILD_VULKAN_BINDING)
116 (lib.cmakeBool "IMGUI_BUILD_WIN32_BINDING" IMGUI_BUILD_WIN32_BINDING)
117 (lib.cmakeBool "IMGUI_FREETYPE" IMGUI_FREETYPE)
118 (lib.cmakeBool "IMGUI_FREETYPE_LUNASVG" IMGUI_FREETYPE_LUNASVG)
119 (lib.cmakeBool "IMGUI_USE_WCHAR32" IMGUI_USE_WCHAR32)
124 demo = callPackage ./demo { };
129 # These flags haven't been tested:
132 || IMGUI_FREETYPE_LUNASVG
133 || IMGUI_BUILD_DX9_BINDING
134 || IMGUI_BUILD_DX10_BINDING
135 || IMGUI_BUILD_DX11_BINDING
136 || IMGUI_BUILD_DX12_BINDING
137 || IMGUI_BUILD_WIN32_BINDING
138 || IMGUI_BUILD_ALLEGRO5_BINDING
139 || IMGUI_BUILD_ANDROID_BINDING;
140 description = "Bloat-free Graphical User interface for C++ with minimal dependencies";
141 homepage = "https://github.com/ocornut/imgui";
142 license = lib.licenses.mit; # vcpkg licensed as MIT too
143 maintainers = with lib.maintainers; [
146 platforms = lib.platforms.all;