diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b15608..067efb5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,6 +46,8 @@ jobs: ruby-version: '3.2' - name: Setup Rust uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable - name: Install Ruby dependencies run: bundle install - name: Setup just diff --git a/flake.lock b/flake.lock index 15a9d58..ed36340 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,26 @@ { "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1754462708, + "narHash": "sha256-82koJGbd4Z2fkoKRahRrSQY/lHjrXuMvsyUC65+cphU=", + "owner": "nix-community", + "repo": "fenix", + "rev": "411d129fad840043f724f98719706be39aa7de9c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -91,9 +112,27 @@ }, "root": { "inputs": { + "fenix": "fenix", "nixpkgs": "nixpkgs", "pre-commit-hooks": "pre-commit-hooks" } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1754428884, + "narHash": "sha256-a+hFq6zFCDhGrW7yK9le4Do80dbQIaYS0ijpOY53i7A=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "75436532df916b370552652b4df601273e518025", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 37abe1b..c3ba90c 100644 --- a/flake.nix +++ b/flake.nix @@ -1,16 +1,28 @@ { description = "Development environment for codetracer-ruby-recorder"; - inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; - inputs.pre-commit-hooks.url = "github:cachix/git-hooks.nix"; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + pre-commit-hooks.url = "github:cachix/git-hooks.nix"; + }; outputs = { self, nixpkgs, + fenix, pre-commit-hooks, }: let systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"]; forEachSystem = nixpkgs.lib.genAttrs systems; + + rust-toolchain-for = system: fenix.packages.${system}.fromToolchainFile { + file = ./rust-toolchain.toml; + sha256 = "sha256-Qxt8XAuaUR2OMdKbN4u8dBJOhSHxS+uS06Wl9+flVEk="; + }; in { checks = forEachSystem (system: { pre-commit-check = pre-commit-hooks.lib.${system}.run { @@ -38,8 +50,7 @@ ruby # The native extension is implemented in Rust - rustc - cargo + (rust-toolchain-for system) libiconv # Required dependency when building the rb-sys Rust crate on macOS and some Linux systems # Required for bindgen (used by rb-sys crate for generating Ruby C API bindings) diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..5913d1c --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.88.0" +components = [ "rustc", "rust-analyzer", "rust-std", "cargo", "rustfmt", "rustc-dev", "llvm-tools" ]