fix(rust): cross compilation

This commit is contained in:
Florian Warzecha 2024-05-16 18:01:19 +02:00
parent 6c25032fcd
commit 90b7063195
Signed by untrusted user: liketechnik
GPG key ID: 4BE8C7D97F910C60

View file

@ -35,10 +35,8 @@
overlays = [ (final: prev: { ${packageName} = self.packages.${system}.${packageName}; }) ]; overlays = [ (final: prev: { ${packageName} = self.packages.${system}.${packageName}; }) ];
}; };
fenixPkgsFor = pkgs: fenix.packages.${pkgs.system}; fenixPkgs = fenix.packages.${pkgs.system};
fenixChannelFor = fenixChannel = fenixPkgs.toolchainOf {
pkgs:
(fenixPkgsFor pkgs).toolchainOf {
channel = "nightly"; channel = "nightly";
date = date =
builtins.replaceStrings [ "nightly-" ] [ "" ] builtins.replaceStrings [ "nightly-" ] [ "" ]
@ -48,10 +46,7 @@
toolchainFor = toolchainFor =
pkgs: pkgs:
let with fenixPkgs;
fenix-pkgs = fenixPkgsFor pkgs;
in
with fenix-pkgs;
combine [ combine [
minimal.cargo minimal.cargo
minimal.rustc minimal.rustc
@ -86,8 +81,8 @@
inherit inherit
system system
pkgs pkgs
fenixPkgsFor fenixPkgs
fenixChannelFor fenixChannel
toolchainFor toolchainFor
rustPlatformFor rustPlatformFor
crossPackageFor crossPackageFor
@ -101,21 +96,18 @@
packages = forSystems ( packages = forSystems (
{ {
pkgs, pkgs,
fenixChannelFor, fenixChannel,
system, system,
crossPackageFor, crossPackageFor,
... ...
}: }:
let
fenix-channel = fenixChannelFor pkgs;
in
{ {
${packageName} = pkgs.callPackage (./. + "/nix/packages/${packageName}.nix") { ${packageName} = pkgs.callPackage (./. + "/nix/packages/${packageName}.nix") {
inherit cargoMeta; inherit cargoMeta;
flake-self = self; flake-self = self;
rustPlatform = pkgs.makeRustPlatform { rustPlatform = pkgs.makeRustPlatform {
cargo = fenix-channel.toolchain; cargo = fenixChannel.toolchain;
rustc = fenix-channel.toolchain; rustc = fenixChannel.toolchain;
}; };
}; };
default = self.packages.${system}.${packageName}; default = self.packages.${system}.${packageName};
@ -128,10 +120,9 @@
); );
devShells = forSystems ( devShells = forSystems (
{ pkgs, fenixChannelFor, ... }: { pkgs, fenixChannel, ... }:
let let
fenix-channel = fenixChannelFor pkgs; fenixRustToolchain = fenixChannel.withComponents [
fenixRustToolchain = fenix-channel.withComponents [
"cargo" "cargo"
"clippy-preview" "clippy-preview"
"rust-src" "rust-src"