From 80ffb632dfde0404c7fdb756bf623486fac7e454 Mon Sep 17 00:00:00 2001 From: eljamm Date: Sat, 18 Jan 2025 10:49:51 +0100 Subject: [PATCH] fix(nix): rust overlay infinite recursion The rust-overlay project strongly recommend NOT overlaying the global Rust platform since that can cause a dependency loop, creating an infinite recursion. Instead, a custom `rustPlatform` can be passed to the derivation, as per the instructions in the [Nixpkgs manual](https://nixos.org/manual/nixpkgs/stable/#using-rust-nightly-in-a-derivation-with-buildrustpackage). --- flake.nix | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/flake.nix b/flake.nix index c6a11b0a..88b7ac49 100644 --- a/flake.nix +++ b/flake.nix @@ -21,21 +21,12 @@ let pkgs = import nixpkgs { inherit system; - overlays = [ - rust-overlay.overlays.default - ( - final: prev: - let - toolchain = final.rust-bin.stable.latest.default; - in - { - rustPlatform = prev.makeRustPlatform { - cargo = toolchain; - rustc = toolchain; - }; - } - ) - ]; + overlays = [ rust-overlay.overlays.default ]; + }; + toolchain = pkgs.rust-bin.stable.latest.default; + rustPlatform = pkgs.makeRustPlatform { + cargo = toolchain; + rustc = toolchain; }; rev = self.shortRev or self.dirtyShortRev or "dirty"; @@ -46,7 +37,14 @@ in { packages = { - yazi-unwrapped = pkgs.callPackage ./nix/yazi-unwrapped.nix { inherit version rev date; }; + yazi-unwrapped = pkgs.callPackage ./nix/yazi-unwrapped.nix { + inherit + version + rev + date + rustPlatform + ; + }; yazi = pkgs.callPackage ./nix/yazi.nix { inherit (self.packages.${system}) yazi-unwrapped; }; default = self.packages.${system}.yazi; };