Merge pull request #624 from mavericm1/fix-nix-build-env
Fix Nix Linux development and profiling environment
This commit is contained in:
4 files changed
+70
-12
No files matched your search
@@ -21,6 +21,8 @@ flutter build web --release
|
||||
|
||||
The versioned web build uses `dart run build_pipe:build` (also `bun run build`). Web deployment pins Flutter 3.41.2; other CI jobs track stable. Read `pubspec.yaml` for current app version and dependencies rather than copying them into this guide.
|
||||
|
||||
For Linux, use `nix develop`; see [Linux with Nix](README.md#linux-with-nix) for the pinned SDK, native build checks, cache troubleshooting, and Sysprof host prerequisites.
|
||||
|
||||
## Architecture and important files
|
||||
|
||||
| Area | Source |
|
||||
|
||||
@@ -150,6 +150,59 @@ The matrix describes implemented functionality, not a guarantee that every featu
|
||||
flutter run
|
||||
```
|
||||
|
||||
### Linux with Nix
|
||||
|
||||
Enter the development shell from the repository root:
|
||||
|
||||
```bash
|
||||
nix develop
|
||||
flutter --version
|
||||
pkg-config --exists gtk+-3.0 glib-2.0 gio-2.0 sysprof-capture-4
|
||||
flutter pub get
|
||||
flutter build linux --debug
|
||||
flutter build linux --profile
|
||||
```
|
||||
|
||||
The lockfile currently supplies Flutter 3.47.4 and its matching Dart SDK. The
|
||||
app requires Flutter 3.41.2 or newer. The Linux shell provides wrapped Clang
|
||||
compilers, native headers and libraries, and Sysprof capture development files.
|
||||
Android SDK warnings do not prevent Linux builds.
|
||||
|
||||
If an SDK or toolchain update leaves CMake using an old compiler or install
|
||||
prefix, remove the affected generated cache, for example
|
||||
`rm -f build/linux/x64/profile/CMakeCache.txt`, and rebuild. If widget tests
|
||||
report that `ink_sparkle.frag` cannot be decoded after an SDK update, remove
|
||||
the generated `build/unit_test_assets` directory and rerun `flutter test`.
|
||||
|
||||
Launch the profile bundle from a graphical session (replace `x64` with `arm64`
|
||||
on ARM Linux):
|
||||
|
||||
```bash
|
||||
build/linux/x64/profile/bundle/meshcore_open
|
||||
```
|
||||
|
||||
To record with Sysprof, launch the app through the recorder and press Ctrl+C
|
||||
when finished. Use a new capture filename for each recording:
|
||||
|
||||
```bash
|
||||
sysprof-cli meshcore.syscap -- build/linux/x64/profile/bundle/meshcore_open
|
||||
sysprof meshcore.syscap
|
||||
```
|
||||
|
||||
CPU stack sampling requires host support for kernel perf events and appropriate
|
||||
permissions, potentially through the Sysprof system service and polkit. The Nix
|
||||
shell supplies tools and libraries, not system services or permission changes.
|
||||
If Sysprof reports `Permission denied` opening perf events, ask the host
|
||||
administrator to configure profiling access. A file being created does not
|
||||
prove CPU samples were recorded; check the recording diagnostics and contents.
|
||||
For an unprivileged capture smoke test only, use
|
||||
`sysprof-cli --no-sysprofd --no-perf smoke.syscap -- build/linux/x64/profile/bundle/meshcore_open`;
|
||||
this intentionally excludes CPU stack sampling.
|
||||
|
||||
To update the package pin, run `nix flake update nixpkgs`, review the lockfile
|
||||
diff, and repeat both Linux builds, analysis, and tests before committing it.
|
||||
Keep the updated lockfile with the shell configuration for reproducibility.
|
||||
|
||||
### Web (self-host)
|
||||
|
||||
Use a Chromium browser. Device APIs are origin-gated, so serve the build over HTTPS.
|
||||
|
||||
Generated
+3
-3
@@ -20,11 +20,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1770562336,
|
||||
"narHash": "sha256-ub1gpAONMFsT/GU2hV6ZWJjur8rJ6kKxdm9IlCT0j84=",
|
||||
"lastModified": 1793341285,
|
||||
"narHash": "sha256-Y1CiZ4SoBUjLQyQM/pY+rS2dXD3CHLPstF0lmOc73D4=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "d6c71932130818840fc8fe9509cf50be8c64634f",
|
||||
"rev": "1c89083e451e891152365b799595cf7790a43325",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -12,11 +12,18 @@
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
{
|
||||
devShells.default = pkgs.mkShell {
|
||||
devShells.default = (pkgs.mkShell.override {
|
||||
stdenv = if pkgs.stdenv.hostPlatform.isLinux then pkgs.clangStdenv else pkgs.stdenv;
|
||||
}) {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
cmake
|
||||
ninja
|
||||
pkg-config
|
||||
];
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
# Flutter and Dart
|
||||
flutter
|
||||
dart
|
||||
|
||||
# Java (required for Android development)
|
||||
jdk17
|
||||
@@ -29,22 +36,18 @@
|
||||
gtk3
|
||||
glib
|
||||
sysprof
|
||||
libclang
|
||||
cmake
|
||||
ninja
|
||||
pkg-config
|
||||
libdatrie
|
||||
|
||||
# Additional tools for installing Android SDK if not present
|
||||
curl
|
||||
unzip
|
||||
] ++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [
|
||||
pkgs.libsysprof-capture
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
echo "MeshCore Flutter Development Environment"
|
||||
export PKG_CONFIG_PATH="${pkgs.gtk3}/lib/pkgconfig:${pkgs.glib}/lib/pkgconfig:${pkgs.sysprof}/lib/pkgconfig:$PKG_CONFIG_PATH"
|
||||
export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath [pkgs.gtk3 pkgs.glib pkgs.sysprof pkgs.libdatrie]}:$LD_LIBRARY_PATH"
|
||||
export CMAKE_INSTALL_PREFIX="$PWD/build/bundle"
|
||||
|
||||
# Setup Android SDK in home directory (standard location)
|
||||
export ANDROID_HOME="$HOME/Android/Sdk"
|
||||
@@ -62,7 +65,7 @@
|
||||
echo ""
|
||||
cat << 'EOF'
|
||||
mkdir -p ~/Android/Sdk && cd ~/Android/Sdk && \
|
||||
curl -o cmdline-tools.zip ${if pkgs.stdenv.isDarwin then "https://dl.google.com/android/repository/commandlinetools-mac-10406996_latest.zip" else "https://dl.google.com/android/repository/commandlinetools-linux-10406996_latest.zip"} && \
|
||||
curl -o cmdline-tools.zip ${if pkgs.stdenv.hostPlatform.isDarwin then "https://dl.google.com/android/repository/commandlinetools-mac-10406996_latest.zip" else "https://dl.google.com/android/repository/commandlinetools-linux-10406996_latest.zip"} && \
|
||||
unzip -q cmdline-tools.zip && \
|
||||
mkdir -p cmdline-tools/latest && \
|
||||
mv cmdline-tools/* cmdline-tools/latest/ 2>/dev/null || echo "Warning: failed to move Android cmdline-tools into 'latest' directory; please check your SDK layout." >&2 && \
|
||||
|
||||
Reference in new issue
Block a user