269 lines
11 KiB
Nix
269 lines
11 KiB
Nix
# let
|
|
# system = "x86_64-linux";
|
|
# in
|
|
{
|
|
description = "ARTIQ";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:nixos/nixpkgs/release-20.09";
|
|
artiq-beta-src = {
|
|
url = "github:M-Labs/artiq";
|
|
flake = false;
|
|
};
|
|
artiq-src = {
|
|
url = "github:M-Labs/artiq/release-6";
|
|
flake = false;
|
|
};
|
|
artiq-legacy-src = {
|
|
url = "github:M-Labs/artiq/release-5";
|
|
flake = false;
|
|
};
|
|
sinara-systems = {
|
|
url = "git+https://git.m-labs.hk/M-Labs/sinara-systems.git";
|
|
flake = false;
|
|
};
|
|
};
|
|
|
|
outputs = sources@{ self, nixpkgs, ... }:
|
|
let
|
|
systems = [
|
|
"x86_64-linux"
|
|
];
|
|
forAllSystems = f:
|
|
builtins.foldl' (systems: system:
|
|
systems // { ${system} = f system; }
|
|
) {} systems;
|
|
in rec {
|
|
|
|
packages = forAllSystems (system:
|
|
let
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
|
|
artiq-fast-src = artiqInputName:
|
|
let
|
|
# locked = (builtins.fromJSON (
|
|
# builtins.readFile ./flake.lock
|
|
# )).nodes.${artiqInputName}.locked;
|
|
inherit (sources.${artiqInputName}) lastModified rev narHash;
|
|
hash = builtins.replaceStrings ["sha256-"] [""] narHash;
|
|
|
|
artiqSrc = sources.${artiqInputName}.outPath;
|
|
|
|
in pkgs.runCommand "generated-nix" { buildInputs = [ pkgs.nix pkgs.git ]; } ''
|
|
cp --no-preserve=mode,ownership -R ${./artiq-fast} $out
|
|
|
|
MAJOR_VERSION=`cat ${artiqSrc}/MAJOR_VERSION`
|
|
if [ -e ${artiqSrc}/BETA ]; then
|
|
SUFFIX=".beta"
|
|
else
|
|
SUFFIX=""
|
|
fi
|
|
|
|
cat > $out/pkgs/artiq-src.nix << EOF
|
|
{ fetchgit }:
|
|
fetchgit {
|
|
url = "git://github.com/m-labs/artiq.git";
|
|
rev = "${rev}";
|
|
sha256 = "${hash}";
|
|
}
|
|
EOF
|
|
echo "{ stdenv, git, fetchgit }: \"$MAJOR_VERSION.`cut -c1-8 <<< ${rev}`$SUFFIX\"" > $out/pkgs/artiq-version.nix
|
|
echo "{ stdenv, git, fetchgit }: \"${toString lastModified}\"" > $out/pkgs/artiq-timestamp.nix
|
|
'';
|
|
artiq-fast = artiqInputName:
|
|
import (artiq-fast-src artiqInputName) {
|
|
inherit pkgs;
|
|
};
|
|
|
|
artiq-board-generated = artiqInputName:
|
|
(import ./artiq-board-generated {
|
|
inherit pkgs;
|
|
sinaraSystemsSrc = null; #sources.sinara-systems.outPath;
|
|
sinaraSystemsRev = sources.sinara-systems.rev;
|
|
sinaraSystemsHash = builtins.replaceStrings ["sha256-"] [""]
|
|
sources.sinara-systems.narHash;
|
|
artiq-fast = artiq-fast-src artiqInputName;
|
|
}).generated-nix;
|
|
|
|
artiq-full = artiqInputName: a6p:
|
|
import ./artiq-full.nix {
|
|
inherit pkgs;
|
|
inherit a6p;
|
|
artiq-board-generated = artiq-board-generated artiqInputName;
|
|
sinaraSystemsSrc = sources.sinara-systems.outPath;
|
|
artiq-fast = artiq-fast-src artiqInputName;
|
|
};
|
|
|
|
# artiq-full1 = artiqInputName: a6p:
|
|
# let
|
|
# pythonDeps = import ./artiq-full/python-deps.nix { inherit pkgs; };
|
|
# ddbDeps = [
|
|
# artiq-fast.artiq
|
|
# (pkgs.python3.withPackages (ps: [ ps.jsonschema ]))
|
|
# ];
|
|
# artiqVersion = (artiq-fast artiqInputName).artiq.version;
|
|
|
|
# targets = import ./artiq-full/artiq-targets.nix {
|
|
# inherit pkgs artiqVersion;
|
|
# sinaraSystemsSrc = sources.sinara-systems.outPath;
|
|
# };
|
|
# kasliVariants = map ({ variant, ... }: variant) (
|
|
# builtins.filter ({ target, ... }: target == "kasli") (
|
|
# builtins.attrValues targets
|
|
# )
|
|
# );
|
|
# standaloneVariants = map ({ variant, ... }: variant) (
|
|
# builtins.filter ({ target, standalone ? false, ... }: target == "kasli" && standalone) (
|
|
# builtins.attrValues targets
|
|
# )
|
|
# );
|
|
|
|
# vivado = import ./artiq-fast/vivado.nix {
|
|
# inherit pkgs;
|
|
# };
|
|
# artiq-board =
|
|
# if a6p
|
|
# then
|
|
# import ./artiq-full/artiq-board-vivado.nix {
|
|
# inherit pkgs vivado;
|
|
# version = artiqVersion;
|
|
# board-generated = artiq-board-generated artiqInputName;
|
|
# }
|
|
# else
|
|
# import ./artiq-fast/artiq-board.nix {
|
|
# inherit pkgs vivado;
|
|
# };
|
|
# conda-artiq-board = import ./artiq-full/conda-artiq-board.nix {
|
|
# inherit pkgs;
|
|
# };
|
|
# artiq-targets = pkgs.lib.lists.foldr (conf: start:
|
|
# let
|
|
# inherit (conf) target variant;
|
|
# json = sources.sinara-systems.outPath + "/${variant}.json";
|
|
# boardBinaries = artiq-board (conf // {
|
|
# src = json;
|
|
# });
|
|
# in
|
|
# start // {
|
|
# "artiq-board-${target}-${variant}" = boardBinaries;
|
|
# "conda-artiq-board-${target}-${variant}" = conda-artiq-board {
|
|
# boardBinaries = boardBinaries;
|
|
# inherit target variant;
|
|
# };
|
|
# } // (pkgs.lib.optionalAttrs (
|
|
# target == "kasli" &&
|
|
# builtins.elem variant standaloneVariants
|
|
# ) {
|
|
# "device-db-${target}-${variant}" = pkgs.stdenv.mkDerivation {
|
|
# name = "device-db-${target}-${variant}";
|
|
# buildInputs = ddbDeps;
|
|
# 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
|
|
# ";
|
|
# };
|
|
# })
|
|
# ) {} (builtins.attrValues targets);
|
|
# drtio-systems =
|
|
# if a6p then {
|
|
# berkeley3 = {
|
|
# master = "berkeley3master";
|
|
# satellites = {
|
|
# "1" = "berkeley3satellite";
|
|
# };
|
|
# };
|
|
# bonn1 = {
|
|
# master = "bonn1master";
|
|
# satellites = {
|
|
# "1" = "bonn1satellite";
|
|
# };
|
|
# };
|
|
# hw2 = {
|
|
# master = "hw2master";
|
|
# satellites = {
|
|
# "1" = "hw2satellite";
|
|
# };
|
|
# };
|
|
# ptb3 = {
|
|
# master = "ptb3master";
|
|
# satellites = {
|
|
# "1" = "ptb3satellite";
|
|
# };
|
|
# };
|
|
# purdue = {
|
|
# master = "purduemaster";
|
|
# satellites = {
|
|
# "1" = "purduesatellite";
|
|
# };
|
|
# };
|
|
# stfc = {
|
|
# master = "stfcmaster";
|
|
# satellites = {
|
|
# "1" = "stfcsatellite";
|
|
# };
|
|
# };
|
|
# wipm7 = {
|
|
# master = "wipm7master";
|
|
# satellites = {
|
|
# "1" = "wipm7satellite";
|
|
# };
|
|
# };
|
|
# }
|
|
# else {};
|
|
# drtio-ddbs = pkgs.lib.attrsets.mapAttrs'
|
|
# (system: crates: pkgs.lib.attrsets.nameValuePair ("device-db-" + system)
|
|
# (pkgs.stdenv.mkDerivation {
|
|
# name = "device-db-${system}";
|
|
# buildInputs = ddbDeps;
|
|
# phases = [ "buildPhase" ];
|
|
# buildPhase = ''
|
|
# mkdir \$out
|
|
# artiq_ddb_template \
|
|
# ${pkgs.lib.strings.concatStringsSep " " (pkgs.lib.attrsets.mapAttrsToList (dest: desc: "-s " + dest + " " + (sources.sinara-systems.outPath + "/${desc}.json")) crates.satellites) } \
|
|
# ${sources.sinara-systems.outPath}/${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;
|
|
# extras = import ./artiq-full/extras.nix { inherit pkgs; inherit (artiq-fast artiqInputName) sipyco asyncserial artiq; };
|
|
|
|
# artiq-full = artiq-targets // drtio-ddbs // extras // rec {
|
|
# conda-artiq-board-kasli-tester = conda-artiq-board {
|
|
# target = "kasli";
|
|
# variant = "tester";
|
|
# boardBinaries = artiq-fast.artiq-board-kasli-tester;
|
|
# };
|
|
# conda-artiq-board-kc705-nist_clock = conda-artiq-board {
|
|
# target = "kc705";
|
|
# variant = "nist_clock";
|
|
# boardBinaries = artiq-fast.artiq-board-kc705-nist_clock;
|
|
# };
|
|
# };
|
|
# 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 {
|
|
# inherit (pkgs) stdenv lib fetchgit git python3Packages texlive texinfo;
|
|
# inherit (pythonDeps) sphinxcontrib-wavedrom;
|
|
# inherit artiq-fast;
|
|
# };
|
|
# exampleUserEnv = import ./artiq-full/example-user-env.nix { inherit pkgs artiq-full; };
|
|
# jobs = artiq-full // sipycoManualPackages // artiqManualPackages // exampleUserEnv;
|
|
# in
|
|
# jobs;
|
|
|
|
allPackages = artiqInputName: a6p:
|
|
(artiq-fast artiqInputName) //
|
|
#(artiq-board-generated artiqInputName);
|
|
(artiq-full artiqInputName a6p);
|
|
in allPackages "artiq-beta-src" true
|
|
);
|
|
|
|
defaultPackage = forAllSystems (system: self.packages.${system}.artiq);
|
|
};
|
|
}
|