From b0be0aa6db5e4a465a7bc4cd43bac0fe783bcccc Mon Sep 17 00:00:00 2001 From: Pavel Sobolev Date: Wed, 17 Jul 2024 20:27:31 +0300 Subject: [PATCH 1/3] tracy: reformat --- pkgs/by-name/tr/tracy/package.nix | 157 +++++++++++++++++------------- 1 file changed, 87 insertions(+), 70 deletions(-) diff --git a/pkgs/by-name/tr/tracy/package.nix b/pkgs/by-name/tr/tracy/package.nix index 1c726affff4723b..0bc0ff9d39642a3 100644 --- a/pkgs/by-name/tr/tracy/package.nix +++ b/pkgs/by-name/tr/tracy/package.nix @@ -1,19 +1,20 @@ -{ lib -, stdenv -, fetchFromGitHub - -, capstone -, darwin -, dbus -, freetype -, glfw -, hicolor-icon-theme -, pkg-config -, tbb - -, withWayland ? stdenv.isLinux -, libxkbcommon -, wayland +{ + lib, + stdenv, + fetchFromGitHub, + + capstone, + darwin, + dbus, + freetype, + glfw, + hicolor-icon-theme, + pkg-config, + tbb, + + withWayland ? stdenv.isLinux, + libxkbcommon, + wayland, }: stdenv.mkDerivation rec { @@ -27,36 +28,45 @@ stdenv.mkDerivation rec { hash = "sha256-DN1ExvQ5wcIUyhMAfiakFbZkDsx+5l8VMtYGvSdboPA="; }; - patches = lib.optionals (stdenv.isDarwin && !(lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11")) [ - ./0001-remove-unifiedtypeidentifiers-framework - ]; + patches = lib.optionals ( + stdenv.isDarwin && !(lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11") + ) [ ./0001-remove-unifiedtypeidentifiers-framework ]; nativeBuildInputs = [ pkg-config ]; - buildInputs = [ - capstone - freetype - glfw - ] ++ lib.optionals (stdenv.isLinux && withWayland) [ - libxkbcommon - wayland - ] ++ lib.optionals stdenv.isLinux [ - dbus - hicolor-icon-theme - tbb - ] ++ lib.optionals stdenv.isDarwin [ - darwin.apple_sdk.frameworks.AppKit - darwin.apple_sdk.frameworks.Carbon - ] ++ lib.optionals (stdenv.isDarwin && lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11") [ - darwin.apple_sdk.frameworks.UniformTypeIdentifiers - ]; - - env.NIX_CFLAGS_COMPILE = toString ([ ] + buildInputs = + [ + capstone + freetype + glfw + ] + ++ lib.optionals (stdenv.isLinux && withWayland) [ + libxkbcommon + wayland + ] + ++ lib.optionals stdenv.isLinux [ + dbus + hicolor-icon-theme + tbb + ] + ++ lib.optionals stdenv.isDarwin [ + darwin.apple_sdk.frameworks.AppKit + darwin.apple_sdk.frameworks.Carbon + ] + ++ lib.optionals (stdenv.isDarwin && lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11") [ + darwin.apple_sdk.frameworks.UniformTypeIdentifiers + ]; + + env.NIX_CFLAGS_COMPILE = toString ( + [ ] # Apple's compiler finds a format string security error on # ../../../server/TracyView.cpp:649:34, preventing building. ++ lib.optional stdenv.isDarwin "-Wno-format-security" ++ lib.optional stdenv.isLinux "-ltbb" - ++ lib.optional stdenv.cc.isClang "-faligned-allocation"); + ++ lib.optional stdenv.cc.isClang "-faligned-allocation" + # workaround issue #19098 + ++ lib.optional (stdenv.cc.isClang && stdenv.isDarwin) "-fno-lto" + ); buildPhase = '' runHook preBuild @@ -72,35 +82,38 @@ stdenv.mkDerivation rec { runHook postBuild ''; - installPhase = '' - runHook preInstall - - install -D -m 0755 capture/build/unix/capture-release $out/bin/capture - install -D -m 0755 csvexport/build/unix/csvexport-release $out/bin/tracy-csvexport - install -D -m 0755 import-chrome/build/unix/import-chrome-release $out/bin/import-chrome - install -D -m 0755 library/unix/libtracy-release.so $out/lib/libtracy.so - install -D -m 0755 profiler/build/unix/Tracy-release $out/bin/tracy - install -D -m 0755 update/build/unix/update-release $out/bin/update - - mkdir -p $out/include/Tracy/client - mkdir -p $out/include/Tracy/common - mkdir -p $out/include/Tracy/tracy - - cp -p public/client/*.{h,hpp} $out/include/Tracy/client - cp -p public/common/*.{h,hpp} $out/include/Tracy/common - cp -p public/tracy/*.{h,hpp} $out/include/Tracy/tracy - '' + lib.optionalString stdenv.isLinux '' - substituteInPlace extra/desktop/tracy.desktop \ - --replace Exec=/usr/bin/tracy Exec=tracy - - install -D -m 0644 extra/desktop/application-tracy.xml $out/share/mime/packages/application-tracy.xml - install -D -m 0644 extra/desktop/tracy.desktop $out/share/applications/tracy.desktop - install -D -m 0644 icon/application-tracy.svg $out/share/icons/hicolor/scalable/apps/application-tracy.svg - install -D -m 0644 icon/icon.png $out/share/icons/hicolor/256x256/apps/tracy.png - install -D -m 0644 icon/icon.svg $out/share/icons/hicolor/scalable/apps/tracy.svg - '' + '' - runHook postInstall - ''; + installPhase = + '' + runHook preInstall + + install -D -m 0755 capture/build/unix/capture-release $out/bin/capture + install -D -m 0755 csvexport/build/unix/csvexport-release $out/bin/tracy-csvexport + install -D -m 0755 import-chrome/build/unix/import-chrome-release $out/bin/import-chrome + install -D -m 0755 library/unix/libtracy-release.so $out/lib/libtracy.so + install -D -m 0755 profiler/build/unix/Tracy-release $out/bin/tracy + install -D -m 0755 update/build/unix/update-release $out/bin/update + + mkdir -p $out/include/Tracy/client + mkdir -p $out/include/Tracy/common + mkdir -p $out/include/Tracy/tracy + + cp -p public/client/*.{h,hpp} $out/include/Tracy/client + cp -p public/common/*.{h,hpp} $out/include/Tracy/common + cp -p public/tracy/*.{h,hpp} $out/include/Tracy/tracy + '' + + lib.optionalString stdenv.isLinux '' + substituteInPlace extra/desktop/tracy.desktop \ + --replace Exec=/usr/bin/tracy Exec=tracy + + install -D -m 0644 extra/desktop/application-tracy.xml $out/share/mime/packages/application-tracy.xml + install -D -m 0644 extra/desktop/tracy.desktop $out/share/applications/tracy.desktop + install -D -m 0644 icon/application-tracy.svg $out/share/icons/hicolor/scalable/apps/application-tracy.svg + install -D -m 0644 icon/icon.png $out/share/icons/hicolor/256x256/apps/tracy.png + install -D -m 0644 icon/icon.svg $out/share/icons/hicolor/scalable/apps/tracy.svg + '' + + '' + runHook postInstall + ''; postFixup = lib.optionalString stdenv.isDarwin '' install_name_tool -change libcapstone.4.dylib ${capstone}/lib/libcapstone.4.dylib $out/bin/tracy @@ -109,9 +122,13 @@ stdenv.mkDerivation rec { meta = with lib; { description = "Real time, nanosecond resolution, remote telemetry frame profiler for games and other applications"; homepage = "https://github.com/wolfpld/tracy"; - platforms = platforms.linux ++ platforms.darwin; license = licenses.bsd3; mainProgram = "tracy"; - maintainers = with maintainers; [ mpickering nagisa paveloom ]; + maintainers = with maintainers; [ + mpickering + nagisa + paveloom + ]; + platforms = platforms.linux ++ platforms.darwin; }; } From 352ab2234636f304d34484037dbd8f87defd595f Mon Sep 17 00:00:00 2001 From: Pavel Sobolev Date: Thu, 18 Jul 2024 22:47:20 +0300 Subject: [PATCH 2/3] tracy: 0.10 -> 0.11.1 --- ...01-remove-unifiedtypeidentifiers-framework | 13 -- ...the-uniformtypeidentifiers-framework.patch | 24 ++++ pkgs/by-name/tr/tracy/package.nix | 131 +++++++++--------- 3 files changed, 92 insertions(+), 76 deletions(-) delete mode 100644 pkgs/by-name/tr/tracy/0001-remove-unifiedtypeidentifiers-framework create mode 100644 pkgs/by-name/tr/tracy/dont-use-the-uniformtypeidentifiers-framework.patch diff --git a/pkgs/by-name/tr/tracy/0001-remove-unifiedtypeidentifiers-framework b/pkgs/by-name/tr/tracy/0001-remove-unifiedtypeidentifiers-framework deleted file mode 100644 index 0dc5a7eb68f16ff..000000000000000 --- a/pkgs/by-name/tr/tracy/0001-remove-unifiedtypeidentifiers-framework +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/profiler/build/unix/legacy.mk b/profiler/build/unix/legacy.mk -index 24765f1a..8baffb68 100644 ---- a/profiler/build/unix/legacy.mk -+++ b/profiler/build/unix/legacy.mk -@@ -16,7 +16,7 @@ else - UNAME := $(shell uname -s) - ifeq ($(UNAME),Darwin) - SRC3 += ../../../nfd/nfd_cocoa.m -- LIBS += -framework CoreFoundation -framework AppKit -framework UniformTypeIdentifiers -+ LIBS += -framework CoreFoundation -framework AppKit - else - ifdef TRACY_GTK_FILESELECTOR - SRC += ../../../nfd/nfd_gtk.cpp diff --git a/pkgs/by-name/tr/tracy/dont-use-the-uniformtypeidentifiers-framework.patch b/pkgs/by-name/tr/tracy/dont-use-the-uniformtypeidentifiers-framework.patch new file mode 100644 index 000000000000000..e521178e9d71d27 --- /dev/null +++ b/pkgs/by-name/tr/tracy/dont-use-the-uniformtypeidentifiers-framework.patch @@ -0,0 +1,24 @@ +From 05074295013a2bf7fa1b6af1b6575e5e0c491454 Mon Sep 17 00:00:00 2001 +From: Pavel Sobolev +Date: Thu, 18 Jul 2024 21:54:44 +0300 +Subject: [PATCH] Don't use the `UniformTypeIdentifiers` framework. + +--- + cmake/vendor.cmake | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/cmake/vendor.cmake b/cmake/vendor.cmake +index bd53a4db..8079d8c2 100644 +--- a/cmake/vendor.cmake ++++ b/cmake/vendor.cmake +@@ -182,7 +182,6 @@ if (NOT NO_FILESELECTOR AND NOT EMSCRIPTEN) + + if (APPLE) + find_library(APPKIT_LIBRARY AppKit) +- find_library(UNIFORMTYPEIDENTIFIERS_LIBRARY UniformTypeIdentifiers) + target_link_libraries(TracyNfd PUBLIC ${APPKIT_LIBRARY} ${UNIFORMTYPEIDENTIFIERS_LIBRARY}) + elseif (UNIX) + if (GTK_FILESELECTOR) +-- +2.45.2 + diff --git a/pkgs/by-name/tr/tracy/package.nix b/pkgs/by-name/tr/tracy/package.nix index 0bc0ff9d39642a3..e2c54b0a77ac823 100644 --- a/pkgs/by-name/tr/tracy/package.nix +++ b/pkgs/by-name/tr/tracy/package.nix @@ -3,122 +3,127 @@ stdenv, fetchFromGitHub, + cmake, + ninja, + pkg-config, + wayland-scanner, + capstone, darwin, dbus, freetype, glfw, - hicolor-icon-theme, - pkg-config, tbb, + withGtkFileSelector ? false, + gtk3, + withWayland ? stdenv.isLinux, + libglvnd, libxkbcommon, wayland, + wayland-protocols, }: stdenv.mkDerivation rec { pname = "tracy"; - version = "0.10"; + version = "0.11.1"; src = fetchFromGitHub { owner = "wolfpld"; repo = "tracy"; rev = "v${version}"; - hash = "sha256-DN1ExvQ5wcIUyhMAfiakFbZkDsx+5l8VMtYGvSdboPA="; + hash = "sha256-HofqYJT1srDJ6Y1f18h7xtAbI/Gvvz0t9f0wBNnOZK8="; }; - patches = lib.optionals ( - stdenv.isDarwin && !(lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11") - ) [ ./0001-remove-unifiedtypeidentifiers-framework ]; + patches = lib.optional ( + stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "11" + ) ./dont-use-the-uniformtypeidentifiers-framework.patch; - nativeBuildInputs = [ pkg-config ]; + nativeBuildInputs = + [ + cmake + ninja + pkg-config + ] + ++ lib.optionals stdenv.isLinux [ wayland-scanner ] + ++ lib.optionals stdenv.cc.isClang [ stdenv.cc.cc.libllvm ]; buildInputs = [ capstone freetype - glfw + tbb ] + ++ lib.optionals (stdenv.isLinux && withGtkFileSelector) [ gtk3 ] + ++ lib.optionals (stdenv.isLinux && !withGtkFileSelector) [ dbus ] ++ lib.optionals (stdenv.isLinux && withWayland) [ + libglvnd libxkbcommon wayland + wayland-protocols ] - ++ lib.optionals stdenv.isLinux [ - dbus - hicolor-icon-theme - tbb - ] - ++ lib.optionals stdenv.isDarwin [ - darwin.apple_sdk.frameworks.AppKit - darwin.apple_sdk.frameworks.Carbon - ] + ++ lib.optionals (stdenv.isDarwin || (stdenv.isLinux && !withWayland)) [ glfw ] + ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.AppKit ] ++ lib.optionals (stdenv.isDarwin && lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11") [ darwin.apple_sdk.frameworks.UniformTypeIdentifiers ]; + cmakeFlags = + [ + "-DDOWNLOAD_CAPSTONE=off" + "-DTRACY_STATIC=off" + ] + ++ lib.optional (stdenv.isLinux && withGtkFileSelector) "-DGTK_FILESELECTOR=ON" + ++ lib.optional (stdenv.isLinux && !withWayland) "-DLEGACY=on"; + env.NIX_CFLAGS_COMPILE = toString ( [ ] - # Apple's compiler finds a format string security error on - # ../../../server/TracyView.cpp:649:34, preventing building. - ++ lib.optional stdenv.isDarwin "-Wno-format-security" ++ lib.optional stdenv.isLinux "-ltbb" - ++ lib.optional stdenv.cc.isClang "-faligned-allocation" - # workaround issue #19098 + ++ lib.optional ( + stdenv.isDarwin && lib.versionOlder stdenv.hostPlatform.darwinMinVersion "10.13" + ) "-fno-aligned-allocation" + # Workaround for https://github.com/NixOS/nixpkgs/issues/19098 ++ lib.optional (stdenv.cc.isClang && stdenv.isDarwin) "-fno-lto" ); - buildPhase = '' - runHook preBuild + dontUseCmakeBuildDir = true; - make -j $NIX_BUILD_CORES -C capture/build/unix release - make -j $NIX_BUILD_CORES -C csvexport/build/unix release - make -j $NIX_BUILD_CORES -C import-chrome/build/unix release - make -j $NIX_BUILD_CORES -C library/unix release - make -j $NIX_BUILD_CORES -C profiler/build/unix release \ - ${lib.optionalString (stdenv.isLinux && !withWayland) "LEGACY=1"} - make -j $NIX_BUILD_CORES -C update/build/unix release + postConfigure = '' + cmake -B capture/build -S capture $cmakeFlags + cmake -B csvexport/build -S csvexport $cmakeFlags + cmake -B import/build -S import $cmakeFlags + cmake -B profiler/build -S profiler $cmakeFlags + cmake -B update/build -S update $cmakeFlags + ''; - runHook postBuild + postBuild = '' + ninja -C capture/build + ninja -C csvexport/build + ninja -C import/build + ninja -C profiler/build + ninja -C update/build ''; - installPhase = + postInstall = '' - runHook preInstall - - install -D -m 0755 capture/build/unix/capture-release $out/bin/capture - install -D -m 0755 csvexport/build/unix/csvexport-release $out/bin/tracy-csvexport - install -D -m 0755 import-chrome/build/unix/import-chrome-release $out/bin/import-chrome - install -D -m 0755 library/unix/libtracy-release.so $out/lib/libtracy.so - install -D -m 0755 profiler/build/unix/Tracy-release $out/bin/tracy - install -D -m 0755 update/build/unix/update-release $out/bin/update - - mkdir -p $out/include/Tracy/client - mkdir -p $out/include/Tracy/common - mkdir -p $out/include/Tracy/tracy - - cp -p public/client/*.{h,hpp} $out/include/Tracy/client - cp -p public/common/*.{h,hpp} $out/include/Tracy/common - cp -p public/tracy/*.{h,hpp} $out/include/Tracy/tracy + install -D -m 0555 capture/build/tracy-capture -t $out/bin + install -D -m 0555 csvexport/build/tracy-csvexport $out/bin + install -D -m 0555 import/build/{tracy-import-chrome,tracy-import-fuchsia} -t $out/bin + install -D -m 0555 profiler/build/tracy-profiler $out/bin/tracy + install -D -m 0555 update/build/tracy-update -t $out/bin '' + lib.optionalString stdenv.isLinux '' substituteInPlace extra/desktop/tracy.desktop \ - --replace Exec=/usr/bin/tracy Exec=tracy + --replace-fail Exec=/usr/bin/tracy Exec=tracy - install -D -m 0644 extra/desktop/application-tracy.xml $out/share/mime/packages/application-tracy.xml - install -D -m 0644 extra/desktop/tracy.desktop $out/share/applications/tracy.desktop - install -D -m 0644 icon/application-tracy.svg $out/share/icons/hicolor/scalable/apps/application-tracy.svg - install -D -m 0644 icon/icon.png $out/share/icons/hicolor/256x256/apps/tracy.png - install -D -m 0644 icon/icon.svg $out/share/icons/hicolor/scalable/apps/tracy.svg - '' - + '' - runHook postInstall + install -D -m 0444 extra/desktop/application-tracy.xml $out/share/mime/packages/application-tracy.xml + install -D -m 0444 extra/desktop/tracy.desktop $out/share/applications/tracy.desktop + install -D -m 0444 icon/application-tracy.svg $out/share/icons/hicolor/scalable/apps/application-tracy.svg + install -D -m 0444 icon/icon.png $out/share/icons/hicolor/256x256/apps/tracy.png + install -D -m 0444 icon/icon.svg $out/share/icons/hicolor/scalable/apps/tracy.svg ''; - postFixup = lib.optionalString stdenv.isDarwin '' - install_name_tool -change libcapstone.4.dylib ${capstone}/lib/libcapstone.4.dylib $out/bin/tracy - ''; - meta = with lib; { description = "Real time, nanosecond resolution, remote telemetry frame profiler for games and other applications"; homepage = "https://github.com/wolfpld/tracy"; From 129cc8409296efecadcfb34526a9df4dfe1ac364 Mon Sep 17 00:00:00 2001 From: Pavel Sobolev Date: Sun, 16 Jun 2024 17:21:33 +0300 Subject: [PATCH 3/3] tracy: split the package into `tracy-wayland` and `tracy-glfw` --- nixos/doc/manual/release-notes/rl-2411.section.md | 6 +++--- pkgs/by-name/tr/tracy/package.nix | 5 ++++- pkgs/top-level/all-packages.nix | 4 +++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/nixos/doc/manual/release-notes/rl-2411.section.md b/nixos/doc/manual/release-notes/rl-2411.section.md index 32c3dc2f54287ca..6fdd0c55d460dd9 100644 --- a/nixos/doc/manual/release-notes/rl-2411.section.md +++ b/nixos/doc/manual/release-notes/rl-2411.section.md @@ -409,9 +409,9 @@ - `/share/vim-plugins` now only gets linked if `programs.vim.enable` is enabled -- The `tracy` package no longer works on X11, since it's moved to Wayland - support, which is the intended default behavior by Tracy maintainers. - X11 users have to switch to the new package `tracy-x11`. +- The profiler from the `tracy` package no longer works on X11, since it + requires Wayland now, which is the intended default behavior by Tracy + maintainers. X11 users have to switch to the new package `tracy-glfw`. - The `services.prometheus.exporters.minio` option has been removed, as it's upstream implementation was broken and unmaintained. Minio now has built-in [Prometheus metrics exposure](https://min.io/docs/minio/linux/operations/monitoring/collect-minio-metrics-using-prometheus.html), which can be used instead. diff --git a/pkgs/by-name/tr/tracy/package.nix b/pkgs/by-name/tr/tracy/package.nix index e2c54b0a77ac823..d7d7b31f2950bf1 100644 --- a/pkgs/by-name/tr/tracy/package.nix +++ b/pkgs/by-name/tr/tracy/package.nix @@ -25,8 +25,11 @@ wayland-protocols, }: +assert withGtkFileSelector -> stdenv.isLinux; +assert withWayland -> stdenv.isLinux; + stdenv.mkDerivation rec { - pname = "tracy"; + pname = if withWayland then "tracy-wayland" else "tracy-glfw"; version = "0.11.1"; src = fetchFromGitHub { diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 72a2be0f2dff67e..5b104537b568661 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -7273,7 +7273,9 @@ with pkgs; tracker = callPackage ../development/libraries/tracker { }; - tracy-x11 = callPackage ../by-name/tr/tracy/package.nix { withWayland = false; }; + tracy = callPackage ../by-name/tr/tracy/package.nix { withWayland = stdenv.isLinux; }; + tracy-glfw = callPackage ../by-name/tr/tracy/package.nix { withWayland = false; }; + tracy-wayland = callPackage ../by-name/tr/tracy/package.nix { withWayland = true; }; trivy = callPackage ../tools/admin/trivy { };