From 842a77fb2bc684a545fb102e16790fa902aec11c Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 10 Jul 2026 21:48:42 -0400 Subject: [PATCH] Pass in rust-overlay for creating rust-bin. --- flake.nix | 29 ++++++++++++++--------- nix/package.nix | 63 +++++++++++++++++++++++++++---------------------- 2 files changed, 53 insertions(+), 39 deletions(-) diff --git a/flake.nix b/flake.nix index b06e340..3745050 100644 --- a/flake.nix +++ b/flake.nix @@ -96,6 +96,7 @@ bindgenTarget ? null, }: (organicScope.callPackage ./nix/package.nix { + inherit rust-overlay; targetBins = [ "wasm" ]; @@ -128,18 +129,24 @@ ); in { - library = (organicScope.callPackage ./nix/package.nix { buildLib = true; }).overrideAttrs ( - old: - let - in - { - installPhase = '' - mkdir -p $out/lib - cp target/*/release/liborganic.rlib $out/lib/ - ''; - } - ); + library = + (organicScope.callPackage ./nix/package.nix { + inherit rust-overlay; + buildLib = true; + }).overrideAttrs + ( + old: + let + in + { + installPhase = '' + mkdir -p $out/lib + cp target/*/release/liborganic.rlib $out/lib/ + ''; + } + ); devTools = organicScope.callPackage ./nix/package.nix { + inherit rust-overlay; targetBins = [ "parse" "compare" diff --git a/nix/package.nix b/nix/package.nix index 780c6dc..6ad1a95 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -1,8 +1,8 @@ { hello, lib, - makeRustPlatform, - rust-bin, + pkgs, + rust-overlay, targetBins ? [ ], features ? [ ], @@ -12,34 +12,41 @@ }: let cargoToml = (lib.importTOML ../Cargo.toml); - rustToolchain = (rust-bin.fromRustupToolchainFile ../rust-toolchain.toml).override ( - if cargoBuildTarget != null then - { - targets = [ cargoBuildTarget ]; - } - else - { } - ); - baseRustPlatform = ( - makeRustPlatform { - cargo = rustToolchain; - rustc = rustToolchain; - } - ); - rustPlatform = - if cargoBuildTarget != null then - baseRustPlatform.overrideScope ( - final: prev: { - cargoBuildHook = prev.cargoBuildHook.overrideDerivation (_: { - rustcTargetSpec = cargoBuildTarget; - }); - cargoInstallHook = hello; + rustPlatformFor = + pkgs: + let + rust-bin = rust-overlay.lib.mkRustBin { } pkgs; + rustToolchain = (rust-bin.fromRustupToolchainFile ../rust-toolchain.toml).override ( + if cargoBuildTarget != null then + { + targets = [ cargoBuildTarget ]; + } + else + { } + ); + baseRustPlatform = ( + pkgs.makeRustPlatform { + cargo = rustToolchain; + rustc = rustToolchain; } - ) - else - baseRustPlatform; + ); + rustPlatform = + if cargoBuildTarget != null then + baseRustPlatform.overrideScope ( + final: prev: { + cargoBuildHook = prev.cargoBuildHook.overrideDerivation (_: { + rustcTargetSpec = cargoBuildTarget; + }); + cargoInstallHook = hello; + } + ) + else + baseRustPlatform; + in + rustPlatform; in -rustPlatform.buildRustPackage ( +(rustPlatformFor pkgs).buildRustPackage ( + # rustPlatform.buildRustPackage ( { pname = "organic"; version = cargoToml.package.version;