Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/nix-flake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Test Nix flake

on:
push:
branches: [main]
# Only run for pull requests when the flake, toolchain, or action is modified.
pull_request:
paths:
- flake.nix
- flake.lock
- rust-toolchain.toml
- .github/workflows/nix-flake.yml
workflow_dispatch:

jobs:
test-flake:
name: Test Nix flake
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Install Nix
uses: DeterminateSystems/determinate-nix-action@v3.15.2

- name: Check flake
run: nix flake check --all-systems

- name: Run Bevy CLI
run: nix run . -- --version

- name: Format `flake.nix`
run: nix-shell -p nixfmt --run "nixfmt --check --strict --verify flake.nix"
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ docs/book/

# Internal Compiler Error files, generated when the linter panics.
rustc-ice-*.txt

# Generated by Nix flake
result

23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 available to [Nix](https://nixos.org/) 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/v0.18.0/docs/linux_dependencies.md#flakenix) project flake can be found in the official Bevy docs.

## Quick Start

<!-- Please keep this section synchronized with the `mdbook` docs. -->
Expand Down
23 changes: 23 additions & 0 deletions docs/src/cli/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,26 @@ If you want to try out the newest unstable features, you may install the CLI fro
```sh
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 available to [Nix](https://nixos.org/) 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/v0.18.0/docs/linux_dependencies.md#flakenix) project flake can be found in the official Bevy docs.
82 changes: 82 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
description = "A Bevy CLI tool and linter";

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,
rust-overlay,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system}.extend rust-overlay.overlays.default;

nativeBuildInputs = with pkgs; [ pkg-config ];

buildInputs = with pkgs; [ openssl ];

toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;

rustPlatform = pkgs.makeRustPlatform {
cargo = toolchain;
rustc = toolchain;
};
in
{
packages = {
default = self.outputs.packages.${system}.bevy;
bevy = rustPlatform.buildRustPackage {
pname = "bevy";
version = "0.1.0-dev";
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
doCheck = false;

nativeBuildInputs = nativeBuildInputs ++ (with pkgs; [ makeBinaryWrapper ]);
inherit buildInputs;
};
};

devShells.default = pkgs.mkShell { inherit buildInputs nativeBuildInputs; };
}
);
}