diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..e0f5739 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[unstable] +build-std = ["std", "panic_abort", "core", "alloc"] diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 885c943..dec3586 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target -Cargo.lock \ No newline at end of file +/.direnv +/result \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..f928647 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,104 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "arena-latency-slider" +version = "0.2.0" +dependencies = [ + "ninput", + "skyline", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc-nnsdk" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6823e4bff6dee10a75dfee95afe1c5a7f93a1b99a20013663e0cb04b3a64f867" + +[[package]] +name = "ninput" +version = "0.1.0" +source = "git+https://github.com/blu-dev/ninput#af26d4de5bb5f444985193b296ce65fe364e6a33" +dependencies = [ + "bitflags", +] + +[[package]] +name = "nnsdk" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0f4537c7470ba25f406d42c8cbfe26f64099af4b613e715c6bcb3d25856896c" +dependencies = [ + "libc-nnsdk", +] + +[[package]] +name = "proc-macro2" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "skyline" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9950fc129490cff3f4755aa523df16aeeb80130699abfc59cc7c6df8fc5802ad" +dependencies = [ + "libc-nnsdk", + "nnsdk", + "skyline_macro", +] + +[[package]] +name = "skyline_macro" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9194b20ee17c1de2ed299cfd9b8b56160a35b5579b3273c416ab4e5c058844dc" +dependencies = [ + "lazy_static", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" diff --git a/Cargo.toml b/Cargo.toml index c91becd..0be2291 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "arena-latency-slider" -version = "0.1.0" +version = "0.2.0" authors = [] edition = "2021" @@ -12,11 +12,11 @@ crate-type = ["cdylib"] [dependencies] ninput = { git = "https://github.com/blu-dev/ninput", version = "0.1.0" } -skyline = "0.2.0" +skyline = "0.2.1" [profile.dev] panic = "abort" [profile.release] panic = "abort" -lto = true \ No newline at end of file +lto = true diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..7d88cbc --- /dev/null +++ b/flake.lock @@ -0,0 +1,164 @@ +{ + "nodes": { + "cargo-skyline-src": { + "flake": false, + "locked": { + "lastModified": 1690219326, + "narHash": "sha256-uGzrGbov3WllRSFBqHtDGsk3pdAxDg9DKx32rK0Xscs=", + "owner": "jam1garner", + "repo": "cargo-skyline", + "rev": "142a4da1a3b03f0f9731a1144229d0552444b02d", + "type": "github" + }, + "original": { + "owner": "jam1garner", + "repo": "cargo-skyline", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1708294118, + "narHash": "sha256-evZzmLW7qoHXf76VCepvun1esZDxHfVRFUJtumD7L2M=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e0da498ad77ac8909a980f07eff060862417ccf7", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1706487304, + "narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "90f456026d284c22b3e3497be980b2e47d0b28ac", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "cargo-skyline-src": "cargo-skyline-src", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay", + "skyline-rs": "skyline-rs" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1708308739, + "narHash": "sha256-FtKWP6d51kz8282jfziNNcCBpAvEzv2TtKH6dYIXCuA=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "d45281ce1027a401255db01ea44972afbc569b7e", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "skyline-rs": { + "flake": false, + "locked": { + "lastModified": 1696102154, + "narHash": "sha256-CNnwaU5La5Iy4/2vLl+xPK+7PXz+gE59d6vXmiz9Kec=", + "owner": "ultimate-research", + "repo": "skyline-rs", + "rev": "01a55d6a72d30b36b3e4b478161ebb4e513ea909", + "type": "github" + }, + "original": { + "owner": "ultimate-research", + "repo": "skyline-rs", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "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", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..2213cb7 --- /dev/null +++ b/flake.nix @@ -0,0 +1,80 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; + + flake-utils.url = "github:numtide/flake-utils"; + + rust-overlay.url = "github:oxalica/rust-overlay"; + + cargo-skyline-src = { + url = "github:jam1garner/cargo-skyline"; + flake = false; + }; + + skyline-rs = { + url = "github:ultimate-research/skyline-rs"; + flake = false; + }; + }; + + outputs = + { self + , nixpkgs + , flake-utils + , rust-overlay + , cargo-skyline-src + , skyline-rs + }: (flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ + rust-overlay.overlays.default + ]; + }; + + rustToolchain = (pkgs.rust-bin.nightly."2023-12-30".default.override { + extensions = [ + "rust-src" + "rust-std" + ]; + }); + rustPlatform = pkgs.makeRustPlatform { + cargo = rustToolchain; + rustc = rustToolchain; + }; + + cargo-skyline = rustPlatform.buildRustPackage { + pname = "cargo-skyline"; + version = (builtins.fromTOML (builtins.readFile "${cargo-skyline-src}/Cargo.toml")).package.version; + + src = cargo-skyline-src; + + cargoLock = { + lockFile = "${cargo-skyline-src}/Cargo.lock"; + }; + + meta = { + description = "A cargo subcommand for working with Skyline plugins written in Rust"; + }; + }; + in + { + packages.rustToolchain = rustToolchain; + + devShells.default = pkgs.mkShell { + nativeBuildInputs = builtins.attrValues { + inherit cargo-skyline; + + # for now, we use rustup to manage the toolchain + # because skyline has some weird customizations that + # I don't feel like getting into at this point in time + # this means no reproducible builds (for now), but I can live with that + inherit (pkgs) rustup; + }; + + # this is mainly for rust-analyzer to not get confused + CARGO_BUILD_TARGET = "${skyline-rs}/aarch64-skyline-switch.json"; + }; + })); +} diff --git a/src/lib.rs b/src/lib.rs index 95d10ed..77dcc5c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,5 @@ +#![feature(restricted_std)] + use skyline::hooks::InlineCtx; #[skyline::from_offset(0x37a1270)]