From eaf42a6bec4687f7ed0027b085d37e494100f262 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Thu, 30 Jul 2020 18:01:53 -0500 Subject: [PATCH 1/2] Support pre-20.03 Nixpkgs toRustTarget was added in https://github.com/nixos/nixpkgs/commits/83ac9c07e4df352e177ebdf978320089a137183a So not all nixpkgs have it. We can provide a backup of it in this case. Fixes #232 --- rust-overlay.nix | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/rust-overlay.nix b/rust-overlay.nix index 933f842..34ae550 100644 --- a/rust-overlay.nix +++ b/rust-overlay.nix @@ -53,7 +53,7 @@ let getComponentsWithFixedPlatform = pkgs: pkgname: stdenv: let pkg = pkgs.${pkgname}; - srcInfo = pkg.target.${super.rust.toRustTarget stdenv.targetPlatform} or pkg.target."*"; + srcInfo = pkg.target.${toRustTarget stdenv.targetPlatform} or pkg.target."*"; components = srcInfo.components or []; componentNamesList = builtins.map (pkg: pkg.pkg) (builtins.filter (pkg: (pkg.target != "*")) components); @@ -64,7 +64,7 @@ let let inherit (super.lib) unique; pkg = pkgs.${pkgname}; - srcInfo = pkg.target.${super.rust.toRustTarget stdenv.targetPlatform} or pkg.target."*"; + srcInfo = pkg.target.${toRustTarget stdenv.targetPlatform} or pkg.target."*"; extensions = srcInfo.extensions or []; extensionNamesList = unique (builtins.map (pkg: pkg.pkg) extensions); in @@ -73,6 +73,15 @@ let hasTarget = pkgs: pkgname: target: pkgs ? ${pkgname}.target.${target}; + toRustTarget = super.rust.toRustTarget or (platform: with platform.parsed; let + cpu_ = { + "armv7a" = "armv7"; + "armv7l" = "armv7"; + "armv6l" = "arm"; + }.${cpu.name} or platform.rustc.arch or cpu.name; + in platform.rustc.config + or "${cpu_}-${vendor.name}-${kernel.name}${lib.optionalString (abi.name != "unknown") "-${abi.name}"}"); + getTuples = pkgs: name: targets: builtins.map (target: { inherit name target; }) (builtins.filter (target: hasTarget pkgs name target) targets); @@ -119,7 +128,7 @@ let inherit (super.lib) flatten remove subtractLists unique; targetExtensionsToInstall = checkMissingExtensions pkgs pkgname stdenv targetExtensions; extensionsToInstall = checkMissingExtensions pkgs pkgname stdenv extensions; - hostTargets = [ "*" (super.rust.toRustTarget stdenv.hostPlatform) (super.rust.toRustTarget stdenv.targetPlatform) ]; + hostTargets = [ "*" (toRustTarget stdenv.hostPlatform) (toRustTarget stdenv.targetPlatform) ]; pkgTuples = flatten (getTargetPkgTuples pkgs pkgname hostTargets targets stdenv); extensionTuples = flatten (map (name: getTargetPkgTuples pkgs name hostTargets targets stdenv) extensionsToInstall); targetExtensionTuples = flatten (map (name: getTargetPkgTuples pkgs name targets targets stdenv) targetExtensionsToInstall); From 3ae360a339edd23aa7d51c9a56ac10880f1c5179 Mon Sep 17 00:00:00 2001 From: lf- Date: Sun, 9 Aug 2020 17:01:58 -0700 Subject: [PATCH 2/2] Fix undefined reference --- rust-overlay.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-overlay.nix b/rust-overlay.nix index 34ae550..7f8f447 100644 --- a/rust-overlay.nix +++ b/rust-overlay.nix @@ -80,7 +80,7 @@ let "armv6l" = "arm"; }.${cpu.name} or platform.rustc.arch or cpu.name; in platform.rustc.config - or "${cpu_}-${vendor.name}-${kernel.name}${lib.optionalString (abi.name != "unknown") "-${abi.name}"}"); + or "${cpu_}-${vendor.name}-${kernel.name}${super.lib.optionalString (abi.name != "unknown") "-${abi.name}"}"); getTuples = pkgs: name: targets: builtins.map (target: { inherit name target; }) (builtins.filter (target: hasTarget pkgs name target) targets);