From 90b70631953e553306ee0b72c2ae2f7436fd4555 Mon Sep 17 00:00:00 2001 From: Florian Warzecha Date: Thu, 16 May 2024 18:01:19 +0200 Subject: [PATCH] fix(rust): cross compilation --- rust/flake.nix | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/rust/flake.nix b/rust/flake.nix index 6e11f07..6fa9cdb 100644 --- a/rust/flake.nix +++ b/rust/flake.nix @@ -35,23 +35,18 @@ overlays = [ (final: prev: { ${packageName} = self.packages.${system}.${packageName}; }) ]; }; - fenixPkgsFor = pkgs: fenix.packages.${pkgs.system}; - fenixChannelFor = - pkgs: - (fenixPkgsFor pkgs).toolchainOf { - channel = "nightly"; - date = - builtins.replaceStrings [ "nightly-" ] [ "" ] - (builtins.fromTOML (builtins.readFile ./rust-toolchain.toml)).toolchain.channel; - sha256 = "sha256-SzEeSoO54GiBQ2kfANPhWrt0EDRxqEvhIbTt2uJt/TQ="; - }; + fenixPkgs = fenix.packages.${pkgs.system}; + fenixChannel = fenixPkgs.toolchainOf { + channel = "nightly"; + date = + builtins.replaceStrings [ "nightly-" ] [ "" ] + (builtins.fromTOML (builtins.readFile ./rust-toolchain.toml)).toolchain.channel; + sha256 = "sha256-SzEeSoO54GiBQ2kfANPhWrt0EDRxqEvhIbTt2uJt/TQ="; + }; toolchainFor = pkgs: - let - fenix-pkgs = fenixPkgsFor pkgs; - in - with fenix-pkgs; + with fenixPkgs; combine [ minimal.cargo minimal.rustc @@ -86,8 +81,8 @@ inherit system pkgs - fenixPkgsFor - fenixChannelFor + fenixPkgs + fenixChannel toolchainFor rustPlatformFor crossPackageFor @@ -101,21 +96,18 @@ packages = forSystems ( { pkgs, - fenixChannelFor, + fenixChannel, system, crossPackageFor, ... }: - let - fenix-channel = fenixChannelFor pkgs; - in { ${packageName} = pkgs.callPackage (./. + "/nix/packages/${packageName}.nix") { inherit cargoMeta; flake-self = self; rustPlatform = pkgs.makeRustPlatform { - cargo = fenix-channel.toolchain; - rustc = fenix-channel.toolchain; + cargo = fenixChannel.toolchain; + rustc = fenixChannel.toolchain; }; }; default = self.packages.${system}.${packageName}; @@ -128,10 +120,9 @@ ); devShells = forSystems ( - { pkgs, fenixChannelFor, ... }: + { pkgs, fenixChannel, ... }: let - fenix-channel = fenixChannelFor pkgs; - fenixRustToolchain = fenix-channel.withComponents [ + fenixRustToolchain = fenixChannel.withComponents [ "cargo" "clippy-preview" "rust-src"