♻️ ci, nix, rust: Set up CI and switch to rust-overlay toolchain

- Added `.github/workflows/test.yaml` to run `cargo test` on push and pull_request events.
- Replaced `fenix` with `rust-overlay` in flake inputs for Rust toolchain management.
- Added `rust-toolchain.toml` specifying stable Rust with required components and targets.
- Updated `flake.nix` to use `rust-bin.fromRustupToolchainFile` and removed `RUST_SRC_PATH`.
This commit is contained in:
Markus Scully 2025-08-12 17:01:33 +03:00
parent 6f88a09b09
commit 5262a266c0
Signed by: mascully
GPG key ID: 93CA5814B698101C
4 changed files with 50 additions and 56 deletions

15
.github/workflows/test.yaml vendored Normal file
View file

@ -0,0 +1,15 @@
name: Test
on:
- push
- pull_request
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- run: nix develop -c cargo test

62
flake.lock generated
View file

@ -15,25 +15,6 @@
"type": "github" "type": "github"
} }
}, },
"fenix": {
"inputs": {
"nixpkgs": "nixpkgs",
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1754116698,
"narHash": "sha256-2cMDogXcqv975o191g0/6ZM0UolJ2X0ChuuLaNKbNAM=",
"owner": "nix-community",
"repo": "fenix",
"rev": "acdb7d8af407ea8aee21b028dc58b4bc51a7849a",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"flake-parts": { "flake-parts": {
"inputs": { "inputs": {
"nixpkgs-lib": "nixpkgs-lib" "nixpkgs-lib": "nixpkgs-lib"
@ -54,16 +35,16 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1753939845, "lastModified": 1754060105,
"narHash": "sha256-K2ViRJfdVGE8tpJejs8Qpvvejks1+A4GQej/lBk5y7I=", "narHash": "sha256-di5L6e5Iiv+oegS07j9h23FdqEpXn0ZQqMlDOEMw1EY=",
"owner": "nixos", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "94def634a20494ee057c76998843c015909d6311", "rev": "e7eabdc701d7dbb810fd91a97ec358caa4c1fc50",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nixos", "owner": "NixOS",
"ref": "nixos-unstable", "ref": "nixpkgs-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
@ -85,11 +66,11 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1754060105, "lastModified": 1744536153,
"narHash": "sha256-di5L6e5Iiv+oegS07j9h23FdqEpXn0ZQqMlDOEMw1EY=", "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "e7eabdc701d7dbb810fd91a97ec358caa4c1fc50", "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -102,25 +83,26 @@
"root": { "root": {
"inputs": { "inputs": {
"crane": "crane", "crane": "crane",
"fenix": "fenix",
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
} }
}, },
"rust-analyzer-src": { "rust-overlay": {
"flake": false, "inputs": {
"nixpkgs": "nixpkgs_2"
},
"locked": { "locked": {
"lastModified": 1753974682, "lastModified": 1754966322,
"narHash": "sha256-Ya4Ecj8JaKkapgYCCybzZBcypXpblhuG0hVDzdy2zyo=", "narHash": "sha256-7f/LH60DnjjQVKbXAsHIniGaU7ixVM7eWU3hyjT24YI=",
"owner": "rust-lang", "owner": "oxalica",
"repo": "rust-analyzer", "repo": "rust-overlay",
"rev": "68e7ec90bf29c9b17d0dcdb3358de5dee7f4afb5", "rev": "7c13cec2e3828d964b9980d0ffd680bd8d4dce90",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "rust-lang", "owner": "oxalica",
"ref": "nightly", "repo": "rust-overlay",
"repo": "rust-analyzer",
"type": "github" "type": "github"
} }
} }

View file

@ -3,12 +3,12 @@
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane"; crane.url = "github:ipetkov/crane";
flake-parts.url = "github:hercules-ci/flake-parts"; flake-parts.url = "github:hercules-ci/flake-parts";
fenix.url = "github:nix-community/fenix"; rust-overlay.url = "github:oxalica/rust-overlay";
}; };
outputs = outputs =
inputs@{ flake-parts, ... }: inputs:
flake-parts.lib.mkFlake { inherit inputs; } { inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ systems = [
"aarch64-linux" "aarch64-linux"
"aarch64-darwin" "aarch64-darwin"
@ -17,19 +17,13 @@
]; ];
perSystem = perSystem =
{ pkgs, system, ... }: { system, ... }:
let let
rustToolchain = inputs.fenix.packages.${system}.combine ([ pkgs = import inputs.nixpkgs {
(inputs.fenix.packages.${system}.complete.withComponents [ inherit system;
"cargo" overlays = [ inputs.rust-overlay.overlays.default ];
"clippy" };
"rust-src" rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
"rustc"
"rustfmt"
])
inputs.fenix.packages.${system}.complete.rust-analyzer
inputs.fenix.packages.${system}.targets.wasm32-unknown-unknown.latest.rust-std
]);
craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rustToolchain; craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rustToolchain;
packages = packages =
@ -110,7 +104,6 @@
devShells.default = craneLib.devShell { devShells.default = craneLib.devShell {
inputsFrom = [ vanth ]; inputsFrom = [ vanth ];
packages = packages; packages = packages;
RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath packages; LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath packages;
}; };
}; };

4
rust-toolchain.toml Normal file
View file

@ -0,0 +1,4 @@
[toolchain]
channel = "stable"
components = ["cargo", "clippy", "rust-analyzer", "rust-src", "rustfmt"]
targets = ["wasm32-unknown-unknown"]