2019-02-14 15:29:42 +08:00
|
|
|
{ pkgs ? import <nixpkgs> {}}:
|
|
|
|
let
|
2019-02-14 20:16:56 +08:00
|
|
|
artiqSrc = <artiqSrc>;
|
2019-02-14 19:31:46 +08:00
|
|
|
generatedNix = pkgs.runCommand "generated-nix" { buildInputs = [ pkgs.nix pkgs.git ]; }
|
2019-02-14 15:29:42 +08:00
|
|
|
''
|
|
|
|
cp --no-preserve=mode,ownership -R ${./artiq} $out
|
2019-02-14 19:31:46 +08:00
|
|
|
REV=`git --git-dir ${artiqSrc}/.git rev-parse HEAD`
|
|
|
|
HASH=`nix-hash --type sha256 --base32 ${artiqSrc}`
|
|
|
|
cat > $out/pkgs/artiq-src.nix << EOF
|
|
|
|
{ fetchgit }:
|
|
|
|
fetchgit {
|
|
|
|
url = "git://github.com/m-labs/artiq.git";
|
|
|
|
rev = "$REV";
|
|
|
|
sha256 = "$HASH";
|
|
|
|
leaveDotGit = true;
|
|
|
|
}
|
|
|
|
EOF
|
2019-02-15 22:34:56 +08:00
|
|
|
echo \"5e.`cut -c1-8 <<< $REV`\" > $out/pkgs/artiq-version.nix
|
2019-02-14 15:29:42 +08:00
|
|
|
'';
|
2019-03-14 11:19:18 +08:00
|
|
|
generateTestOkHash = pkgs.runCommand "generate-test-ok-hash" { buildInputs = [ pkgs.nix ]; }
|
|
|
|
''
|
|
|
|
TMPDIR=`mktemp -d`
|
2019-03-14 14:52:30 +08:00
|
|
|
cp ${generatedNix}/pkgs/artiq-version.nix $TMPDIR/passed5
|
2019-03-14 11:19:18 +08:00
|
|
|
HASH=`nix-hash --type sha256 --base32 $TMPDIR`
|
|
|
|
echo \"$HASH\" > $out
|
|
|
|
'';
|
2019-02-15 18:17:34 +08:00
|
|
|
artiqpkgs = import "${generatedNix}/default.nix" { inherit pkgs; };
|
2019-02-19 15:28:45 +08:00
|
|
|
artiqVersion = import "${generatedNix}/pkgs/artiq-version.nix";
|
2019-02-15 18:17:34 +08:00
|
|
|
jobs = builtins.mapAttrs (key: value: pkgs.lib.hydraJob value) artiqpkgs;
|
2019-02-14 15:29:42 +08:00
|
|
|
in
|
|
|
|
jobs // {
|
2019-03-14 11:19:18 +08:00
|
|
|
generated-nix = pkgs.lib.hydraJob generatedNix; # used by sinara-systems
|
2019-02-17 22:37:33 +08:00
|
|
|
channel = pkgs.releaseTools.channel rec {
|
2019-02-14 17:26:52 +08:00
|
|
|
name = "main";
|
2019-02-14 17:49:40 +08:00
|
|
|
src = generatedNix;
|
2019-02-14 15:29:42 +08:00
|
|
|
constituents = builtins.attrValues jobs;
|
|
|
|
};
|
2019-03-14 11:19:18 +08:00
|
|
|
|
|
|
|
# HACK: Abuse fixed-output derivations to escape the sandbox and run the hardware
|
|
|
|
# unit tests, all integrated in the Hydra interface.
|
|
|
|
# One major downside of this hack is the tests are only run when generateTestOkHash
|
|
|
|
# changes, i.e. when the ARTIQ version changes (and not the dependencies).
|
|
|
|
# Impure derivations, when they land in Nix/Hydra, should improve the situation.
|
2019-03-14 14:06:40 +08:00
|
|
|
kc705-tests = pkgs.stdenv.mkDerivation rec {
|
2019-03-14 12:28:25 +08:00
|
|
|
name = "kc705-tests";
|
2019-03-14 11:19:18 +08:00
|
|
|
outputHashAlgo = "sha256";
|
|
|
|
outputHashMode = "recursive";
|
|
|
|
outputHash = import generateTestOkHash;
|
|
|
|
buildInputs = [
|
2019-03-14 12:26:03 +08:00
|
|
|
(pkgs.python3.withPackages(ps: [ ps.paramiko artiqpkgs.artiq artiqpkgs.artiq-board-kc705-nist_clock ]))
|
2019-03-14 11:19:18 +08:00
|
|
|
artiqpkgs.binutils-or1k
|
2019-03-14 12:26:03 +08:00
|
|
|
artiqpkgs.openocd
|
2019-03-14 11:19:18 +08:00
|
|
|
pkgs.iputils
|
|
|
|
];
|
|
|
|
phases = [ "buildPhase" ];
|
|
|
|
buildPhase =
|
|
|
|
''
|
2019-03-14 14:20:28 +08:00
|
|
|
whoami
|
2019-03-14 14:06:40 +08:00
|
|
|
export HOME=`mktemp -d`
|
|
|
|
mkdir $HOME/.ssh
|
2019-03-14 14:13:42 +08:00
|
|
|
cp /opt/hydra_id_rsa $HOME/.ssh/id_rsa
|
2019-03-14 14:20:28 +08:00
|
|
|
cp /opt/hydra_id_rsa.pub $HOME/.ssh/id_rsa.pub
|
|
|
|
echo "rpi,192.168.1.188 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMc7waNkP2HjL5Eo94evoxJhC8CbYj4i2n1THe5TPIR3" > $HOME/.ssh/known_hosts
|
|
|
|
chmod 600 $HOME/.ssh/id_rsa
|
2019-03-14 13:06:20 +08:00
|
|
|
artiq_flash -t kc705 -H rpi
|
2019-03-14 11:19:18 +08:00
|
|
|
sleep 15
|
|
|
|
# ping: socket: Operation not permitted
|
|
|
|
#ping kc705-1 -c10 -w30
|
2019-03-14 14:56:05 +08:00
|
|
|
export ARTIQ_ROOT=`python -c "import artiq; print(artiq.__path__[0])"`/examples/kc705_nist_clock
|
2019-03-14 11:19:18 +08:00
|
|
|
export ARTIQ_LOW_LATENCY=1
|
|
|
|
python -m unittest discover -v artiq.test.coredevice
|
|
|
|
mkdir $out
|
2019-03-14 14:52:30 +08:00
|
|
|
cp ${generatedNix}/pkgs/artiq-version.nix $out/passed5
|
2019-03-14 11:19:18 +08:00
|
|
|
'';
|
|
|
|
};
|
2019-02-14 15:29:42 +08:00
|
|
|
}
|