artiq-full: split code generation into artiq-board-generated jobset

This commit is contained in:
Astro 2021-01-27 20:06:05 +01:00
parent 33c33d49df
commit 64ee51b673
8 changed files with 386 additions and 266 deletions

View File

@ -0,0 +1,97 @@
# Install Vivado in /opt and add to /etc/nixos/configuration.nix:
# nix.sandboxPaths = ["/opt"];
{ pkgs ? import <nixpkgs> {}
, artiq-fast
}:
let
artiqSrc = import (artiq-fast + "/pkgs/artiq-src.nix") { fetchgit = pkgs.fetchgit; };
artiqpkgs = import artiq-fast { inherit pkgs; };
pythonEnv = pkgs.python3.withPackages (ps: with ps; [
jinja2 jsonschema numpy artiqpkgs.migen artiqpkgs.microscope artiqpkgs.misoc artiqpkgs.jesd204b artiqpkgs.artiq
]);
fetchcargo = import (artiq-fast + "/fetchcargo.nix") {
inherit (pkgs) stdenv cacert git;
inherit (artiqpkgs) cargo cargo-vendor;
};
cargoDeps = fetchcargo rec {
name = "artiq-firmware-cargo-deps";
src = "${artiqSrc}/artiq/firmware";
sha256 = import (artiqSrc + "/artiq/firmware/cargosha256.nix");
};
cargoVendored = pkgs.stdenv.mkDerivation {
name = "artiq-firmware-cargo-vendored";
src = cargoDeps;
phases = [ "unpackPhase" "installPhase" ];
installPhase =
''
mkdir -p $out/registry
cat << EOF > $out/config
[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/registry"
EOF
cp -R * $out/registry
'';
};
in
{ target
, variant
, src ? null
, buildCommand ? "python -m artiq.gateware.targets.${target} -V ${variant}"
, extraInstallCommands ? ""
, ...
}:
let
name = "artiq-board-${target}-${variant}-${artiqpkgs.artiq.version}-xxx";
installPath = "${pkgs.python3Packages.python.sitePackages}/artiq/board-support/${target}-${variant}";
in
# Board packages are Python modules so that they get added to the ARTIQ Python
# environment, and artiq_flash finds them.
pkgs.stdenv.mkDerivation {
name = "artiq-board-${target}-${variant}-${artiqpkgs.artiq.version}";
inherit src;
phases = [ "buildPhase" "installPhase" ];
nativeBuildInputs = [
pkgs.gnumake pkgs.which pythonEnv
artiqpkgs.cargo
artiqpkgs.rustc
artiqpkgs.binutils-or1k
artiqpkgs.llvm-or1k
];
buildInputs = [ pythonEnv ];
buildPhase =
''
export CARGO_HOME=${cargoVendored}
export TARGET_AR=or1k-linux-ar
${buildCommand} --no-compile-gateware --gateware-identifier-str=unprogrammed
'';
installPhase =
''
mkdir -p $out
cp -ar artiq_${target}/${variant}/gateware $out
TARGET_DIR=$out/${pkgs.python3Packages.python.sitePackages}/artiq/board-support/${target}-${variant}
mkdir -p $TARGET_DIR
if [ -e artiq_${target}/${variant}/software/bootloader/bootloader.bin ]
then cp artiq_${target}/${variant}/software/bootloader/bootloader.bin $TARGET_DIR
fi
if [ -e artiq_${target}/${variant}/software/runtime ]
then cp artiq_${target}/${variant}/software/runtime/runtime.{elf,fbi} $TARGET_DIR
else cp artiq_${target}/${variant}/software/satman/satman.{elf,fbi} $TARGET_DIR
fi
${extraInstallCommands}
'';
# don't mangle ELF files as they are not for NixOS
dontFixup = true;
}

View File

@ -0,0 +1,54 @@
{ pkgs ? import <nixpkgs> {}
, artiq-fast ? <artiq-fast>
}:
let
sinaraSystemsSrc = <sinaraSystemsSrc>;
generatedNix = pkgs.runCommand "generated-nix" { buildInputs = [ pkgs.nix pkgs.git ]; }
''
mkdir $out
cp ${./artiq-board.nix} $out/artiq-board.nix
cp ${../artiq-full/artiq-targets.nix} $out/artiq-targets.nix
cp -a ${artiq-fast} $out/fast
REV=`git --git-dir ${sinaraSystemsSrc}/.git rev-parse HEAD`
echo -n $REV > $out/sinara-rev.txt
SINARA_SRC_CLEAN=`mktemp -d`
cp -a ${sinaraSystemsSrc}/. $SINARA_SRC_CLEAN
chmod -R 755 $SINARA_SRC_CLEAN/.git
chmod 755 $SINARA_SRC_CLEAN
rm -rf $SINARA_SRC_CLEAN/.git
HASH=`nix-hash --type sha256 --base32 $SINARA_SRC_CLEAN`
echo -n $HASH > $out/sinara-hash.txt
cat > $out/default.nix << EOF
{ pkgs ? import <nixpkgs> {}
}:
let
sinaraSystemsSrc = pkgs.fetchgit {
url = "https://git.m-labs.hk/M-Labs/sinara-systems.git";
rev = "$REV";
sha256 = "$HASH";
};
artiq-fast = import ./fast { inherit pkgs; };
artiq-board = import ./artiq-board.nix {
inherit pkgs;
artiq-fast = ./fast;
};
in
builtins.mapAttrs (_: conf: pkgs.lib.hydraJob (artiq-board conf)) (
import ./artiq-targets.nix {
inherit pkgs sinaraSystemsSrc;
artiqVersion = artiq-fast.artiq.version;
}
)
EOF
'';
artiq-board-generated = import generatedNix {
inherit pkgs;
};
in
artiq-board-generated // {
generated-nix = pkgs.lib.hydraJob generatedNix;
}

