forked from M-Labs/artiq
1
0
Fork 0
artiq/nix/artiq-board.nix

61 lines
1.8 KiB
Nix
Raw Normal View History

2019-02-09 15:07:16 +08:00
# Install Vivado in /opt and add to /etc/nixos/configuration.nix:
# nix.sandboxPaths = ["/opt"];
2019-02-09 11:06:44 +08:00
{ pkgs ? import <nixpkgs> {}}:
{ target, variant }:
2019-02-09 11:06:44 +08:00
let
artiqPkgs = import ./default.nix { inherit pkgs; };
fetchcargo = import ./fetchcargo.nix {
inherit (pkgs) stdenv cacert git cargo cargo-vendor;
2019-02-09 10:36:20 +08:00
};
2019-02-09 11:06:44 +08:00
cargoDeps = fetchcargo rec {
name = "artiq-firmware-cargo-deps";
2019-02-09 10:36:20 +08:00
src = ../artiq/firmware;
sha256 = "1xzjn9i4rkd9124v2gbdplsgsvp1hlx7czdgc58n316vsnrkbr86";
};
2019-02-09 11:06:44 +08:00
cargoVendored = pkgs.stdenv.mkDerivation {
name = "artiq-firmware-cargo-vendored";
src = cargoDeps;
2019-02-09 10:36:20 +08:00
phases = [ "unpackPhase" "installPhase" ];
2019-02-09 11:06:44 +08:00
installPhase =
''
mkdir -p $out/registry
2019-02-09 17:58:46 +08:00
cat << EOF > $out/config
2019-02-09 10:36:20 +08:00
[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]
2019-02-09 11:06:44 +08:00
directory = "$out/registry"
2019-02-09 10:36:20 +08:00
EOF
2019-02-09 11:06:44 +08:00
cp -R * $out/registry
'';
2019-02-09 10:36:20 +08:00
};
buildenv = import ./artiq-dev.nix { inherit pkgs; };
in pkgs.stdenv.mkDerivation {
name = "artiq-board-${target}-${variant}";
2019-02-09 10:36:20 +08:00
src = null;
phases = [ "buildPhase" "installPhase" ];
buildPhase =
''
${buildenv}/bin/artiq-dev -c "CARGO_HOME=${cargoVendored} python -m artiq.gateware.targets.${target} -V ${variant}
2019-02-09 10:36:20 +08:00
'';
installPhase =
''
TARGET_DIR=$out/${pkgs.python3Packages.python.sitePackages}/artiq/binaries/${target}-${variant}
mkdir -p $TARGET_DIR
cp artiq_${target}/${variant}/gateware/top.bit $TARGET_DIR
cp artiq_${target}/${variant}/software/bootloader/bootloader.bin $TARGET_DIR
cp artiq_${target}/${variant}/software/runtime/runtime.{elf,fbi} $TARGET_DIR
2019-02-09 10:36:20 +08:00
'';
}