Files
monorepo/plan.md
Savanni D'Gerinel cf85132d94
Some checks failed
Monorepo build / build-flake (push) Has been cancelled
Build a new devshell from scratch
2026-01-22 14:11:54 -05:00

3.6 KiB

Goal: Create a new flake.nix file which provides a shell for Rust development and build instructions for multiple Rust applications.

Instructions:

  • Create a new flake.nix file to contain the new work.
  • Define a developer shell which installs Rust, extra Rust tools, and the dependencies needed for building the project. A list of dependencies is given below in the section titled "The Shell".
  • Define a derivation for each of the installable applications. A list of applications and their dependencies is given below in the section titled "Applications".

Parameters:

  • I have backed up the existing flake.nix as flake.nix.old. You may disregard it, but I will use it for reference if we encounter an issue that I have seen before. Ignore the Cargo.nix file. Use the fitnesstrax/app/override.nix file for guidance on postInstall and preFixup instructions that may still be valuable for the gtk applications.
  • Any application should be built as its own derivation.
  • Use Crane for build and dependency management. Ensure that dependencies for each application are built into a derivation separate from the final application.
  • The flake.nix should use flake-utils to implement the instructions for Linux x86_64 and ARM for Raspberry Pi platforms, and for MacOS. Other platforms will be disregarded at this time.
  • The Rust toolchain and corresponding Rust utilities can be installed through any mechanism available, with these restrictions:
    • The devshell and the application derivations use identical rust shells.

Known Issues:

  • The rusqlite_migration crate requires that the environment variable CARGO_PKG_README be set to the path to the README.md file at the root fo the rusqlite_migration source tree.

Supported host platforms:

  • x86_64-unknown-linux-gnu
  • aarch64-apple-darwin
  • aarch64-unknown-linux-gnu

The Shell

The shell is an interactive environment containing all of the tools commonly used for Rust development. These tools are:

  • clang
  • trunk
  • glib
  • gtk4
  • libadwaita
  • librsvg
  • openssl
  • pkg-config
  • rustup
  • sqlite
  • go-task

The devshell should include these Rust components:

  • cargo, rustc, rustfmt, rust-analyzer, clippy, cargo-nextest, and cargo-watch

Rust in the devshell should be able to build executables for these targets:

  • the host platform
  • wasm32-unknown-unknown

Applications

  • bike-lights/simulator
    • Cargo.toml file: visions__build/bike-lights/simulator/Cargo.toml
    • native dependencies: pkg-config, gtk4, libadwaita, wrapGAppsHook4
  • cyberpunk-splash
    • Cargo.toml file: visions__build/cyberpunk-splash/Cargo.toml
    • native dependencies: pkg-config, gtk4, libadwaita, wrapGAppsHook4
  • dashboard
    • Cargo.toml file: visions__build/dashboard/Cargo.toml
    • native dependencies: pkg-config, gtk4, libadwaita, openssl, wrapGAppsHook4
  • fitnesstrax
    • Cargo.toml file: visions__build/fitnesstrax/app/Cargo.toml
    • native dependencies: pkg-config, gtk4, libadwaita, wrapGAppsHook4
    • additional files: resources/fitnesstrax.desktop, resources/com.luminescent-dreams.fitnesstrax.gschema.xml. The postInstall script in fitnesstrax/app/override.nix installs the files to their correct locations in the installation directory. The preFixup script uses gappsWrapperArgs, paired with the wrapGAppsHook4 native dependency, to generate the launcher script.
  • visions-server
    • Cargo.toml file: visions__build/visions/server/Cargo.toml
    • native dependencies: openssl, sqlite

The following package should always be cross-compiled for wasm32-unknown-unknown, no matter the source platform:

  • visions-ui.
  • This package will built, but not installed, through Nix. The Cargo.toml for this project is visions__build/visions/ui/Cargo.toml.