Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 42 additions & 34 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,35 @@
};
};

outputs =
{
self,
nixpkgs,
fenix,
}:
let
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: fn system);
in
{
devShells = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
fenixPkgs = fenix.packages.${system};
toolchain = fenixPkgs.fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-vra6TkHITpwRyA5oBKAHSX0Mi6CBDNQD+ryPSpxFsfg=";
};
in
{
default = pkgs.mkShell.override { stdenv = pkgs.clangStdenv; } {
RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
packages = [
outputs = {
self,
nixpkgs,
fenix,
}: let
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: fn (pkgsFor system) (toolchainFor system));
pkgsFor = system:
import nixpkgs {
system = system;
};
toolchainFor = system:
fenix.packages.${system}.fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "sha256-vra6TkHITpwRyA5oBKAHSX0Mi6CBDNQD+ryPSpxFsfg=";
};
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
in {
devShells = forAllSystems (
pkgs: toolchain: {
default = pkgs.mkShell.override {stdenv = pkgs.clangStdenv;} {
RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
packages =
[
toolchain
pkgs.treefmt
pkgs.shfmt
Expand All @@ -53,8 +52,17 @@
pkgs.apple-sdk
pkgs.libiconv
];
};
}
);
};
};
}
);
packages = forAllSystems (pkgs: toolchain: rec {
sukr = pkgs.rustPlatform.buildRustPackage {
pname = cargoToml.package.name;
version = cargoToml.package.version;
src = ./.;
cargoHash = "sha256-mPm8Pe4W9TyDuuXLHWqA9DzbkTyR1kkfLZ3SmEt+dUc=";
};
Comment on lines 59 to 64
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pkgs.rustPlatform.buildRustPackage will still build with the Rust toolchain from nixpkgs; adding the fenix toolchain to buildInputs doesn’t switch the compiler/cargo, and also pulls the full toolchain into the runtime closure. If the intent is to build with the pinned rust-toolchain.toml, create a rustPlatform using pkgs.makeRustPlatform { cargo = toolchain; rustc = toolchain; } (or set the appropriate nativeBuildInputs/env vars) and avoid placing the toolchain in buildInputs.

Suggested change
sukr = pkgs.rustPlatform.buildRustPackage {
pname = cargoToml.package.name;
version = cargoToml.package.version;
src = ./.;
buildInputs = [toolchain];
cargoHash = "sha256-mPm8Pe4W9TyDuuXLHWqA9DzbkTyR1kkfLZ3SmEt+dUc=";
};
sukr =
let
rustPlatform = pkgs.makeRustPlatform {
cargo = toolchain;
rustc = toolchain;
};
in
rustPlatform.buildRustPackage {
pname = cargoToml.package.name;
version = cargoToml.package.version;
src = ./.;
cargoHash = "sha256-mPm8Pe4W9TyDuuXLHWqA9DzbkTyR1kkfLZ3SmEt+dUc=";
};

Copilot uses AI. Check for mistakes.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @uttarayan21 thanks for catching this, can you integrate fenix as copilot suggests here? That way we are using a consistent toolchain throughout? Thanks

default = sukr;
});
};
}