diff --git a/hydra/mcu.json b/hydra/mcu.json index ec3df67..80dffff 100644 --- a/hydra/mcu.json +++ b/hydra/mcu.json @@ -14,7 +14,7 @@ "nixpkgs": { "type": "git", "value": "git://github.com/NixOS/nixpkgs nixos-21.05", "emailresponsible": false }, "mozillaOverlay": { "type": "git", "value": "git://github.com/mozilla/nixpkgs-mozilla.git", "emailresponsible": false }, "nixScripts": { "type": "git", "value": "https://git.m-labs.hk/M-Labs/nix-scripts.git", "emailresponsible": false }, - "stabilizerSrc": { "type": "git", "value": "git://github.com/quartiq/stabilizer.git", "emailresponsible": false }, + "stabilizerSrc": { "type": "git", "value": "git://github.com/HarryMakes/stabilizer.git pre-mqtt 1", "emailresponsible": false }, "thermostatSrc": { "type": "git", "value": "https://git.m-labs.hk/M-Labs/thermostat.git", "emailresponsible": false }, "humpbackDdsSrc": { "type": "git", "value": "https://git.m-labs.hk/M-Labs/humpback-dds.git", "emailresponsible": false }, "saymaMmcSrc": { "type": "git", "value": "git://github.com/sinara-hw/openMMC sayma-devel", "emailresponsible": false } diff --git a/mcu/default.nix b/mcu/default.nix index cc58861..44b05ae 100644 --- a/mcu/default.nix +++ b/mcu/default.nix @@ -8,23 +8,24 @@ let rustPlatform = pkgs.recurseIntoAttrs (pkgs.callPackage ./rustPlatform.nix { inherit rustManifest; }); - buildStm32Firmware = { name, src, patchPhase ? "", extraNativeBuildInputs ? [], checkPhase ? "", ... } @ 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 "") + + (if (args ? binaryName) then ("--bin " + binaryName) else "") + ); + # If binaryName is specified, # then use it as the filename of the ELF generated from `cargo build`; # otherwise, use the `name` arg (i.e. the Rust package name) as the ELF filename. binaryName = if (args ? binaryName) then args.binaryName else name; in rustPlatform.buildRustPackage rec { - inherit name; + inherit name cargoDepsName; version = "0.0.0"; inherit src; @@ -34,10 +35,10 @@ let nativeBuildInputs = [ pkgs.llvm ] ++ extraNativeBuildInputs; buildPhase = '' export CARGO_HOME=$(mktemp -d cargo-home.XXX) - cargo build --release + cargo build --release ${extraCargoBuildArgs} ''; - inherit checkPhase; + inherit checkPhase doCheck; installPhase = '' mkdir -p $out $out/nix-support cp target/thumbv7em-none-eabihf/release/${binaryName} $out/${name}.elf @@ -50,10 +51,13 @@ let }; migen = (import ../artiq-fast/pkgs/python-deps.nix { inherit (pkgs) lib fetchgit fetchFromGitHub python3Packages; misoc-new = true; }).migen; in - { - stabilizer-dual-iir = buildStm32Firmware { - name = "stabilizer-dual-iir"; - binaryName = "dual-iir"; + pkgs.lib.attrsets.mapAttrs' + (name: value: pkgs.lib.attrsets.nameValuePair ("stabilizer-" + name) + (buildStm32Firmware { + name = "stabilizer-" + name; + # If binaryName is not specified, use the attribute name as binaryName by default. + binaryName = if (value ? binaryName) then value.binaryName else name; + cargoDepsName = "stabilizer"; src = ; patchPhase = '' substituteInPlace src/hardware/configuration.rs \ @@ -62,7 +66,25 @@ in --replace "Ipv4Address::new(10, 34, 16, 1)" \ "Ipv4Address::new(192, 168, 1, 1)" ''; - }; + doCheck = false; + })) { + dual-iir = {}; + dual-iir-pounder_v1_1 = { + binaryName = "dual-iir"; + extraCargoBuildArgs = "--features pounder_v1_1"; + }; + lockin-external = {}; + lockin-external-pounder_v1_1 = { + binaryName = "lockin-external"; + extraCargoBuildArgs = "--features pounder_v1_1"; + }; + lockin-internal = {}; + lockin-internal-pounder_v1_1 = { + binaryName = "lockin-internal"; + extraCargoBuildArgs = "--features pounder_v1_1"; + }; + } // + { thermostat = buildStm32Firmware { name = "thermostat"; src = ;