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.
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
A Nix flake and a
Makefilefor building Stack Wallet locally: for testers, for anyone who wants to reproduce a build, and for people who want their own. 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).This is a slimmer replacement for my draft #1482. It does not touch the release pipeline:
build.yaml, theDockerfileand the CI image are unchanged, and a build from this branch is not a release (see "Which build is for what" indocs/building/make.md).What it adds
flake.nix,flake.lock,.envrc): Flutter, Go, rustup, sccache, CMake, Meson, Ninja, pkg-config, protoc and the Linux/macOS build dependencies, for Apple Silicon macOS and Linux. The pinned versions (two Rust toolchains, and the Xcode that dnix source builds need) are written down once, at the top offlake.nix, and exported to theMakefile. On Linux the shell drops mkShell's-rpath $out/lib, which would otherwise put the checkout path into every binary.build-macos,build-ios,build-linux,build-windows,build-android;bootstrap(enter the shell);check-reqs*,check-sdk-macos,diagnose-env-macos;clean,clean-app,clean-native;sccache-setup,cache-stats.makestops and says what to run; Windows (Git Bash) is the one exception and always uses the prebuilts.VERSIONandBUILD_NUMare required,BUILD_NUMmay not be below the latestbuild_*tag, and both reach the shell through the environment instead of being interpolated into recipe text.bootstrap-nix(macOS and Linux; asks before running the downloaded installer as root),bootstrap-macos(adds a full Xcode),bootstrap-xcode, and the opt-inbootstrap-xcode-download(archive.org, SHA-1 and Apple signature checked; refuses to run in CI; aborts on a hash mismatch before extracting anything).check-sdk-macosdemands the pinned Xcode for source builds and says how to install it.bm/: plain-text cache benchmarks.bench.sh(cold/warm,--clean app|native|full,--sccache on|off, hit/miss counters),matrix.sh(six standard scenarios) andreport.sh.make-checkjob intest.yaml(dry-runs, the Nix requirement and source-mode policy with the reason for each rejection, and a real run ofrequire-version).docs/building/make.md, linked fromdocs/building.md.Changes to existing scripts
build_app.sh: EOF on the confirmation prompt aborts instead of looping; declining exits with$BUILD_APP_DECLINE_EXIT(default 0, unchanged; the Makefile sets 1 somakestops).configure_campfire.sh, android and iosplatform_config.sh:sed -i.bak, which works with BSD sed and the GNU sed the Nix shell puts first onPATH.build_secure_storage_deps.shwrites a pkg-config file for the locally built libsecret (the trackedscripts/linux/pc/libsecret-1.pchardcoded/usr/localand is removed), andbuild_secp256k1.shprovides the library coinlib's CMake install step expects without overwriting an existing one.Verification
From fresh clones of the branch:
nix develop:make build-macosfrom source (all four dnix packages built with Xcode 27.0,Stack Wallet.app320 MB),make build-iosfrom source, andmake build-macos PREBUILTS=1.make build-linuxclean, rebuild (the bundledlibsecp256k1.sohas the same sha256 after the rebuild) andPREBUILTS=1; the executable-stack validation passes.make bootstrap-nix(prebuilts, and from source), macOS and iOS with Nix (prebuilts), and Windows (Git Bash, no Nix). These ran with a temporary fork-only workflow, so they are not part of this PR's CI.make-checkjob was mutation-tested locally: 11 changes to the Makefile's policy each make it fail.Limits
build-androidis covered by dry-runs and the policy checks only./nix/storeas its ELF interpreter and in itsRUNPATH: it runs where it was built, it is not for distribution. Distributable Linux builds stay on the CI image path.