feat: add proper nix flake

This commit is contained in:
2026-04-13 16:48:38 -04:00
parent 9a362630a2
commit 7d1996306c
16 changed files with 296 additions and 155 deletions

3
.envrc
View File

@@ -1,2 +1 @@
eval "$(devenv direnvrc)"
use devenv
use flake

17
.github/dependabot.yaml vendored Normal file
View File

@@ -0,0 +1,17 @@
version: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "monthly"
- package-ecosystem: "nix"
directory: "/"
schedule:
interval: "monthly"
- package-ecosystem: "github-actions"
directory: ".github/workflows"
schedule:
interval: "monthly"

75
Cargo.lock generated
View File

@@ -375,7 +375,8 @@ dependencies = [
[[package]]
name = "azalea"
version = "0.16.0+mc26.1"
source = "git+https://github.com/azalea-rs/azalea#ddef37118448b639ff56b86ae339e8913cb4ed11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4499cd2a5bbf1ead434e457fd40fc6f3a3597c577564c12f4c21fd110b07cdaf"
dependencies = [
"azalea-auth",
"azalea-block",
@@ -412,7 +413,8 @@ dependencies = [
[[package]]
name = "azalea-auth"
version = "0.16.0+mc26.1"
source = "git+https://github.com/azalea-rs/azalea#ddef37118448b639ff56b86ae339e8913cb4ed11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c74117dc3c3805946ac16cdd2f48fcecd7aa7e950c7da86e681e5ad921eb8885"
dependencies = [
"azalea-buf",
"azalea-crypto",
@@ -432,7 +434,8 @@ dependencies = [
[[package]]
name = "azalea-block"
version = "0.16.0+mc26.1"
source = "git+https://github.com/azalea-rs/azalea#ddef37118448b639ff56b86ae339e8913cb4ed11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea45cc5ae686461c81716f08bdee08857be2ffa0eb6562c213c35c67aa78db6c"
dependencies = [
"azalea-block-macros",
"azalea-buf",
@@ -442,7 +445,8 @@ dependencies = [
[[package]]
name = "azalea-block-macros"
version = "0.16.0+mc26.1"
source = "git+https://github.com/azalea-rs/azalea#ddef37118448b639ff56b86ae339e8913cb4ed11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdcc882d1a9b05af79b1bbd592d920e3a7ec252ac403877105bce5a2fdb21e1e"
dependencies = [
"proc-macro2",
"quote",
@@ -452,7 +456,8 @@ dependencies = [
[[package]]
name = "azalea-brigadier"
version = "0.16.0+mc26.1"
source = "git+https://github.com/azalea-rs/azalea#ddef37118448b639ff56b86ae339e8913cb4ed11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f5a6d6986eccbf3902dd72432d56244dc5debca6ccbb1f47393c4d9277b044c5"
dependencies = [
"azalea-buf",
"azalea-chat",
@@ -462,7 +467,8 @@ dependencies = [
[[package]]
name = "azalea-buf"
version = "0.16.0+mc26.1"
source = "git+https://github.com/azalea-rs/azalea#ddef37118448b639ff56b86ae339e8913cb4ed11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b8fb450761479a164cd94fbf7353c758f154a03d337ffaff8166a42e6937ff0"
dependencies = [
"azalea-buf-macros",
"byteorder",
@@ -477,7 +483,8 @@ dependencies = [
[[package]]
name = "azalea-buf-macros"
version = "0.16.0+mc26.1"
source = "git+https://github.com/azalea-rs/azalea#ddef37118448b639ff56b86ae339e8913cb4ed11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29bc6a8dec6782886d06d1adf4a304d3babe7c61f28c407a10610dbac8db1d00"
dependencies = [
"proc-macro2",
"quote",
@@ -487,7 +494,8 @@ dependencies = [
[[package]]
name = "azalea-chat"
version = "0.16.0+mc26.1"
source = "git+https://github.com/azalea-rs/azalea#ddef37118448b639ff56b86ae339e8913cb4ed11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "665a5c4cd3488722302f69711027d29010d2e5b9f92d744f46605271afe2cf56"
dependencies = [
"azalea-buf",
"azalea-language",
@@ -501,7 +509,8 @@ dependencies = [
[[package]]
name = "azalea-client"
version = "0.16.0+mc26.1"
source = "git+https://github.com/azalea-rs/azalea#ddef37118448b639ff56b86ae339e8913cb4ed11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1b6d6f2298959bc66bbf7744ba880ac45c84f78ed383e2360ce085b73a73835"
dependencies = [
"async-compat",
"azalea-auth",
@@ -539,7 +548,8 @@ dependencies = [
[[package]]
name = "azalea-core"
version = "0.16.0+mc26.1"
source = "git+https://github.com/azalea-rs/azalea#ddef37118448b639ff56b86ae339e8913cb4ed11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf3c7e9ec40c983b9a5e17cc75cb744896e4cce279ef355da1750c11632d37a0"
dependencies = [
"azalea-buf",
"azalea-chat",
@@ -560,7 +570,8 @@ dependencies = [
[[package]]
name = "azalea-crypto"
version = "0.16.0+mc26.1"
source = "git+https://github.com/azalea-rs/azalea#ddef37118448b639ff56b86ae339e8913cb4ed11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7eb0ec0995af57e34a130e61869bb865e092d838d98d601fab64b9291d837adf"
dependencies = [
"aes",
"azalea-buf",
@@ -579,7 +590,8 @@ dependencies = [
[[package]]
name = "azalea-entity"
version = "0.16.0+mc26.1"
source = "git+https://github.com/azalea-rs/azalea#ddef37118448b639ff56b86ae339e8913cb4ed11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eac94303362f7576efe063f8db36552f97258e729b3e4bd32a864ec797dc393f"
dependencies = [
"azalea-block",
"azalea-buf",
@@ -599,18 +611,11 @@ dependencies = [
"uuid",
]
[[package]]
name = "azalea-hax"
version = "0.1.0"
source = "git+https://github.com/azalea-rs/azalea-hax#ef06856f1e6c45cab614ac78d2224a8228d9c426"
dependencies = [
"azalea",
]
[[package]]
name = "azalea-inventory"
version = "0.16.0+mc26.1"
source = "git+https://github.com/azalea-rs/azalea#ddef37118448b639ff56b86ae339e8913cb4ed11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f15103d879c9967c37fd13361d08db062dc9529a5593b14ef8301f322d42cd3e"
dependencies = [
"azalea-auth",
"azalea-buf",
@@ -628,7 +633,8 @@ dependencies = [
[[package]]
name = "azalea-inventory-macros"
version = "0.16.0+mc26.1"
source = "git+https://github.com/azalea-rs/azalea#ddef37118448b639ff56b86ae339e8913cb4ed11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94afbf2cb10a6cfc26a723430b42d0a1933291f176f10081c69f21651e56052d"
dependencies = [
"proc-macro2",
"quote",
@@ -638,7 +644,8 @@ dependencies = [
[[package]]
name = "azalea-language"
version = "0.16.0+mc26.1"
source = "git+https://github.com/azalea-rs/azalea#ddef37118448b639ff56b86ae339e8913cb4ed11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e58005bd5a7bdc0bed973640ae281aecd09fdbaa7312b959fc3f6f2232d3a64"
dependencies = [
"compact_str",
"serde_json",
@@ -647,7 +654,8 @@ dependencies = [
[[package]]
name = "azalea-physics"
version = "0.16.0+mc26.1"
source = "git+https://github.com/azalea-rs/azalea#ddef37118448b639ff56b86ae339e8913cb4ed11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5963fd337c81663ec89745f1baf7b97e823bf820c76c35f26e14a70233787923"
dependencies = [
"azalea-block",
"azalea-core",
@@ -664,7 +672,8 @@ dependencies = [
[[package]]
name = "azalea-protocol"
version = "0.16.0+mc26.1"
source = "git+https://github.com/azalea-rs/azalea#ddef37118448b639ff56b86ae339e8913cb4ed11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15e2203a1d672290513a9c62d4753f1004a69a6767aebb788b06b02779071156"
dependencies = [
"azalea-auth",
"azalea-block",
@@ -699,7 +708,8 @@ dependencies = [
[[package]]
name = "azalea-protocol-macros"
version = "0.16.0+mc26.1"
source = "git+https://github.com/azalea-rs/azalea#ddef37118448b639ff56b86ae339e8913cb4ed11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab6a0f484a4cb105cd178f0cf54755f281625cda1beaf84d65e696af3383fd15"
dependencies = [
"proc-macro2",
"quote",
@@ -709,7 +719,8 @@ dependencies = [
[[package]]
name = "azalea-registry"
version = "0.16.0+mc26.1"
source = "git+https://github.com/azalea-rs/azalea#ddef37118448b639ff56b86ae339e8913cb4ed11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3960fd7f1dcd6ea6941fcb5e8a756ff0c8e13f13fa989bc1cde7cfb4563bb35"
dependencies = [
"azalea-buf",
"azalea-registry-macros",
@@ -720,7 +731,8 @@ dependencies = [
[[package]]
name = "azalea-registry-macros"
version = "0.16.0+mc26.1"
source = "git+https://github.com/azalea-rs/azalea#ddef37118448b639ff56b86ae339e8913cb4ed11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a8c09e57b12a674726eb5570b88828756c56fab90ce6f473a0a4a0a02bf18ea"
dependencies = [
"quote",
"syn 2.0.117",
@@ -729,7 +741,8 @@ dependencies = [
[[package]]
name = "azalea-world"
version = "0.16.0+mc26.1"
source = "git+https://github.com/azalea-rs/azalea#ddef37118448b639ff56b86ae339e8913cb4ed11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59258b4001f420e0fb7fc418566b9fed25bac171e8fe6ebbee93d588118370a2"
dependencies = [
"azalea-block",
"azalea-buf",
@@ -1082,7 +1095,8 @@ dependencies = [
[[package]]
name = "built"
version = "0.8.0"
source = "git+https://github.com/lukaslueg/built#7cebe3e8d802502f55d2cf799abf1e5c983fb7a9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4ad8f11f288f48ca24471bbd51ac257aaeaaa07adae295591266b792902ae64"
dependencies = [
"git2",
]
@@ -1969,7 +1983,6 @@ version = "0.2.0"
dependencies = [
"anyhow",
"azalea",
"azalea-hax",
"bevy_app",
"bevy_ecs",
"bevy_log",

View File

@@ -16,12 +16,11 @@ lto = true
strip = true
[build-dependencies]
built = { git = "https://github.com/lukaslueg/built", features = ["git2"] }
built = { version = "0", features = ["git2"] }
[dependencies]
anyhow = "1"
azalea = { git = "https://github.com/azalea-rs/azalea" }
azalea-hax = { git = "https://github.com/azalea-rs/azalea-hax" }
azalea = "0"
bevy_app = "0"
bevy_ecs = "0"
bevy_log = "0"

View File

@@ -21,7 +21,13 @@ A Minecraft bot with Lua scripting support, written in Rust with [azalea](https:
$ git clone https://github.com/ErrorNoInternet/ErrorNoWatcher
$ cd ErrorNoWatcher
$ cargo build --release
$ # ./target/release/errornowatcher
$ ./target/release/errornowatcher
```
#### Nix
```sh
nix run github:ErrorNoInternet/ErrorNoWatcher
```
Make sure the `Server` and `Username` globals are defined in `main.lua` before starting the bot.

24
default.nix Normal file
View File

@@ -0,0 +1,24 @@
{
lib,
pkgs,
rust,
self,
}:
pkgs.rustPlatform.buildRustPackage {
pname = "errornowatcher";
version = self.shortRev or self.dirtyShortRev;
cargoLock.lockFile = ./Cargo.lock;
src = lib.cleanSource ./.;
nativeBuildInputs = with pkgs; [
rust
mold
pkg-config
];
buildInputs = with pkgs; [
luajit
];
}

View File

@@ -1,86 +0,0 @@
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1775928269,
"narHash": "sha256-kolsui5s7citDkwz2RL4Au8/BUdH9/TYbfMthLrarrc=",
"owner": "cachix",
"repo": "devenv",
"rev": "b908ac3d4b59f28cb32e7294c621b1c7325002c7",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"nixpkgs": {
"inputs": {
"nixpkgs-src": "nixpkgs-src"
},
"locked": {
"lastModified": 1774287239,
"narHash": "sha256-W3krsWcDwYuA3gPWsFA24YAXxOFUL6iIlT6IknAoNSE=",
"owner": "cachix",
"repo": "devenv-nixpkgs",
"rev": "fa7125ea7f1ae5430010a6e071f68375a39bd24c",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "rolling",
"repo": "devenv-nixpkgs",
"type": "github"
}
},
"nixpkgs-src": {
"flake": false,
"locked": {
"lastModified": 1773840656,
"narHash": "sha256-9tpvMGFteZnd3gRQZFlRCohVpqooygFuy9yjuyRL2C0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9cf7092bdd603554bd8b63c216e8943cf9b12512",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1775877051,
"narHash": "sha256-wpSQm2PD/w4uRo2wb8utk0b5hOBkkg/CZ1xICY+qB7M=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "08b4f3633471874c8894632ade1b78d75dbda002",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View File

@@ -1,19 +0,0 @@
{
pkgs,
...
}:
{
packages = with pkgs; [
git
jujutsu
luajit
openssl
];
languages.rust = {
enable = true;
channel = "nightly";
};
}

View File

@@ -1,8 +0,0 @@
inputs:
nixpkgs:
url: github:cachix/devenv-nixpkgs/rolling
rust-overlay:
url: github:oxalica/rust-overlay
inputs:
nixpkgs:
follows: nixpkgs

82
flake.lock generated Normal file
View File

@@ -0,0 +1,82 @@
{
"nodes": {
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1772408722,
"narHash": "sha256-rHuJtdcOjK7rAHpHphUb1iCvgkU3GpfvicLMwwnfMT0=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "f20dc5d9b8027381c474144ecabc9034d6a839a3",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1774709303,
"narHash": "sha256-D3Q07BbIA2KnTcSXIqqu9P586uWxN74zNoCH3h2ESHg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "8110df5ad7abf5d4c0f6fb0f8f978390e77f9685",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1772328832,
"narHash": "sha256-e+/T/pmEkLP6BHhYjx6GmwP5ivonQQn0bJdH9YrRB+Q=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "c185c7a5e5dd8f9add5b2f8ebeff00888b070742",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1775013181,
"narHash": "sha256-zPrt6oNM1r/RO5bWYaZ3hthfG9vzkr6kQdoqDd5x4Qw=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "e8046c1d9ccadd497c2344d8fa49dab62f22f7be",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

66
flake.nix Normal file
View File

@@ -0,0 +1,66 @@
{
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
flake-parts,
nixpkgs,
rust-overlay,
self,
...
}@inputs:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"aarch64-linux"
"x86_64-linux"
];
perSystem =
{
pkgs,
self',
system,
...
}:
let
rust = pkgs.rust-bin.nightly.latest.default.override {
extensions = [
"rust-src"
"rust-analyzer-preview"
];
};
in
{
_module.args.pkgs = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
devShells.default = pkgs.mkShell {
name = "errornowatcher";
inputsFrom = [ self'.packages.default ];
nativeBuildInputs = [ pkgs.pkg-config ];
buildInputs = [ pkgs.taplo ];
RUST_BACKTRACE = 1;
};
packages = rec {
default = errornowatcher;
errornowatcher = pkgs.callPackage ./. { inherit rust self; };
};
};
};
description = "A Minecraft bot with Lua scripting support";
}

View File

@@ -1,4 +1,4 @@
use azalea::{brigadier::prelude::*, client_chat::ChatPacket, prelude::*};
use azalea::{brigadier::prelude::*, chat::ChatPacket, prelude::*};
use futures::lock::Mutex;
use mlua::{Error, Result, Table, UserDataRef};
use ncr::{

View File

@@ -0,0 +1,19 @@
use azalea::{
entity::Physics,
movement::{KnockbackEvent, handle_knockback},
prelude::*,
};
use bevy_ecs::{observer::On, query::With, system::Query};
#[derive(Component)]
pub struct AntiKnockback;
pub fn anti_knockback(
knockback: On<KnockbackEvent>,
entity_query: Query<(), With<AntiKnockback>>,
handle_knockback_query: Query<&mut Physics>,
) {
if entity_query.get(knockback.entity).is_err() {
handle_knockback(knockback, handle_knockback_query);
}
}

28
src/hacks/mod.rs Normal file
View File

@@ -0,0 +1,28 @@
pub mod anti_knockback;
use azalea::movement::KnockbackEvent;
use bevy_app::{App, Plugin, PostStartup};
use bevy_ecs::world::World;
pub struct HacksPlugin;
impl Plugin for HacksPlugin {
fn build(&self, app: &mut App) {
app.add_systems(PostStartup, init_hacks);
}
}
fn init_hacks(ecs: &mut World) {
let observers = ecs
.observers()
.try_get_observers(ecs.event_key::<KnockbackEvent>().unwrap());
let mut to_despawn = Vec::new();
for (observer_entity, _) in observers.unwrap().global_observers() {
to_despawn.push(*observer_entity);
}
for observer_entity in to_despawn {
ecs.despawn(observer_entity);
}
ecs.add_observer(anti_knockback::anti_knockback);
}

View File

@@ -2,11 +2,10 @@ use azalea::{
ClientInformation, entity::metadata::AirSupply, pathfinder::debug::PathfinderDebugParticles,
protocol::common::client_information::ModelCustomization,
};
use azalea_hax::AntiKnockback;
use mlua::{Error, Lua, Result, Table, UserDataRef};
use super::Client;
use crate::unpack;
use crate::{hacks::anti_knockback::AntiKnockback, unpack};
pub fn air_supply(_lua: &Lua, client: &Client) -> Result<i32> {
Ok(client.component::<AirSupply>().0)

View File

@@ -5,6 +5,7 @@ mod arguments;
mod build_info;
mod commands;
mod events;
mod hacks;
mod http;
mod lua;
mod particle;
@@ -27,7 +28,6 @@ use arguments::Arguments;
use azalea::{
DefaultPlugins, bot::DefaultBotPlugins, brigadier::prelude::CommandDispatcher, prelude::*,
};
use azalea_hax::HaxPlugin;
use bevy_app::PluginGroup;
use bevy_log::{
LogPlugin,
@@ -45,6 +45,8 @@ use {
replay::{plugin::RecordPlugin, recorder::Recorder},
};
use crate::hacks::HacksPlugin;
#[cfg(feature = "mimalloc")]
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
@@ -114,7 +116,7 @@ async fn main() -> Result<()> {
let builder = ClientBuilder::new_without_plugins()
.add_plugins(default_plugins)
.add_plugins(DefaultBotPlugins)
.add_plugins(HaxPlugin);
.add_plugins(HacksPlugin);
#[cfg(feature = "replay")]
let builder = builder.add_plugins(RecordPlugin {