Repository navigation
Conversation
A Nix flake is the toolchain and a Makefile wraps scripts/build_app.sh and `flutter build`. Every build needs Nix: the four dnix packages are either compiled from source (PREBUILTS=0, the default on Apple Silicon and Linux) or taken as verified prebuilts (PREBUILTS=1). Windows (Git Bash) has no Nix and always uses the prebuilts. Flake - flake.nix, flake.lock and .envrc (`use flake`) provide Flutter, Go, rustup, sccache, CMake, Meson, Ninja, pkg-config, protoc and the Linux/macOS build dependencies for Apple Silicon macOS and Linux. - On Linux the shell drops mkShell's `-rpath $out/lib` from NIX_LDFLAGS, which would otherwise put the checkout path into every binary's RUNPATH. - The versions are written down once, at the top of flake.nix: the two Rust toolchains (installed by the shell on first entry) and the Xcode that dnix source builds need. The shell exports them as STACK_*_VERSION for the Makefile. Makefile - build-macos, build-ios, build-linux, build-windows, build-android. - Without an active Nix shell make stops and says what to run; there is no escape hatch except Windows. - VERSION and BUILD_NUM are required; BUILD_NUM may not be below the latest build_* tag. Both reach the shell through the environment, never by interpolation into the recipe text. - bootstrap-nix installs Nix on macOS and on Linux (multi-user with systemd, else single-user; asks before running the downloaded installer as root) and enables the nix-command and flakes features. - Requirements on macOS: bootstrap-macos (bootstrap-nix plus a full Xcode), bootstrap-xcode, the opt-in bootstrap-xcode-download (archive.org, SHA-1 and Apple signature checked, refuses CI, aborts on a mismatch before it extracts anything), check-reqs*, check-sdk-macos (also requires the pinned Xcode for source builds) and diagnose-env-macos. - clean, clean-app, clean-native, sccache-setup and cache-stats. - CONFIRM=1 answers the wallet-data prompt of build_app.sh; the Makefile also sets BUILD_APP_DECLINE_EXIT=1 so declining stops make. Scripts - build_app.sh: EOF on the confirmation prompt aborts instead of looping; declining exits with $BUILD_APP_DECLINE_EXIT (default 0, as before). - configure_campfire.sh, android and ios platform_config.sh: `sed -i.bak` works with BSD sed and the GNU sed the Nix shell puts first on PATH. - linux: build_secure_storage_deps.sh generates a pkg-config file for the locally built libsecret (the tracked one hardcoded /usr/local) and build_secp256k1.sh provides the library coinlib's CMake install step expects, without overwriting an existing one. Benchmarks (bm/, plain text) - bench.sh: cold/warm, --clean app|native|full, --sccache on|off (the cargo config is restored afterwards, also after a crash), sccache hit/miss counters; matrix.sh runs six standard scenarios; report.sh prints the table. CI: a make-check job validates the Makefile (dry-runs, the Nix requirement and the source-mode policy with the reason for each rejection, and a real run of require-version). Docs: docs/building/make.md, including how Linux is built and why a Nix-built bundle is for the machine that built it, not for distribution.
- Linux: add $ORIGIN to the RUNPATH of the Nix Flutter engine; without it the app window stays empty - Linux: build-linux is x86_64 only and says why on ARM - Linux shell: use a constant -frandom-seed, so that builds on different machines can produce identical bundles - Android: build Flutter plugins from the read-only Nix SDK from a copy; on NixOS run the APK build inside the flake's android-fhs environment - require-version rejects multi-line VERSION and BUILD_NUM values - sccache-setup writes the cargo config that Flutter's build hooks read - Xcode download: no sudo for a new writable target directory - install_nix.sh enables flakes for single-user installs - docs: shorter make.md with measured reproducibility and platform notes - make-check covers the new rules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
One Nix flake and a
Makefilefor local builds of Stack Wallet: for testers, for reproducing a build and for building your own. Everymakebuild needs Nix (Windows is the exception; Android also needs a JDK and the Android SDK). The four dnix packages are compiled from source (PREBUILTS=0, the default on Apple Silicon and Linux) or taken as verified prebuilts (PREBUILTS=1).The release pipeline is untouched (
build.yaml,Dockerfile, CI image), and a local build is not a release. This replaces my larger draft #1482.Details:
docs/building/make.md.What it adds
flake.nix(+ lock,.envrc): the toolchain for Apple Silicon macOS and Linux. The two Rust versions and the Xcode version for dnix source builds are set once at its top.build-macos|ios|linux|windows|android;bootstrap-nix,bootstrap-macos,bootstrap-xcode,bootstrap-xcode-download(opt-in, SHA-1 and Apple signature checked); requirement checks;clean*;sccache-setup,cache-stats. Without a Nix shellmakestops and says what to run.VERSIONandBUILD_NUMare required and validated.bm/: plain-text cache benchmarks (cold, warm, app or native clean, with and without sccache).make-checkjob intest.yaml.Changes to existing files
build_app.sh: end of input at the confirmation prompt aborts instead of looping; the exit code on "no" can be set (default unchanged).configure_campfire.sh, Android and iOSplatform_config.sh:sed -i.bak, which works with BSD and GNU sed.android/settings.gradle: Gradle 9 rejects Flutter'sintegration_testproject inside the read-only Nix SDK, so such plugins are built from a copy underbuild/. No effect with a writable SDK.build_secure_storage_deps.shwrites the pkg-config file for the local libsecret (the tracked one hardcoded/usr/local);build_secp256k1.shprovides the library coinlib's install step expects.docs/building.mdlinks the new page.Linux and NixOS
makesays why on ARM.libfolder (empty window), sobuild-linuxadds$ORIGINto itsRUNPATH.make.md).build-androiduses the flake'sandroid-fhs.Verification
Hosted-runner checks used temporary fork-only workflows. Some checks ran on earlier states of this branch. Later changes to the Linux build are the constant compiler seed (below); with it, both Linux modes were built again on NixOS and Ubuntu, and the pushed commit was built from source on NixOS and starts.
Builds
Reproducibility (two clean builds from fresh clones; same commit, version, paths, home directory and pub cache)
To get the Linux result across machines, the Linux shell now sets a constant
-frandom-seed: the default one comes from the shell's own store path and ended up in the libraries.Running apps (new wallets without funds)
Other
flutter test1205 passed, 8 skipped; the Linux bundle tests and the build-script tests pass.bootstrap-nixandbootstrap-macosinstalled Nix on a fresh hosted Mac.bootstrap-xcode-downloadran download, SHA-1, Apple signature check and extraction for real; its selection and licence steps ran with stubs.bm/on NixOS: rebuilding the native libraries took 642 s without sccache and 559 s with a filled cache.clean*;make-checkfails on deliberately broken Makefiles.