flake: fix build, replace cargoSha256 -> cargoLock

This commit is contained in:
mwojcik 2022-01-17 16:44:42 +08:00
parent 22cc53d854
commit e749a96971

View File

@ -27,45 +27,51 @@
rustc = rust; rustc = rust;
cargo = rust; cargo = rust;
}); });
cargoSha256 = "0qb4s06jwgj3i9df6qq9gwcnyr3jq6dh4l5ygjghq5x1bmcqliix"; thermostat = rustPlatform.buildRustPackage rec {
buildStm32Firmware = { name, src, cargoDepsName ? name, patchPhase ? "", extraNativeBuildInputs ? [], checkPhase ? "", doCheck ? true, binaryName ? name, extraCargoBuildArgs ? "" }: name = "thermostat";
rustPlatform.buildRustPackage rec {
inherit name cargoDepsName;
version = "0.0.0"; version = "0.0.0";
inherit src; src = self;
inherit cargoSha256; cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"stm32-eth-0.2.0" = "sha256-HXRr/NDhdIKqyjdA4D8ZmcO1dDpDawdlYPUOwcEbPQk=";
"stm32f4xx-hal-0.8.3" = "sha256-MOv7tVtVMxr3IYMaN0Q8EQWxv3rubmCxjXMXuw/ZKAw=";
};
};
inherit patchPhase; patchPhase = "";
nativeBuildInputs = [ pkgs.llvm ] ++ extraNativeBuildInputs; nativeBuildInputs = [ pkgs.llvm ];
buildPhase = '' buildPhase = ''
export CARGO_HOME=$(mktemp -d cargo-home.XXX) export CARGO_HOME=$(mktemp -d cargo-home.XXX)
cargo build --release --bin ${binaryName} ${extraCargoBuildArgs} cargo build --release --bin thermostat
'';
checkPhase = ''
cargo test --target=${pkgs.rust.toRustTarget pkgs.stdenv.targetPlatform};
''; '';
inherit checkPhase doCheck;
# binaryName defaults to the `name` arg (i.e. the Rust package name); # binaryName defaults to the `name` arg (i.e. the Rust package name);
# it is used as the Cargo binary filename # it is used as the Cargo binary filename
installPhase = '' installPhase = ''
mkdir -p $out $out/nix-support mkdir -p $out $out/nix-support
cp target/thumbv7em-none-eabihf/release/${binaryName} $out/${name}.elf cp target/thumbv7em-none-eabihf/release/thermostat $out/thermostat.elf
echo file binary-dist $out/${name}.elf >> $out/nix-support/hydra-build-products echo file binary-dist $out/thermostat.elf >> $out/nix-support/hydra-build-products
llvm-objcopy -O binary target/thumbv7em-none-eabihf/release/${binaryName} $out/${name}.bin llvm-objcopy -O binary target/thumbv7em-none-eabihf/release/thermostat $out/thermostat.bin
echo file binary-dist $out/${name}.bin >> $out/nix-support/hydra-build-products echo file binary-dist $out/thermostat.bin >> $out/nix-support/hydra-build-products
''; '';
dontFixup = true; dontFixup = true;
}; };
in { in rec {
packages.x86_64-linux = rec { packages.x86_64-linux = rec {
thermostat = buildStm32Firmware { inherit thermostat;
name = "thermostat";
src = self;
checkPhase = ''
cargo test --target=${pkgs.rust.toRustTarget pkgs.stdenv.targetPlatform};
'';
}; };
hydraJobs = {
inherit (packages.x86_64-linux) thermostat;
}; };
devShell.x86_64-linux = pkgs.mkShell { devShell.x86_64-linux = pkgs.mkShell {
name = "thermostat-dev-shell"; name = "thermostat-dev-shell";
buildInputs = with pkgs; [ buildInputs = with pkgs; [
@ -76,6 +82,6 @@
numpy matplotlib numpy matplotlib
]); ]);
}; };
defaultPackage.x86_64-linux = pkgs.python3.withPackages(ps: [ ]); defaultPackage.x86_64-linux = thermostat;
}; };
} }