From 4496aa33ed8cc493127ad22a2aaf871d3a05b863 Mon Sep 17 00:00:00 2001 From: Ture Bentzin Date: Sun, 6 Sep 2026 19:48:16 +0000 Subject: [PATCH 1/3] update: introduce nix flake --- .envrc | 1 + .gitignore | 4 ++ flake.lock | 61 ++++++++++++++++++ flake.nix | 184 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 250 insertions(+) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..a5dbbcb --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake . diff --git a/.gitignore b/.gitignore index 68bc17f..3f0bd3c 100644 --- a/.gitignore +++ b/.gitignore @@ -152,6 +152,10 @@ dmypy.json # Cython debug symbols cython_debug/ +# Nix +result +.direnv/ + # PyCharm # JetBrains specific template is maintained in a separate JetBrains.gitignore that can # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..69815be --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1788450739, + "narHash": "sha256-glZLQlzIn1fXH6PazR2iUmTo7kzzyYSshrWhLS9TqCU=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "31729ca8cbdb4fa927b34e5f4353e6a83f39e993", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1788584326, + "narHash": "sha256-Fd3OB8J9JhgliQwOKcqx4M672CInxi1I5VnwsaXeSQo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6713828a351efa628b025a1adf7f43cbf8597513", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-26.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1788057806, + "narHash": "sha256-DTQSMxzDWmT0zhguthvegnVkn7CFqGCv4IHCzk5ZUpM=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "596e2e3940e09b2abbeb03f75fa1828c57fcd72c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..b3fa136 --- /dev/null +++ b/flake.nix @@ -0,0 +1,184 @@ +{ + description = "Development environment and packages for Monal DebugTools"; + + inputs = { + flake-parts.url = "github:hercules-ci/flake-parts"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05"; + }; + + outputs = + inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ + "x86_64-linux" + "aarch64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; + + perSystem = + { pkgs, ... }: + let + projectName = "debugtools"; + pythonBase = pkgs.python3; + + mkApp = program: description: { + type = "app"; + inherit program; + meta = { inherit description; }; + }; + + python = pythonBase.withPackages ( + pythonPackages: with pythonPackages; [ + platformdirs + pyqt5 + qdarkstyle + ] + ); + + developmentPython = pythonBase.withPackages ( + pythonPackages: with pythonPackages; [ + kivy + platformdirs + pyjnius + pyqt5 + pyinstaller + pytest + qdarkstyle + ruff + ] + ); + + desktopTools = pkgs.stdenvNoCC.mkDerivation { + pname = "${projectName}-desktop"; + version = "unstable"; + src = ./src; + + nativeBuildInputs = [ + pkgs.makeWrapper + pkgs.qt5.wrapQtAppsHook + ]; + + dontBuild = true; + + installPhase = '' + runHook preInstall + + installRoot="$out/share/${projectName}" + mkdir -p "$installRoot" "$out/bin" + cp -r shared CrashAnalyzer LogViewer "$installRoot/" + cp CrashAnalyzer.py LogViewer.py "$installRoot/" + + makeWrapper ${python}/bin/python "$out/bin/crash-analyzer" \ + --add-flags "$installRoot/CrashAnalyzer.py" + makeWrapper ${python}/bin/python "$out/bin/log-viewer" \ + --add-flags "$installRoot/LogViewer.py" + + runHook postInstall + ''; + + meta = { + description = "Desktop crash-analysis and rawlog-viewing tools for Monal"; + homepage = "https://github.com/monal-im/DebugTools"; + license = pkgs.lib.licenses.bsd2; + mainProgram = "log-viewer"; + platforms = pkgs.lib.platforms.unix; + }; + }; + + symbolTools = pkgs.stdenv.mkDerivation { + pname = "${projectName}-symbol-tools"; + version = "unstable"; + src = ./tools/symbol_extractor; + + nativeBuildInputs = [ pkgs.makeWrapper ]; + buildInputs = [ pkgs.sqlite ]; + + buildPhase = '' + runHook preBuild + $CXX -std=c++20 -O2 -o symbol-extractor symbol_extractor.cpp -lsqlite3 + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + installRoot="$out/share/${projectName}/symbol-tools" + mkdir -p "$installRoot" "$out/bin" + install -Dm755 symbol-extractor "$out/bin/symbol-extractor" + install -Dm644 merger.py "$installRoot/merger.py" + install -Dm644 symbolicator.py "$installRoot/symbolicator.py" + + makeWrapper ${pythonBase}/bin/python "$out/bin/symbols-db-merger" \ + --add-flags "$installRoot/merger.py" + makeWrapper ${pythonBase}/bin/python "$out/bin/symbolicator" \ + --add-flags "$installRoot/symbolicator.py" + + runHook postInstall + ''; + + meta = { + description = "Mach-O symbol extraction, merging, and symbolication tools"; + homepage = "https://github.com/monal-im/DebugTools"; + license = pkgs.lib.licenses.bsd2; + mainProgram = "symbol-extractor"; + platforms = pkgs.lib.platforms.unix; + }; + }; + + debugtools = pkgs.symlinkJoin { + name = "${projectName}-unstable"; + paths = [ + desktopTools + symbolTools + ]; + meta = desktopTools.meta // { + description = "Monal DebugTools desktop and symbol utilities"; + }; + }; + in + { + packages = { + default = debugtools; + inherit debugtools; + desktop = desktopTools; + symbol-tools = symbolTools; + }; + + apps = { + default = mkApp "${desktopTools}/bin/log-viewer" "Run the Monal Log Viewer"; + log-viewer = mkApp "${desktopTools}/bin/log-viewer" "Run the Monal Log Viewer"; + crash-analyzer = mkApp "${desktopTools}/bin/crash-analyzer" "Run the Monal Crash Analyzer"; + symbol-extractor = mkApp "${symbolTools}/bin/symbol-extractor" "Extract symbols from Apple system libraries"; + symbolicator = mkApp "${symbolTools}/bin/symbolicator" "Symbolicate an Apple crash log"; + symbols-db-merger = mkApp "${symbolTools}/bin/symbols-db-merger" "Merge two symbol databases"; + }; + + checks = { + inherit desktopTools symbolTools; + }; + + formatter = pkgs.nixfmt; + + devShells.default = pkgs.mkShell { + name = "${projectName}-devshell"; + + packages = [ + developmentPython + pkgs.git-lfs + pkgs.gnumake + pkgs.jdk17_headless + pkgs.nixfmt + pkgs.pkg-config + pkgs.sqlite + pkgs.stdenv.cc + ]; + + shellHook = '' + echo "DebugTools development shell" + echo "Python: $(python --version)" + ''; + }; + }; + }; +} From 31dfdcc7919031f43585bc9228586827066b3425 Mon Sep 17 00:00:00 2001 From: Ture Bentzin Date: Sun, 6 Sep 2026 19:48:30 +0000 Subject: [PATCH 2/3] docs: document nix development workflow --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 2b65e5e..04e9777 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,20 @@ The `tools/symbol_extractor` directory contains a C++ tool capable of generating See [the readme](tools/symbol_extractor/README.md) in [that directory](tools/symbol_extractor/) for all the details. I've added a precompiled symbols database using git lfs. It contains symbols of iOS 18.5 (22F76), 18.1.1 (22B91) and 16.7.11 (20H360). + +## Nix development and packaging + +Enter the development environment with `nix develop` or let direnv load it using the included `.envrc`. +The shell provides Python with the desktop and mobile UI dependencies, PyInstaller, the C++ toolchain, SQLite, Git LFS, +pytest, Ruff and the Nix formatter. + +Build all desktop and symbol tools with `nix build`. Individual packages are available as `.#desktop` and +`.#symbol-tools`. The packaged applications can also be launched directly: + +```sh +nix run .#log-viewer +nix run .#crash-analyzer +nix run .#symbol-extractor -- DIRECTORY_WITH_SYMBOLS +nix run .#symbolicator -- CRASH_LOG SYMBOLS_DB +nix run .#symbols-db-merger -- MAIN_DB SOURCE_DB +``` From 3d505138db6e0abf67e8ecf12618d12910bfd53e Mon Sep 17 00:00:00 2001 From: Ture Bentzin Date: Sun, 6 Sep 2026 19:58:25 +0000 Subject: [PATCH 3/3] update: cleanup flake --- flake.nix | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/flake.nix b/flake.nix index b3fa136..937696a 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "Development environment and packages for Monal DebugTools"; + description = "Flake for Monal DebugTools"; inputs = { flake-parts.url = "github:hercules-ci/flake-parts"; @@ -163,21 +163,20 @@ devShells.default = pkgs.mkShell { name = "${projectName}-devshell"; - packages = [ - developmentPython - pkgs.git-lfs - pkgs.gnumake - pkgs.jdk17_headless - pkgs.nixfmt - pkgs.pkg-config - pkgs.sqlite - pkgs.stdenv.cc - ]; - - shellHook = '' - echo "DebugTools development shell" - echo "Python: $(python --version)" - ''; + packages = + with pkgs; + [ + git-lfs + gnumake + jdk17_headless + nixfmt + pkg-config + sqlite + stdenv.cc + ] + ++ [ + developmentPython + ]; }; }; };