From 6ccf442fd3c39cbcc6d50de8e09275096420448c Mon Sep 17 00:00:00 2001 From: Thomas Given Date: Sat, 2 Aug 2025 16:38:23 -0400 Subject: [PATCH 1/6] barebones flake.nix --- flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..faa925ef --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1753939845, + "narHash": "sha256-K2ViRJfdVGE8tpJejs8Qpvvejks1+A4GQej/lBk5y7I=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "94def634a20494ee057c76998843c015909d6311", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..e73b633d --- /dev/null +++ b/flake.nix @@ -0,0 +1,41 @@ +{ + description = "A Bevy CLI tool and linter"; + + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + }; + + outputs = { self, flake-utils, nixpkgs }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + + nativeBuildInputs = with pkgs; [ + pkg-config + ]; + + buildInputs = with pkgs; [ + openssl + # rustup + ]; + in + { + packages.default = pkgs.rustPlatform.buildRustPackage { + pname = "bevy_cli"; + version = "0.1.0-dev"; + src = ./.; + cargoLock = { + lockFile = ./Cargo.lock; + }; + doCheck = false; + inherit buildInputs nativeBuildInputs; + }; + + devShells.default = pkgs.mkShell { + inherit buildInputs nativeBuildInputs; + }; + } + ); +} From 04e867573694f0f9f70a34e28441a7f1f962200d Mon Sep 17 00:00:00 2001 From: Thomas Given Date: Sat, 4 Oct 2025 18:03:28 -0400 Subject: [PATCH 2/6] nix flake update --- flake.lock | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index faa925ef..c4b0560d 100644 --- a/flake.lock +++ b/flake.lock @@ -1,12 +1,30 @@ { "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1753939845, - "narHash": "sha256-K2ViRJfdVGE8tpJejs8Qpvvejks1+A4GQej/lBk5y7I=", + "lastModified": 1759381078, + "narHash": "sha256-gTrEEp5gEspIcCOx9PD8kMaF1iEmfBcTbO0Jag2QhQs=", "owner": "nixos", "repo": "nixpkgs", - "rev": "94def634a20494ee057c76998843c015909d6311", + "rev": "7df7ff7d8e00218376575f0acdcc5d66741351ee", "type": "github" }, "original": { @@ -18,8 +36,24 @@ }, "root": { "inputs": { + "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", From 0feb7edd2167158a876d30dc13d9719025fcd789 Mon Sep 17 00:00:00 2001 From: Thomas Given Date: Sun, 12 Oct 2025 11:43:11 -0400 Subject: [PATCH 3/6] apply review suggestions && nix flake update --- flake.lock | 6 +++--- flake.nix | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index c4b0560d..5cb95c1a 100644 --- a/flake.lock +++ b/flake.lock @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1759381078, - "narHash": "sha256-gTrEEp5gEspIcCOx9PD8kMaF1iEmfBcTbO0Jag2QhQs=", + "lastModified": 1760038930, + "narHash": "sha256-Oncbh0UmHjSlxO7ErQDM3KM0A5/Znfofj2BSzlHLeVw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "7df7ff7d8e00218376575f0acdcc5d66741351ee", + "rev": "0b4defa2584313f3b781240b29d61f6f9f7e0df3", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index e73b633d..c0469207 100644 --- a/flake.nix +++ b/flake.nix @@ -18,12 +18,11 @@ buildInputs = with pkgs; [ openssl - # rustup ]; in { packages.default = pkgs.rustPlatform.buildRustPackage { - pname = "bevy_cli"; + pname = "bevy"; version = "0.1.0-dev"; src = ./.; cargoLock = { From 4c24f51f33160a1ec3169f7d5d8670d23a39d7ee Mon Sep 17 00:00:00 2001 From: Thomas Given Date: Mon, 3 Nov 2025 19:26:20 -0500 Subject: [PATCH 4/6] configure nightly toolchain for linter --- flake.lock | 29 +++++++++++++++++++++++++---- flake.nix | 41 +++++++++++++++++++++++++++++++---------- 2 files changed, 56 insertions(+), 14 deletions(-) diff --git a/flake.lock b/flake.lock index 5cb95c1a..be2323cc 100644 --- a/flake.lock +++ b/flake.lock @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1760038930, - "narHash": "sha256-Oncbh0UmHjSlxO7ErQDM3KM0A5/Znfofj2BSzlHLeVw=", + "lastModified": 1762111121, + "narHash": "sha256-4vhDuZ7OZaZmKKrnDpxLZZpGIJvAeMtK6FKLJYUtAdw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "0b4defa2584313f3b781240b29d61f6f9f7e0df3", + "rev": "b3d51a0365f6695e7dd5cdf3e180604530ed33b4", "type": "github" }, "original": { @@ -37,7 +37,28 @@ "root": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1762137611, + "narHash": "sha256-sTqb10FR/YQCuGbw16qxliX0NFlYg6evSEjN8w+9IYE=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "3a0ebe5d2965692f990cb27e62f501ad35e3deeb", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" } }, "systems": { diff --git a/flake.nix b/flake.nix index c0469207..d8a791a3 100644 --- a/flake.nix +++ b/flake.nix @@ -4,13 +4,17 @@ inputs = { flake-utils.url = "github:numtide/flake-utils"; nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { self, flake-utils, nixpkgs }: + outputs = { self, flake-utils, nixpkgs, rust-overlay }: flake-utils.lib.eachDefaultSystem ( system: let - pkgs = nixpkgs.legacyPackages.${system}; + pkgs = nixpkgs.legacyPackages.${system}.extend rust-overlay.overlays.default; nativeBuildInputs = with pkgs; [ pkg-config @@ -19,17 +23,34 @@ buildInputs = with pkgs; [ openssl ]; + + toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + + rustPlatform = pkgs.makeRustPlatform { + cargo = toolchain; + rustc = toolchain; + }; in { - packages.default = pkgs.rustPlatform.buildRustPackage { - pname = "bevy"; - version = "0.1.0-dev"; - src = ./.; - cargoLock = { - lockFile = ./Cargo.lock; + packages = { + default = self.outputs.packages.${system}.bevy; + bevy = rustPlatform.buildRustPackage { + pname = "bevy"; + version = "0.1.0-dev"; + src = ./.; + cargoLock.lockFile = ./Cargo.lock; + cargoBuildFlags = [ "--all" ]; + doCheck = false; + + nativeBuildInputs = nativeBuildInputs ++ (with pkgs; [ makeBinaryWrapper ]); + inherit buildInputs; + + postInstall = '' + for bin in $out/bin/bevy{,_lint}; do + wrapProgram $bin --set BEVY_LINT_SYSROOT ${toolchain} + done + ''; }; - doCheck = false; - inherit buildInputs nativeBuildInputs; }; devShells.default = pkgs.mkShell { From 0fd9ed8cc536025a41da3bd370ea306b4cc0c6dd Mon Sep 17 00:00:00 2001 From: "T.J. Given" <100444483+CupOfTeaJay@users.noreply.github.com> Date: Sun, 9 Nov 2025 17:54:31 -0500 Subject: [PATCH 5/6] document Nix support --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 8ad95934..8611659a 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,29 @@ If you want to try out the newest unstable features, you may install the CLI fro cargo install --git https://github.com/TheBevyFlock/bevy_cli --branch main --locked bevy_cli ``` +### Nix + +> Please note that Nix support is maintained on a best-effort basis, and therefore should not be considered stable. Features may be unavailable or break altogether as a result of future changes. + +The CLI is also available to Nix users as a [flake](https://wiki.nixos.org/wiki/Flakes). Simply add it as an input to your project's `flake.nix` to include it in the environment: + +```nix +{ + description = "A Bevy project flake."; + + inputs = { + # Other inputs... + bevy_cli.url = "github:TheBevyFlock/bevy_cli"; + }; + + outputs = { self, bevy_cli }: { + # Your outputs... + }; +} +``` + +An [example](https://github.com/bevyengine/bevy/blob/2facb2572d84e9b9923edef7f35bae2c26308081/docs/linux_dependencies.md#flakenix) project flake can be found in the official Bevy docs. + ## Quick Start From 3c32ece820c5e7b743edf6778f9333679fbfb6d5 Mon Sep 17 00:00:00 2001 From: "T.J. Given" <100444483+CupOfTeaJay@users.noreply.github.com> Date: Tue, 11 Nov 2025 19:22:00 -0500 Subject: [PATCH 6/6] qualify both CLI & Linter for Nix support Co-authored-by: DAA <42379074+DaAlbrecht@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8611659a..fe445268 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ cargo install --git https://github.com/TheBevyFlock/bevy_cli --branch main --loc > Please note that Nix support is maintained on a best-effort basis, and therefore should not be considered stable. Features may be unavailable or break altogether as a result of future changes. -The CLI is also available to Nix users as a [flake](https://wiki.nixos.org/wiki/Flakes). Simply add it as an input to your project's `flake.nix` to include it in the environment: +The CLI and Linter are also available to Nix users as a [flake](https://wiki.nixos.org/wiki/Flakes). Simply add it as an input to your project's `flake.nix` to include it in the environment: ```nix {