View File

@ -47,7 +47,8 @@ in
, variant , variant
, src ? null , src ? null
, buildCommand ? "python -m artiq.gateware.targets.${target} -V ${variant}" , buildCommand ? "python -m artiq.gateware.targets.${target} -V ${variant}"
, extraInstallCommands ? ""}: , extraInstallCommands ? ""
, ... }:
# Board packages are Python modules so that they get added to the ARTIQ Python # Board packages are Python modules so that they get added to the ARTIQ Python
# environment, and artiq_flash finds them. # environment, and artiq_flash finds them.

View File

@ -1,110 +1,127 @@
{ pkgs ? import <nixpkgs> {}}: { pkgs ? import <nixpkgs> {}
, beta ? <beta>
}:
let let
sinaraSystemsSrc = <sinaraSystemsSrc>; sinaraSystemsRev = builtins.readFile <artiq-board-generated/sinara-rev.txt>;
artiqVersion = import <artiq-fast/pkgs/artiq-version.nix> { sinaraSystemsHash = builtins.readFile <artiq-board-generated/sinara-hash.txt>;
sinaraSystemsSrc =
if beta
then pkgs.fetchgit {
url = "https://git.m-labs.hk/M-Labs/sinara-systems.git";
rev = sinaraSystemsRev;
sha256 = sinaraSystemsHash;
}
else <sinaraSystemsSrc>;
artiq-fast =
if beta
then <artiq-board-generated/fast>
else <artiq-fast>;
artiqVersion = import (artiq-fast + "/pkgs/artiq-version.nix") {
inherit (pkgs) stdenv git fetchgit; inherit (pkgs) stdenv git fetchgit;
}; };
variantsJson = targets = import ./artiq-full/artiq-targets.nix {
let inherit pkgs artiqVersion sinaraSystemsSrc;
jsonFiles = };
builtins.attrNames ( kasliVariants = map ({ variant, ... }: variant) (
pkgs.lib.filterAttrs (name: type: builtins.filter ({ target, ... }: target == "kasli") (
type != "directory" && builtins.attrValues targets
builtins.match ".+\\.json" name != null )
) (builtins.readDir sinaraSystemsSrc) );
); standaloneVariants = map ({ variant, ... }: variant) (
in builtins.filter ({ target, standalone ? false, ... }: target == "kasli" && standalone) (
builtins.listToAttrs ( builtins.attrValues targets
map (jsonFile: { )
name = builtins.replaceStrings [".json"] [""] jsonFile; );
value = builtins.fromJSON ( serializedTargets = pkgs.lib.generators.toPretty {} (
builtins.readFile (<sinaraSystemsSrc> + "/${jsonFile}") map (conf:
); if conf ? buildCommand
}) jsonFiles then conf // {
); buildCommand = builtins.replaceStrings ["$"] ["\\\\\\$"] conf.buildCommand;
variants = }
builtins.attrNames ( else conf
pkgs.lib.filterAttrs (_: json: ) (builtins.attrValues targets)
pkgs.lib.strings.versionAtLeast artiqVersion ( );
if json ? min_artiq_version
then json.min_artiq_version
else "0"
)
) variantsJson
);
standaloneVariants =
builtins.attrNames (
pkgs.lib.filterAttrs (_: json:
json.base == "standalone"
) variantsJson
);
generatedNix = pkgs.runCommand "generated-nix" { buildInputs = [ pkgs.nix pkgs.git ]; } generatedNix = pkgs.runCommand "generated-nix" { buildInputs = [ pkgs.nix pkgs.git ]; }
'' ''
mkdir $out mkdir $out
cp -a ${<artiq-fast>} $out/fast ${if beta
cp ${./artiq-full}/artiq-board.nix $out then ''
cp -a ${<artiq-board-generated>} $out/board-generated
ln -s board-generated/fast $out/fast
''
else "cp -a ${<artiq-fast>} $out/fast"}
cp ${./artiq-full}/artiq-board-vivado.nix $out
cp ${./artiq-full}/generate-identifier.py $out cp ${./artiq-full}/generate-identifier.py $out
cp ${./artiq-full}/conda-artiq-board.nix $out cp ${./artiq-full}/conda-artiq-board.nix $out
cp ${./artiq-full}/extras.nix $out cp ${./artiq-full}/extras.nix $out
cp ${./artiq-full}/*.patch $out cp ${./artiq-full}/*.patch $out
REV=`git --git-dir ${sinaraSystemsSrc}/.git rev-parse HEAD` ${if beta
SINARA_SRC_CLEAN=`mktemp -d` then ''
cp -a ${sinaraSystemsSrc}/. $SINARA_SRC_CLEAN REV=${sinaraSystemsRev}
chmod -R 755 $SINARA_SRC_CLEAN/.git HASH=${sinaraSystemsHash}
chmod 755 $SINARA_SRC_CLEAN ''
rm -rf $SINARA_SRC_CLEAN/.git else ''
HASH=`nix-hash --type sha256 --base32 $SINARA_SRC_CLEAN` REV=`git --git-dir ${sinaraSystemsSrc}/.git rev-parse HEAD`
SINARA_SRC_CLEAN=`mktemp -d`
cp -a ${sinaraSystemsSrc}/. $SINARA_SRC_CLEAN
chmod -R 755 $SINARA_SRC_CLEAN/.git
chmod 755 $SINARA_SRC_CLEAN
rm -rf $SINARA_SRC_CLEAN/.git
HASH=`nix-hash --type sha256 --base32 $SINARA_SRC_CLEAN`
''}
cat > $out/default.nix << EOF cat > $out/default.nix << EOF
{ pkgs ? import <nixpkgs> {}}: { pkgs ? import <nixpkgs> {}}:
let let
artiq-fast = import ./fast { inherit pkgs; }; artiq-fast = import ${if beta then "./board-generated" else "."}/fast { inherit pkgs; };
ddbDeps = [ ddbDeps = [
artiq-fast.artiq artiq-fast.artiq
(pkgs.python3.withPackages (ps: [ ps.jsonschema ])) (pkgs.python3.withPackages (ps: [ ps.jsonschema ]))
]; ];
target = "kasli"; kasliVariants = [${builtins.concatStringsSep " " (
variants = [${builtins.concatStringsSep " " ( builtins.map (variant: "\"${variant}\"") kasliVariants
builtins.map (variant: "\"${variant}\"") variants
)}]; )}];
standaloneVariants = [${builtins.concatStringsSep " " ( standaloneVariants = [${builtins.concatStringsSep " " (
builtins.map (variant: "\"${variant}\"") standaloneVariants builtins.map (variant: "\"${variant}\"") standaloneVariants
)}]; )}];
# Splitting the build process into software+gateware does
# not work when artiq embeds compiled firmware into generated
# Vivado input.
boardsWithoutBuildSplit = [
{ target = "sayma"; variant = "rtm"; }
];
vivado = import ./fast/vivado.nix { inherit pkgs; }; vivado = import ${if beta then "./board-generated" else "."}/fast/vivado.nix {
artiq-board-import = path: import path { inherit pkgs vivado; }; inherit pkgs;
artiq-board = args: };
if pkgs.lib.strings.versionAtLeast artiq-fast.artiq.version "6.0" artiq-board =
&& ! builtins.elem { inherit (args) target variant; } boardsWithoutBuildSplit ${if beta
then then ''
artiq-board-import ./artiq-board.nix args import ./artiq-board-vivado.nix {
else inherit pkgs vivado;
artiq-board-import ./fast/artiq-board.nix args; version = artiq-fast.artiq.version;
board-generated = import ./board-generated {
inherit pkgs;
};
}
''
else ''
import ./fast/artiq-board.nix {
inherit pkgs vivado;
}
''};
conda-artiq-board = import ./conda-artiq-board.nix { inherit pkgs; }; conda-artiq-board = import ./conda-artiq-board.nix { inherit pkgs; };
src = pkgs.fetchgit { src = pkgs.fetchgit {
url = "https://git.m-labs.hk/M-Labs/sinara-systems.git"; url = "https://git.m-labs.hk/M-Labs/sinara-systems.git";
rev = "$REV"; rev = "$REV";
sha256 = "$HASH"; sha256 = "$HASH";
}; };
generic-kasli = pkgs.lib.lists.foldr (variant: start: artiq-targets = pkgs.lib.lists.foldr (conf: start:
let let
json = builtins.toPath (src + "/\''${variant}.json"); inherit (conf) target variant;
boardBinaries = artiq-board { json = src + "/\''${variant}.json";
inherit target variant; boardBinaries = artiq-board (conf // {
src = json; src = json;
buildCommand = "python -m artiq.gateware.targets.kasli_generic \$src"; });
};
in in
start // { start // {
"artiq-board-\''${target}-\''${variant}" = boardBinaries; "artiq-board-\''${target}-\''${variant}" = boardBinaries;
@ -112,7 +129,10 @@ let
boardBinaries = boardBinaries; boardBinaries = boardBinaries;
inherit target variant; inherit target variant;
}; };
} // (pkgs.lib.optionalAttrs (builtins.elem variant standaloneVariants) { } // (pkgs.lib.optionalAttrs (
target == "kasli" &&
builtins.elem variant standaloneVariants
) {
"device-db-\''${target}-\''${variant}" = pkgs.stdenv.mkDerivation { "device-db-\''${target}-\''${variant}" = pkgs.stdenv.mkDerivation {
name = "device-db-\''${target}-\''${variant}"; name = "device-db-\''${target}-\''${variant}";
buildInputs = ddbDeps; buildInputs = ddbDeps;
@ -124,52 +144,54 @@ let
echo file device_db_template \$out/device_db.py >> \$out/nix-support/hydra-build-products echo file device_db_template \$out/device_db.py >> \$out/nix-support/hydra-build-products
"; ";
}; };
})) {} variants; })
) {} ${serializedTargets};
drtio-systems = { drtio-systems = {
} // (pkgs.lib.optionalAttrs (pkgs.lib.strings.versionAtLeast artiq-fast.artiq.version "6.0") { ${pkgs.lib.optionalString beta ''
berkeley3 = { berkeley3 = {
master = "berkeley3master"; master = "berkeley3master";
satellites = { satellites = {
"1" = "berkeley3satellite"; "1" = "berkeley3satellite";
};
}; };
}; bonn1 = {
bonn1 = { master = "bonn1master";
master = "bonn1master"; satellites = {
satellites = { "1" = "bonn1satellite";
"1" = "bonn1satellite"; };
}; };
}; hw2 = {
hw2 = { master = "hw2master";
master = "hw2master"; satellites = {
satellites = { "1" = "hw2satellite";
"1" = "hw2satellite"; };
}; };
}; ptb3 = {
ptb3 = { master = "ptb3master";
master = "ptb3master"; satellites = {
satellites = { "1" = "ptb3satellite";
"1" = "ptb3satellite"; };
}; };
}; purdue = {
purdue = { master = "purduemaster";
master = "purduemaster"; satellites = {
satellites = { "1" = "purduesatellite";
"1" = "purduesatellite"; };
}; };
}; stfc = {
stfc = { master = "stfcmaster";
master = "stfcmaster"; satellites = {
satellites = { "1" = "stfcsatellite";
"1" = "stfcsatellite"; };
}; };
}; wipm7 = {
wipm7 = { master = "wipm7master";
master = "wipm7master"; satellites = {
satellites = { "1" = "wipm7satellite";
"1" = "wipm7satellite"; };
}; };
}; ''}
}); };
drtio-ddbs = pkgs.lib.attrsets.mapAttrs' drtio-ddbs = pkgs.lib.attrsets.mapAttrs'
(system: crates: pkgs.lib.attrsets.nameValuePair ("device-db-" + system) (system: crates: pkgs.lib.attrsets.nameValuePair ("device-db-" + system)
(pkgs.stdenv.mkDerivation { (pkgs.stdenv.mkDerivation {
@ -187,42 +209,7 @@ let
})) drtio-systems; })) drtio-systems;
extras = import ./extras.nix { inherit pkgs; inherit (artiq-fast) sipyco asyncserial artiq; }; extras = import ./extras.nix { inherit pkgs; inherit (artiq-fast) sipyco asyncserial artiq; };
in in
artiq-fast // generic-kasli // drtio-ddbs // extras // rec { artiq-fast // artiq-targets // drtio-ddbs // extras // rec {
artiq-board-sayma-rtm = artiq-board {
target = "sayma";
variant = "rtm";
buildCommand = "python -m artiq.gateware.targets.sayma_rtm";
};
artiq-board-sayma-satellite = artiq-board {
target = "sayma";
variant = "satellite";
buildCommand = "python -m artiq.gateware.targets.sayma_amc";
};
artiq-board-metlino-master = artiq-board {
target = "metlino";
variant = "master";
buildCommand = "python -m artiq.gateware.targets.metlino";
};
artiq-board-kc705-nist_qc2 = artiq-board {
target = "kc705";
variant = "nist_qc2";
};
conda-artiq-board-sayma-rtm = conda-artiq-board {
target = "sayma";
variant = "rtm";
boardBinaries = artiq-board-sayma-rtm;
};
conda-artiq-board-sayma-satellite = conda-artiq-board {
target = "sayma";
variant = "satellite";
boardBinaries = artiq-board-sayma-satellite;
};
conda-artiq-board-metlino-master = conda-artiq-board {
target = "metlino";
variant = "master";
boardBinaries = artiq-board-metlino-master;
};
conda-artiq-board-kasli-tester = conda-artiq-board { conda-artiq-board-kasli-tester = conda-artiq-board {
target = "kasli"; target = "kasli";
variant = "tester"; variant = "tester";
@ -233,28 +220,18 @@ let
variant = "nist_clock"; variant = "nist_clock";
boardBinaries = artiq-fast.artiq-board-kc705-nist_clock; boardBinaries = artiq-fast.artiq-board-kc705-nist_clock;
}; };
conda-artiq-board-kc705-nist_qc2 = conda-artiq-board { }
target = "kc705";
variant = "nist_qc2";
boardBinaries = artiq-board-kc705-nist_qc2;
};
} // (pkgs.lib.optionalAttrs (pkgs.lib.strings.versionAtLeast artiq-fast.artiq.version "6.0") rec {
artiq-board-sayma-satellite-st = artiq-board {
target = "sayma";
variant = "satellite";
buildCommand = "python -m artiq.gateware.targets.sayma_amc --jdcg-type syncdds";
};
})
EOF EOF
''; '';
pythonDeps = import ./artiq-full/python-deps.nix { inherit pkgs; }; pythonDeps = import ./artiq-full/python-deps.nix { inherit pkgs; };
sipycoManualPackages = import ./artiq-full/sipyco-manual.nix { sipycoManualPackages = import ./artiq-full/sipyco-manual.nix {
inherit (pkgs) stdenv lib python3Packages texlive texinfo; inherit (pkgs) stdenv lib python3Packages texlive texinfo;
inherit (import <artiq-fast> { inherit pkgs; }) sipyco; inherit (import artiq-fast { inherit pkgs; }) sipyco;
}; };
artiqManualPackages = import ./artiq-full/artiq-manual.nix { artiqManualPackages = import ./artiq-full/artiq-manual.nix {
inherit (pkgs) stdenv lib fetchgit git python3Packages texlive texinfo; inherit (pkgs) stdenv lib fetchgit git python3Packages texlive texinfo;
inherit (pythonDeps) sphinxcontrib-wavedrom; inherit (pythonDeps) sphinxcontrib-wavedrom;
inherit artiq-fast;
}; };
artiq-full = import generatedNix { inherit pkgs; }; artiq-full = import generatedNix { inherit pkgs; };
exampleUserEnv = import ./artiq-full/example-user-env.nix { inherit pkgs artiq-full; }; exampleUserEnv = import ./artiq-full/example-user-env.nix { inherit pkgs artiq-full; };

View File

@ -3,46 +3,11 @@
{ pkgs { pkgs
, vivado ? import ./fast/vivado.nix { inherit pkgs; } , vivado ? import ./fast/vivado.nix { inherit pkgs; }
, board-generated
, version
}: }:
let let
version = import ./fast/pkgs/artiq-version.nix (with pkgs; { inherit stdenv fetchgit git; });
artiqSrc = import ./fast/pkgs/artiq-src.nix { fetchgit = pkgs.fetchgit; };
artiqpkgs = import ./fast/default.nix { inherit pkgs; };
fetchcargo = import ./fast/fetchcargo.nix {
inherit (pkgs) stdenv cacert git;
inherit (artiqpkgs) cargo cargo-vendor;
};
cargoDeps = fetchcargo rec {
name = "artiq-firmware-cargo-deps";
src = "${artiqSrc}/artiq/firmware";
sha256 = import (artiqSrc + "/artiq/firmware/cargosha256.nix");
};
cargoVendored = pkgs.stdenv.mkDerivation {
name = "artiq-firmware-cargo-vendored";
src = cargoDeps;
phases = [ "unpackPhase" "installPhase" ];
installPhase =
''
mkdir -p $out/registry
cat << EOF > $out/config
[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/registry"
EOF
cp -R * $out/registry
'';
};
# Funnelling the source code through a Nix string allows dropping # Funnelling the source code through a Nix string allows dropping
# all dependencies via `unsafeDiscardStringContext`. # all dependencies via `unsafeDiscardStringContext`.
discardContextFromPath = { name, src }: discardContextFromPath = { name, src }:
@ -70,71 +35,13 @@ let
in in
{ target { target
, variant , variant
, src ? null , extraInstallCommands ? ""
, buildCommand ? "python -m artiq.gateware.targets.${target} -V ${variant}" , ... }:
, extraInstallCommands ? ""}:
let let
name = "artiq-board-${target}-${variant}-${version}"; name = "artiq-board-${target}-${variant}-${version}";
installPath = builtins.unsafeDiscardStringContext "${pkgs.python3Packages.python.sitePackages}/artiq/board-support/${target}-${variant}"; installPath = builtins.unsafeDiscardStringContext "${pkgs.python3Packages.python.sitePackages}/artiq/board-support/${target}-${variant}";
pythonEnv = pkgs.python3.withPackages (ps: with ps; [
jinja2 jsonschema numpy artiqpkgs.migen artiqpkgs.microscope artiqpkgs.misoc artiqpkgs.jesd204b artiqpkgs.artiq
]);
generatedSources = generated = board-generated."artiq-board-${target}-${variant}";
pkgs.stdenv.mkDerivation {
name = "${name}-src";
inherit version src;
phases = [ "buildPhase" "installCheckPhase" "installPhase" "checkPhase" ];
buildInputs = [ pythonEnv ];
buildPhase =
''
${buildCommand} --no-compile-software --no-compile-gateware --gateware-identifier-str=unprogrammed
'';
installPhase =
''
mkdir -p $out
cp -ar artiq_${target}/${variant}/{gateware,software} $out
substituteInPlace $out/software/Makefile \
--replace /build/artiq_${target}/${variant}/software/ ""
'';
};
# Board packages are Python modules so that they get added to the ARTIQ Python
# environment, and artiq_flash finds them.
software =
pkgs.stdenv.mkDerivation {
name = "${name}-software";
src = "${generatedSources}/software";
nativeBuildInputs = [
pkgs.gnumake pkgs.which pythonEnv
artiqpkgs.cargo
artiqpkgs.rustc
artiqpkgs.binutils-or1k
artiqpkgs.llvm-or1k
];
buildPhase =
''
export CARGO_HOME=${cargoVendored}
export TARGET_AR=or1k-linux-ar
make BUILDINC_DIRECTORY=`pwd`/include
'';
installPhase =
''
TARGET_DIR=$out/${installPath}
mkdir -p $TARGET_DIR
if [ -e bootloader/bootloader.bin ]
then cp bootloader/bootloader.bin $TARGET_DIR
fi
if [ -e runtime ]
then cp runtime/runtime.{elf,fbi} $TARGET_DIR
else cp satman/satman.{elf,fbi} $TARGET_DIR
fi
${extraInstallCommands}
'';
# don't mangle ELF files as they are not for NixOS
dontFixup = true;
};
identifierStr = "${version};${variant}"; identifierStr = "${version};${variant}";
identifiers = import ( identifiers = import (
@ -149,7 +56,7 @@ let
src = discardContextFromPath { src = discardContextFromPath {
name = "${name}-gateware"; name = "${name}-gateware";
src = "${generatedSources}/gateware"; src = "${generated}/gateware";
}; };
buildInputs = [ vivado pkgs.nix ]; buildInputs = [ vivado pkgs.nix ];
buildPhase = '' buildPhase = ''
@ -213,6 +120,6 @@ in
pkgs.python3Packages.toPythonModule ( pkgs.python3Packages.toPythonModule (
pkgs.buildEnv rec { pkgs.buildEnv rec {
inherit name; inherit name;
paths = [ software vivadoOutput ]; paths = [ generated vivadoOutput ];
pathsToLink = [ "/${installPath}" ]; pathsToLink = [ "/${installPath}" ];
}) })

View File

@ -1,7 +1,7 @@
{ stdenv, lib, fetchgit, git, python3Packages, texlive, texinfo, sphinxcontrib-wavedrom }: { stdenv, lib, fetchgit, git, python3Packages, texlive, texinfo, sphinxcontrib-wavedrom, artiq-fast }:
let let
artiqVersion = import <artiq-fast/pkgs/artiq-version.nix> { inherit stdenv fetchgit git; }; artiqVersion = import (artiq-fast + "/pkgs/artiq-version.nix") { inherit stdenv fetchgit git; };
isLatexPdfTarget = target: builtins.match "latexpdf.*" target != null; isLatexPdfTarget = target: builtins.match "latexpdf.*" target != null;
@ -16,7 +16,7 @@ let
name = "artiq-manual-${target}-${version}"; name = "artiq-manual-${target}-${version}";
version = artiqVersion; version = artiqVersion;
src = import <artiq-fast/pkgs/artiq-src.nix> { inherit fetchgit; }; src = import (artiq-fast + "/pkgs/artiq-src.nix") { inherit fetchgit; };
buildInputs = [ buildInputs = [
python3Packages.sphinx python3Packages.sphinx_rtd_theme python3Packages.sphinx python3Packages.sphinx_rtd_theme
python3Packages.sphinx-argparse sphinxcontrib-wavedrom python3Packages.sphinx-argparse sphinxcontrib-wavedrom
@ -26,7 +26,7 @@ let
preBuild = '' preBuild = ''
export VERSIONEER_OVERRIDE=${artiqVersion} export VERSIONEER_OVERRIDE=${artiqVersion}
export SOURCE_DATE_EPOCH=${import <artiq-fast/pkgs/artiq-timestamp.nix> { inherit stdenv fetchgit git; }} export SOURCE_DATE_EPOCH=${import (artiq-fast + "/pkgs/artiq-timestamp.nix") { inherit stdenv fetchgit git; }}
cd doc/manual cd doc/manual
''; '';
makeFlags = [ target ]; makeFlags = [ target ];

View File

@ -0,0 +1,65 @@
{ pkgs
, artiqVersion
, sinaraSystemsSrc
}:
let
jsons =
map (jsonFile: builtins.fromJSON (
builtins.readFile (sinaraSystemsSrc + "/${jsonFile}")
)) (
builtins.attrNames (
pkgs.lib.filterAttrs (name: type:
type != "directory" &&
builtins.match ".+\\.json" name != null
) (builtins.readDir sinaraSystemsSrc)
)
);
kasli = builtins.listToAttrs (
builtins.map ({ variant, base, ... }: {
name = "artiq-board-kasli-${variant}";
value = {
target = "kasli";
inherit variant;
src = sinaraSystemsSrc + "/${variant}.json";
buildCommand = "python -m artiq.gateware.targets.kasli_generic $src";
standalone = base == "standalone";
};
}) (
builtins.filter (json:
pkgs.lib.strings.versionAtLeast artiqVersion (
if json ? min_artiq_version
then json.min_artiq_version
else "0"
)
) jsons
)
);
in
kasli // {
artiq-board-sayma-rtm = {
target = "sayma";
variant = "rtm";
buildCommand = "python -m artiq.gateware.targets.sayma_rtm";
};
artiq-board-sayma-satellite = {
target = "sayma";
variant = "satellite";
buildCommand = "python -m artiq.gateware.targets.sayma_amc";
};
artiq-board-metlino-master = {
target = "metlino";
variant = "master";
buildCommand = "python -m artiq.gateware.targets.metlino";
};
artiq-board-kc705-nist_qc2 = {
target = "kc705";
variant = "nist_qc2";
};
} // (pkgs.lib.optionalAttrs (pkgs.lib.strings.versionAtLeast artiqVersion "6.0") {
artiq-board-sayma-satellite-st = {
target = "sayma";
variant = "satellite";
buildCommand = "python -m artiq.gateware.targets.sayma_amc --jdcg-type syncdds";
};
})

View File

@ -16,6 +16,24 @@
"artiqSrc": { "type": "git", "value": "git://github.com/m-labs/artiq.git master 1", "emailresponsible": false } "artiqSrc": { "type": "git", "value": "git://github.com/m-labs/artiq.git master 1", "emailresponsible": false }
} }
}, },
"board-generated-beta": {
"enabled": 1,
"hidden": false,
"description": "Generated code for ARTIQ targets (beta version)",
"nixexprinput": "nixScripts",
"nixexprpath": "artiq-board-generated",
"checkinterval": 86400,
"schedulingshares": 1,
"enableemail": false,
"emailoverride": "",
"keepnr": 10,
"inputs": {
"nixpkgs": { "type": "git", "value": "git://github.com/NixOS/nixpkgs nixos-20.09", "emailresponsible": false },
"nixScripts": { "type": "git", "value": "https://git.m-labs.hk/M-Labs/nix-scripts.git", "emailresponsible": false },
"sinaraSystemsSrc": { "type": "git", "value": "https://git.m-labs.hk/M-Labs/sinara-systems.git master 1", "emailresponsible": false },
"artiq-fast": { "type": "sysbuild", "value": "artiq:fast-beta:generated-nix", "emailresponsible": false }
}
},
"full-beta": { "full-beta": {
"enabled": 1, "enabled": 1,
"hidden": false, "hidden": false,
@ -30,8 +48,8 @@
"inputs": { "inputs": {
"nixpkgs": { "type": "git", "value": "git://github.com/NixOS/nixpkgs nixos-20.09", "emailresponsible": false }, "nixpkgs": { "type": "git", "value": "git://github.com/NixOS/nixpkgs nixos-20.09", "emailresponsible": false },
"nixScripts": { "type": "git", "value": "https://git.m-labs.hk/M-Labs/nix-scripts.git", "emailresponsible": false }, "nixScripts": { "type": "git", "value": "https://git.m-labs.hk/M-Labs/nix-scripts.git", "emailresponsible": false },
"sinaraSystemsSrc": { "type": "git", "value": "https://git.m-labs.hk/M-Labs/sinara-systems.git master 1", "emailresponsible": false }, "beta": { "type": "boolean", "value": "true" },
"artiq-fast": { "type": "sysbuild", "value": "artiq:fast-beta:generated-nix", "emailresponsible": false } "artiq-board-generated": { "type": "sysbuild", "value": "artiq:board-generated-beta:generated-nix", "emailresponsible": false }
} }
}, },
"fast": { "fast": {
@ -66,6 +84,7 @@
"nixpkgs": { "type": "git", "value": "git://github.com/NixOS/nixpkgs nixos-20.03", "emailresponsible": false }, "nixpkgs": { "type": "git", "value": "git://github.com/NixOS/nixpkgs nixos-20.03", "emailresponsible": false },
"nixScripts": { "type": "git", "value": "https://git.m-labs.hk/M-Labs/nix-scripts.git", "emailresponsible": false }, "nixScripts": { "type": "git", "value": "https://git.m-labs.hk/M-Labs/nix-scripts.git", "emailresponsible": false },
"sinaraSystemsSrc": { "type": "git", "value": "https://git.m-labs.hk/M-Labs/sinara-systems.git master 1", "emailresponsible": false }, "sinaraSystemsSrc": { "type": "git", "value": "https://git.m-labs.hk/M-Labs/sinara-systems.git master 1", "emailresponsible": false },
"beta": { "type": "boolean", "value": "false" },
"artiq-fast": { "type": "sysbuild", "value": "artiq:fast:generated-nix", "emailresponsible": false } "artiq-fast": { "type": "sysbuild", "value": "artiq:fast:generated-nix", "emailresponsible": false }
} }
}, },