Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake .
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions README.md

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not add the nix deployment option in the README!

Original file line number Diff line number Diff line change
Expand Up @@ -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
```
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

183 changes: 183 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
{
description = "Flake 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 =
with pkgs;
[
git-lfs
gnumake
jdk17_headless
nixfmt
pkg-config
sqlite
stdenv.cc
]
++ [
developmentPython
];
};
};
};
}