From 07ac42505bf1fed62d4fe76a157f4c8aefaf1d70 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 9 Feb 2019 10:36:20 +0800 Subject: [PATCH] nix: add firmware derivation (WIP) --- nix/artiq-board.nix | 56 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 nix/artiq-board.nix diff --git a/nix/artiq-board.nix b/nix/artiq-board.nix new file mode 100644 index 000000000..d68537503 --- /dev/null +++ b/nix/artiq-board.nix @@ -0,0 +1,56 @@ +let + pkgs = import {}; + fetchcargo = import { + inherit (pkgs) stdenv cacert git rust cargo-vendor; + }; + myVendoredSrcFetchCargo = fetchcargo rec { + name = "myVendoredSrcFetchCargo"; + sourceRoot = null; + srcs = null; + src = ../artiq/firmware; + cargoUpdateHook = ""; + patches = []; + sha256 = "1xzjn9i4rkd9124v2gbdplsgsvp1hlx7czdgc58n316vsnrkbr86"; + }; + + myVendoredSrc = pkgs.stdenv.mkDerivation { + name = "myVendoredSrc"; + src = myVendoredSrcFetchCargo; + phases = [ "unpackPhase" "installPhase" ]; + installPhase = '' + mkdir -p $out/.cargo/registry + cat > $out/.cargo/config << EOF + [source.crates-io] + registry = "https://github.com/rust-lang/crates.io-index" + replace-with = "vendored-sources" + + [source."https://github.com/m-labs/libfringe"] + git = "https://github.com/m-labs/libfringe" + rev = "b8a6d8f" + replace-with = "vendored-sources" + + [source.vendored-sources] + directory = "$out/.cargo/registry" + EOF + cp -R * $out/.cargo/registry + ''; + }; + + buildenv = import ./artiq-dev.nix { inherit pkgs; }; + +in pkgs.stdenv.mkDerivation { + name = "artiq-board"; + src = null; + phases = [ "buildPhase" "installPhase" ]; + buildPhase = + '' + ${buildenv}/bin/artiq-dev -c "HOME=${myVendoredSrc} python -m artiq.gateware.targets.kasli -V satellite --no-compile-gateware" + ''; + installPhase = + '' + mkdir $out + #cp artiq_kasli/satellite/gateware/top.bit $out + cp artiq_kasli/satellite/software/bootloader/bootloader.bin $out + cp artiq_kasli/satellite/software/satman/satman.{elf,fbi} $out + ''; +}