Repository navigation
Conversation
Adds a flake so Nix users can build and run leaf from the repository, and documents Nix in the Install and Update sections of the README. - version and dependencies are read from Cargo.toml and Cargo.lock, so release-cut.sh needs no change when cutting a version - packages.default, overlays.default, and a devShell with the toolchain from CONTRIBUTING.md - the five completions in completions/ are installed from the static files, so the binary is never run at build time - `leaf --update` cannot overwrite a binary in the read-only Nix store, so it is rewritten to point at the Nix workflow instead - a Nix Check workflow builds and runs the test suite on ubuntu-latest and macos-latest, and fails if that rewrite stops matching src/main.rs
Owner
|
Hi @rhousand I think this PR is more complete than the other two, but I'd prefer to wait until leaf is available on NixOS Search before merging it, so the installation instructions in the README work as expected. Thanks again for your interest in leaf! |
This was referenced Oct 14, 2026
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.
Adds
flake.nixso Nix users can build, run and installleaffrom this repository, and documents Nix in the Install and Update sections of the README.Relation to the existing PRs
Two flake PRs are already open, #286 and #118, so this one needs a reason to exist. I commented on #286 with the detail. The short version is that three things make a straightforward flake either flaky or incomplete:
src/tests/config.rsmutate the process-globalLEAF_TAB_TITLE_LENGTH, so they race when cargo runs test threads in parallel. On an 8-core Linux builder the build fails reproducibly; on smaller runners and on Darwin it passes by luck.dontUseCargoParallelTests = trueserialises the run instead of skipping tests.completions/ships bash, fish, nushell, zsh and PowerShell. All five are installed here, the ps1 by hand sinceinstallShellFileshas no PowerShell support.leaf --updatecannot work from the read-only Nix store. Instead of a permission error, it now says:leaf was installed through Nix; update it with your Nix configuration instead of leaf --updateHappy for you to take whichever shape you prefer, including closing this and folding the fixes into #286.
What this gives users
overlays.defaultis exported as well, so NixOS and home-manager users can add the package to their configuration.Maintenance cost
This is meant to need no attention at release time:
Cargo.tomland dependencies fromCargo.lock, soscripts/release-cut.shneeds no change and there is no hash to bumpcompletions/, so the built binary is never executed during the build, which also keeps cross-compilation workingnixpkgs, and a 27-lineflake.lockleaf --updaterewrite uses--replace-warn, so refactoringsrc/main.rsdegrades to the current upstream behavior locally rather than breakingnix build, while the newNix Checkworkflow fails loudly if the pattern stops matching, so the rewrite cannot rot silentlyThe new workflow mirrors
ci-check.ymlin triggers, concurrency and permissions, and has a narrow paths filter so it only runs when a file that can affect the Nix build changes.Also in flight
NixOS/nixpkgs#564648 adds
leafto nixpkgs itself asleaf-markdown-viewer. Once that lands,nix profile install nixpkgs#leaf-markdown-viewerworks with no flake involved, and the README documents both. This flake covers building from source and trackingmain.Testing
nix buildandnix flake checkon aarch64-darwin: 746 tests pass, no Rust warnings and nosubstituteInPlacewarningsNix Checkgreen on ubuntu-latest and macos-latest: https://github.com/rhousand/leaf/actions/runs/37950254514./result/bin/leaf --versionreports 1.28.3, and all five completion files are present in the output