Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
fix(rust): cross compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
liketechnik committed May 16, 2024
1 parent 6c25032 commit 90b7063
Showing 1 changed file with 16 additions and 25 deletions.
41 changes: 16 additions & 25 deletions rust/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -86,8 +81,8 @@
inherit
system
pkgs
fenixPkgsFor
fenixChannelFor
fenixPkgs
fenixChannel
toolchainFor
rustPlatformFor
crossPackageFor
Expand All @@ -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};
Expand All @@ -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"
Expand Down

0 comments on commit 90b7063

Please sign in to comment.