From 868216eb2d29508796172e0c8364d29cc666e708 Mon Sep 17 00:00:00 2001 From: Harry Ho Date: Tue, 29 Jun 2021 17:14:34 +0800 Subject: [PATCH] mcu: keep cargo tarball name the same for different variants * This partially reverts 726ee7aa82f812f40f631b7c4e7040d84a1b627a, and keeps allowing the generated binary to have a name different from the derivation. --- mcu/default.nix | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/mcu/default.nix b/mcu/default.nix index 98c16a5..ec16425 100644 --- a/mcu/default.nix +++ b/mcu/default.nix @@ -8,17 +8,12 @@ let rustPlatform = pkgs.recurseIntoAttrs (pkgs.callPackage ./rustPlatform.nix { inherit rustManifest; }); - buildStm32Firmware = { name, src, patchPhase ? "", extraNativeBuildInputs ? [], checkPhase ? "", doCheck ? true, ... } @ args: + buildStm32Firmware = { name, src, cargoDepsName ? name, patchPhase ? "", extraNativeBuildInputs ? [], checkPhase ? "", doCheck ? true, ... } @ args: let - # If binaryName is specified as an arg of buildStm32Firmware, - # then the .nix containing the cargoSha256 must be named "cargosha256-${binaryName}.nix"; - # otherwise, the .nix must be named "cargosha256.nix". cargoSha256Drv = pkgs.runCommand "${name}-cargosha256" { } '' - cp "${src}/cargosha256${ - if (args ? binaryName) then "-" + args.binaryName else "" - }.nix" $out + cp "${src}/cargosha256.nix" $out ''; - # If binaryName is specified as an arg of buildStm32Firmware, + # If binaryName is specified, # then pass it as an argument for `cargo build`; otherwise, do not add such argument. extraCargoBuildArgs = ( (if (args ? extraCargoBuildArgs) then (args.extraCargoBuildArgs + " ") else "") + @@ -30,7 +25,7 @@ let binaryName = if (args ? binaryName) then args.binaryName else name; in rustPlatform.buildRustPackage rec { - inherit name; + inherit name cargoDepsName; version = "0.0.0"; inherit src; @@ -60,6 +55,7 @@ in stabilizer-dual-iir = buildStm32Firmware { name = "stabilizer-dual-iir"; binaryName = "dual-iir"; + cargoDepsName = "stabilizer"; src = ; patchPhase = '' substituteInPlace src/hardware/configuration.rs \