1
0
Fork 0
nix-scripts/artiq-full.nix

271 lines
9.5 KiB
Nix
Raw Normal View History

{ pkgs ? import <nixpkgs> {}}:
2019-02-15 23:06:00 +08:00
let
2019-02-16 00:24:20 +08:00
sinaraSystemsSrc = <sinaraSystemsSrc>;
artiqVersion = import <artiq-fast/pkgs/artiq-version.nix> {
inherit (pkgs) stdenv git fetchgit;
};
variantsJson =
let
jsonFiles =
builtins.attrNames (
pkgs.lib.filterAttrs (name: type:
type != "directory" &&
builtins.match ".+\\.json" name != null
) (builtins.readDir sinaraSystemsSrc)
);
in
builtins.listToAttrs (
map (jsonFile: {
name = builtins.replaceStrings [".json"] [""] jsonFile;
value = builtins.fromJSON (
builtins.readFile (<sinaraSystemsSrc> + "/${jsonFile}")
);
}) jsonFiles
);
variants =
builtins.attrNames (
pkgs.lib.filterAttrs (_: json:
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
);
2019-02-16 00:24:20 +08:00
generatedNix = pkgs.runCommand "generated-nix" { buildInputs = [ pkgs.nix pkgs.git ]; }
''
mkdir $out
2019-07-17 19:35:29 +08:00
cp -a ${<artiq-fast>} $out/fast
cp ${./artiq-full}/artiq-board.nix $out
2020-12-22 08:21:43 +08:00
cp ${./artiq-full}/generate-identifier.py $out
2020-11-23 23:23:02 +08:00
cp ${./artiq-full}/conda-artiq-board.nix $out
cp ${./artiq-full}/extras.nix $out
cp ${./artiq-full}/*.patch $out
2019-07-17 19:35:29 +08:00
2019-02-16 00:24:20 +08:00
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`
2019-02-16 00:24:20 +08:00
cat > $out/default.nix << EOF
{ pkgs ? import <nixpkgs> {}}:
let
2019-12-03 11:46:01 +08:00
artiq-fast = import ./fast { inherit pkgs; };
2021-01-15 16:36:48 +08:00
ddbDeps = [
artiq-fast.artiq
(pkgs.python3.withPackages (ps: [ ps.jsonschema ]))
];
2019-12-03 11:46:01 +08:00
2019-02-16 00:24:20 +08:00
target = "kasli";
variants = [${builtins.concatStringsSep " " (
builtins.map (variant: "\"${variant}\"") variants
)}];
standaloneVariants = [${builtins.concatStringsSep " " (
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"; }
];
2019-02-16 00:24:20 +08:00
vivado = import ./fast/vivado.nix { inherit pkgs; };
artiq-board-import = path: import path { inherit pkgs vivado; };
artiq-board = args:
if pkgs.lib.strings.versionAtLeast artiq-fast.artiq.version "6.0"
&& ! builtins.elem { inherit (args) target variant; } boardsWithoutBuildSplit
then
artiq-board-import ./artiq-board.nix args
else
artiq-board-import ./fast/artiq-board.nix args;
2019-07-17 22:36:44 +08:00
conda-artiq-board = import ./conda-artiq-board.nix { inherit pkgs; };
2019-02-16 00:24:20 +08:00
src = pkgs.fetchgit {
2019-05-07 15:58:33 +08:00
url = "https://git.m-labs.hk/M-Labs/sinara-systems.git";
2019-02-16 00:24:20 +08:00
rev = "$REV";
sha256 = "$HASH";
};
2019-02-19 20:47:44 +08:00
generic-kasli = pkgs.lib.lists.foldr (variant: start:
2019-02-16 00:24:20 +08:00
let
json = builtins.toPath (src + "/\''${variant}.json");
2019-02-16 00:24:20 +08:00
boardBinaries = artiq-board {
inherit target variant;
src = json;
buildCommand = "python -m artiq.gateware.targets.kasli_generic \$src";
2019-02-16 00:24:20 +08:00
};
in
start // {
"artiq-board-\''${target}-\''${variant}" = boardBinaries;
"conda-artiq-board-\''${target}-\''${variant}" = conda-artiq-board {
boardBinaries = boardBinaries;
inherit target variant;
2019-02-22 23:46:16 +08:00
};
} // (pkgs.lib.optionalAttrs (builtins.elem variant standaloneVariants) {
2019-02-22 23:46:16 +08:00
"device-db-\''${target}-\''${variant}" = pkgs.stdenv.mkDerivation {
name = "device-db-\''${target}-\''${variant}";
2021-01-15 16:36:48 +08:00
buildInputs = ddbDeps;
2019-02-22 23:46:16 +08:00
phases = [ "buildPhase" ];
buildPhase = "
mkdir \$out
artiq_ddb_template \''${json} -o \$out/device_db.py
mkdir \$out/nix-support
echo file device_db_template \$out/device_db.py >> \$out/nix-support/hydra-build-products
";
};
})) {} variants;
drtio-systems = {
2019-12-04 19:37:24 +08:00
} // (pkgs.lib.optionalAttrs (pkgs.lib.strings.versionAtLeast artiq-fast.artiq.version "6.0") {
berkeley3 = {
master = "berkeley3master";
satellites = {
"1" = "berkeley3satellite";
};
};
2019-12-03 11:46:01 +08:00
bonn1 = {
master = "bonn1master";
satellites = {
"1" = "bonn1satellite";
};
};
hw2 = {
master = "hw2master";
satellites = {
"1" = "hw2satellite";
};
};
2020-11-16 16:42:32 +08:00
ptb3 = {
master = "ptb3master";
satellites = {
"1" = "ptb3satellite";
};
};
purdue = {
master = "purduemaster";
satellites = {
"1" = "purduesatellite";
};
};
stfc = {
master = "stfcmaster";
satellites = {
"1" = "stfcsatellite";
};
};
2020-12-14 11:18:42 +08:00
wipm7 = {
master = "wipm7master";
satellites = {
"1" = "wipm7satellite";
};
};
2019-12-03 11:46:01 +08:00
});
drtio-ddbs = pkgs.lib.attrsets.mapAttrs'
(system: crates: pkgs.lib.attrsets.nameValuePair ("device-db-" + system)
(pkgs.stdenv.mkDerivation {
name = "device-db-\''${system}";
2021-01-15 16:36:48 +08:00
buildInputs = ddbDeps;
phases = [ "buildPhase" ];
buildPhase = "
mkdir \$out
artiq_ddb_template \
\''${pkgs.lib.strings.concatStringsSep " " (pkgs.lib.attrsets.mapAttrsToList (dest: desc: "-s " + dest + " " + (src + "/\''${desc}.json")) crates.satellites) } \
\''${src}/\''${crates.master}.json -o \$out/device_db.py
mkdir \$out/nix-support
echo file device_db_template \$out/device_db.py >> \$out/nix-support/hydra-build-products
";
})) drtio-systems;
2019-11-07 19:34:36 +08:00
extras = import ./extras.nix { inherit pkgs; inherit (artiq-fast) sipyco asyncserial artiq; };
2019-02-19 20:47:44 +08:00
in
artiq-fast // generic-kasli // drtio-ddbs // extras // rec {
artiq-board-sayma-rtm = artiq-board {
target = "sayma";
variant = "rtm";
buildCommand = "python -m artiq.gateware.targets.sayma_rtm";
};
2019-02-19 20:47:44 +08:00
artiq-board-sayma-satellite = artiq-board {
target = "sayma";
variant = "satellite";
buildCommand = "python -m artiq.gateware.targets.sayma_amc";
2019-02-19 20:47:44 +08:00
};
2019-05-19 11:44:53 +08:00
artiq-board-metlino-master = artiq-board {
target = "metlino";
variant = "master";
buildCommand = "python -m artiq.gateware.targets.metlino";
};
2019-07-18 09:41:33 +08:00
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 {
target = "kasli";
variant = "tester";
boardBinaries = artiq-fast.artiq-board-kasli-tester;
};
2019-07-17 22:36:44 +08:00
conda-artiq-board-kc705-nist_clock = conda-artiq-board {
target = "kc705";
variant = "nist_clock";
boardBinaries = artiq-fast.artiq-board-kc705-nist_clock;
};
2019-07-18 09:41:33 +08:00
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";
};
})
2019-02-16 00:24:20 +08:00
EOF
'';
2019-07-17 22:41:43 +08:00
pythonDeps = import ./artiq-full/python-deps.nix { inherit pkgs; };
2019-11-12 10:43:50 +08:00
sipycoManualPackages = import ./artiq-full/sipyco-manual.nix {
inherit (pkgs) stdenv lib python3Packages texlive texinfo;
inherit (import <artiq-fast> { inherit pkgs; }) sipyco;
};
artiqManualPackages = import ./artiq-full/artiq-manual.nix {
2019-07-17 20:02:06 +08:00
inherit (pkgs) stdenv lib fetchgit git python3Packages texlive texinfo;
inherit (pythonDeps) sphinxcontrib-wavedrom;
};
2021-01-15 17:23:19 +08:00
artiq-full = import generatedNix { inherit pkgs; };
exampleUserEnv = import ./artiq-full/example-user-env.nix { inherit pkgs artiq-full; };
jobs = artiq-full // sipycoManualPackages // artiqManualPackages // exampleUserEnv;
in
2019-07-17 22:48:14 +08:00
builtins.mapAttrs (key: value: pkgs.lib.hydraJob value) jobs // {
artiq-full = pkgs.releaseTools.channel {
name = "artiq-full";
2019-02-16 00:24:20 +08:00
src = generatedNix;
constituents = [];
2019-02-16 00:24:20 +08:00
};
2019-07-18 00:08:35 +08:00
conda-channel = import ./artiq-full/conda-channel.nix { inherit pkgs; } { inherit jobs; };
2019-02-16 00:24:20 +08:00
}