From cf7c6e8545a50ce791d80058ed13a71e93247aca Mon Sep 17 00:00:00 2001 From: HaeNoe Date: Mon, 2 Mar 2026 09:57:15 +0100 Subject: [PATCH] fix: error on target platform != x86_64-unknown-linux-gnu Ensure `RUSTFLAGS` is not `null`, when target platform is not x86_64-unknown-linux-gnu but rather `""`. Note that as per https://doc.rust-lang.org/cargo/reference/config.html#buildrustflags an empty RUSTFLAGS still overrides user configuration (e.g. in cargo config). --- flake.nix | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/flake.nix b/flake.nix index b614ce7..79d272b 100644 --- a/flake.nix +++ b/flake.nix @@ -61,12 +61,13 @@ rust-toolchain = fenix.packages.${system}.fromManifestFile rust-manifest; - rustflags = - if pkgs.stdenv.hostPlatform.rust.rustcTargetSpec == "x86_64-unknown-linux-gnu" then - # Upstream defaults to lld on x86_64-unknown-linux-gnu, we need to use the system linker - "-Clinker-features=-lld -Clink-self-contained=-linker" - else - null; + # Upstream defaults to lld on x86_64-unknown-linux-gnu, we need to use the system linker + rustflags = lib.concatStringsSep " " ( + lib.optionals (pkgs.stdenv.hostPlatform.rust.rustcTargetSpec == "x86_64-unknown-linux-gnu") [ + "-Clinker-features=-lld" + "-Clink-self-contained=-linker" + ] + ); # Crane-based Nix flake configuration. # Based on https://github.com/ipetkov/crane/blob/master/examples/trunk-workspace/flake.nix