Skip to content

Minimize flake - #915

Open
ada-x64 wants to merge 1 commit into
TheBevyFlock:mainfrom
ada-x64:fix/minimize-flake
Open

ada-x64 wants to merge 1 commit into
TheBevyFlock:mainfrom
ada-x64:fix/minimize-flake

Conversation

@ada-x64

@ada-x64 ada-x64 commented Sep 17, 2026

Copy link
Copy Markdown

I am currently working on a nix-based Bevy ecosystem and am pushing out a minimized toolchain. Right now, the bevy_cli flake is packaging the default profile for Rust. This PR changes it to a minimal profile.

Example of downstream usage from https://github.com/cubething-qproj/infra

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

    rust-overlay = {
      url = "github:oxalica/rust-overlay";
      inputs.nixpkgs.follows = "nixpkgs";
    };

    bevy_cli = {
      url = "github:TheBevyFlock/bevy_cli";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.rust-overlay.follows = "rust-overlay";
    };
  };

  outputs =
    {
      nixpkgs,
      rust-overlay,
      bevy_cli,
      ...
    }:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs {
        inherit system;
        overlays = [ rust-overlay.overlays.default ];
      };

      # Discover the exact nightly required by bevy_lint without
      # independently hardcoding it downstream.
      rustChannel =
        bevy_cli.packages.${system}.bevy.rustToolchainChannel;

      # The packaged CLI retains only its minimal rustc-private sysroot.
      bevy-cli = bevy_cli.packages.${system}.bevy;
    in
    {
      devShells.${system}.default = pkgs.mkShell {
        packages = [
          bevy-cli
          # The project's own Rust toolchain and other development tools.
        ];
      };
    };
}

The important part is that both upstream inputs follow the downstream versions:

  bevy_cli.inputs.nixpkgs.follows = "nixpkgs";
  bevy_cli.inputs.rust-overlay.follows = "rust-overlay";

This lets Nix deduplicate the underlying rustc, cargo, rust-std, and rustc-dev component paths even when the project has its own dev toolchain.

@DaAlbrecht

Copy link
Copy Markdown
Collaborator

Hi Thanks for this PR. I dont use nix so i cant really review this, maybe @musjj could help?

@DaAlbrecht
DaAlbrecht requested a review from BD103 September 20, 2026 09:21
@DaAlbrecht DaAlbrecht added C-Code-Quality An improvement of readability or quality S-Needs-Review The PR needs to be reviewed before it can be merged A-Meta labels Sep 20, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Meta C-Code-Quality An improvement of readability or quality S-Needs-Review The PR needs to be reviewed before it can be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants