Skip to content

Commit 349bc0e

Browse files
fahdfadyhulxv
andauthored
build(nix): use fenix to manage rust toolchain dependencies (#47)
* use Fenix to manage rust toolchain dependencies * specify a toolchain with date for reproducability --------- Co-authored-by: hulxv <hulxxv@gmail.com>
1 parent ea9387a commit 349bc0e

File tree

2 files changed

+70
-11
lines changed

2 files changed

+70
-11
lines changed

flake.lock

Lines changed: 42 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,34 @@
77
inputs = {
88
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
99
flake-utils.url = "github:numtide/flake-utils";
10+
fenix = {
11+
url = "github:nix-community/fenix";
12+
inputs.nixpkgs.follows = "nixpkgs";
13+
};
1014
};
1115

12-
outputs = { self, nixpkgs, flake-utils, ... }:
16+
outputs = { self, nixpkgs, flake-utils, fenix, ... }:
1317
flake-utils.lib.eachDefaultSystem (system:
1418
let
1519
system = "x86_64-linux";
1620
pkgs = nixpkgs.legacyPackages.${system};
21+
22+
# Create a Rust toolchain using fenix (Nightly)
23+
rustToolchain = (fenix.packages.${system}.toolchainOf {
24+
channel = "nightly";
25+
date = "2025-10-15";
26+
sha256 = "sha256-nYxm7Okhb4WOD0C/qCJ3uzm+VwgQTG4SSpO8IXewVXU=";
27+
}).defaultToolchain;
28+
29+
# Or for more granular control, use:
30+
# rustToolchain = fenix.packages.${system}.combine [
31+
# fenix.packages.${system}.latest.rustc
32+
# fenix.packages.${system}.latest.cargo
33+
# fenix.packages.${system}.latest.rustfmt
34+
# fenix.packages.${system}.latest.clippy
35+
# fenix.packages.${system}.latest.rust-src
36+
# fenix.packages.${system}.latest.rust-analyzer
37+
# ];
1738

1839
metacallConfig = {
1940
defaultLibPaths = [
@@ -28,17 +49,16 @@
2849
name = "metassr-dev";
2950

3051
buildInputs = with pkgs; [
31-
# Core Rust tools
32-
rustc cargo rustfmt clippy rust-analyzer
33-
# Build tools (REVIEW THIS)
52+
# Rust toolchain from fenix
53+
rustToolchain
54+
# Build tools
3455
pkg-config cmake gcc
3556
# System libs
3657
openssl libffi llvmPackages.libclang
3758
# Runtimes
3859
nodejs_22
3960
# dev tools
4061
git curl
41-
4262
less
4363
];
4464

@@ -47,8 +67,8 @@
4767
"-I${pkgs.libclang.lib}/lib/clang/${pkgs.libclang.version}/include";
4868

4969
env = {
50-
RUST_SRC_PATH =
51-
"${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
70+
# rust-src is included in the fenix toolchain
71+
RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";
5272
};
5373

5474
shellHook = ''
@@ -70,4 +90,4 @@
7090
'';
7191
};
7292
});
73-
}
93+
}

0 commit comments

Comments
 (0)