Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

artiq-fast.nix 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. let
  2. pkgs = import <nixpkgs> {};
  3. artiqSrc = <artiqSrc>;
  4. generatedNix = pkgs.runCommand "generated-nix" { buildInputs = [ pkgs.nix pkgs.git ]; }
  5. ''
  6. cp --no-preserve=mode,ownership -R ${./artiq-fast} $out
  7. REV=`git --git-dir ${artiqSrc}/.git rev-parse HEAD`
  8. MAJOR_VERSION=`cat ${artiqSrc}/MAJOR_VERSION`
  9. COMMIT_COUNT=`git --git-dir ${artiqSrc}/.git rev-list --count HEAD`
  10. TIMESTAMP=`git --git-dir ${artiqSrc}/.git log -1 --format=%ct`
  11. ARTIQ_SRC_CLEAN=`mktemp -d`
  12. cp -a ${artiqSrc}/. $ARTIQ_SRC_CLEAN
  13. chmod -R 755 $ARTIQ_SRC_CLEAN/.git
  14. chmod 755 $ARTIQ_SRC_CLEAN
  15. rm -rf $ARTIQ_SRC_CLEAN/.git
  16. HASH=`nix-hash --type sha256 --base32 $ARTIQ_SRC_CLEAN`
  17. cat > $out/pkgs/artiq-src.nix << EOF
  18. { fetchgit }:
  19. fetchgit {
  20. url = "git://github.com/m-labs/artiq.git";
  21. rev = "$REV";
  22. sha256 = "$HASH";
  23. }
  24. EOF
  25. echo "{ stdenv, git, fetchgit }: \"$MAJOR_VERSION.$COMMIT_COUNT.`cut -c1-8 <<< $REV`.beta\"" > $out/pkgs/artiq-version.nix
  26. echo "{ stdenv, git, fetchgit }: \"$TIMESTAMP\"" > $out/pkgs/artiq-timestamp.nix
  27. '';
  28. generateTestOkHash = pkgs.runCommand "generate-test-ok-hash" { buildInputs = [ pkgs.nix ]; }
  29. ''
  30. TMPDIR=`mktemp -d`
  31. cp ${generatedNix}/pkgs/artiq-version.nix $TMPDIR/passed
  32. HASH=`nix-hash --type sha256 --base32 $TMPDIR`
  33. echo \"$HASH\" > $out
  34. '';
  35. artiqpkgs = import "${generatedNix}/default.nix" { inherit pkgs; };
  36. artiqVersion = import "${generatedNix}/pkgs/artiq-version.nix" (with pkgs; { inherit stdenv fetchgit git; });
  37. windowsRunner = overrides:
  38. import "${generatedNix}/windows/run-test.nix" ({
  39. inherit pkgs;
  40. artiqPkg = artiqpkgs.conda-artiq;
  41. } // overrides);
  42. jobs = (builtins.mapAttrs (key: value: pkgs.lib.hydraJob value) artiqpkgs);
  43. in
  44. jobs // {
  45. generated-nix = pkgs.lib.hydraJob generatedNix; # used by artiq-full
  46. artiq-fast = pkgs.releaseTools.channel {
  47. name = "artiq-fast";
  48. src = generatedNix;
  49. constituents = builtins.attrValues jobs;
  50. };
  51. windows-no-hardware-tests = pkgs.stdenv.mkDerivation {
  52. name = "windows-no-hardware-tests";
  53. buildInputs = [ (windowsRunner {}) ];
  54. phases = [ "buildPhase" ];
  55. buildPhase = ''
  56. ${windowsRunner {}}/bin/run.sh
  57. touch $out
  58. '';
  59. };
  60. # HACK: Abuse fixed-output derivations to escape the sandbox and run the hardware
  61. # unit tests, all integrated in the Hydra interface.
  62. # One major downside of this hack is the tests are only run when generateTestOkHash
  63. # changes, i.e. when the ARTIQ version changes (and not the dependencies).
  64. # Impure derivations, when they land in Nix/Hydra, should improve the situation.
  65. extended-tests = pkgs.stdenv.mkDerivation {
  66. name = "extended-tests";
  67. outputHashAlgo = "sha256";
  68. outputHashMode = "recursive";
  69. outputHash = import generateTestOkHash;
  70. __hydraRetry = false;
  71. buildInputs = [
  72. (pkgs.python3.withPackages(ps: [ ps.paramiko artiqpkgs.artiq artiqpkgs.artiq-board-kc705-nist_clock ]))
  73. artiqpkgs.binutils-or1k
  74. artiqpkgs.openocd
  75. pkgs.iputils
  76. pkgs.openssh
  77. ];
  78. phases = [ "buildPhase" ];
  79. buildPhase =
  80. ''
  81. export HOME=`mktemp -d`
  82. mkdir $HOME/.ssh
  83. cp /opt/hydra_id_rsa $HOME/.ssh/id_rsa
  84. cp /opt/hydra_id_rsa.pub $HOME/.ssh/id_rsa.pub
  85. echo "rpi-1,192.168.1.188 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMc7waNkP2HjL5Eo94evoxJhC8CbYj4i2n1THe5TPIR3" > $HOME/.ssh/known_hosts
  86. chmod 600 $HOME/.ssh/id_rsa
  87. LOCKCTL=$(mktemp -d)
  88. mkfifo $LOCKCTL/lockctl
  89. cat $LOCKCTL/lockctl | ${pkgs.openssh}/bin/ssh \
  90. -i $HOME/.ssh/id_rsa \
  91. -o UserKnownHostsFile=$HOME/.ssh/known_hosts \
  92. sb@rpi-1 \
  93. 'flock /tmp/board_lock-kc705-1 -c "echo Ok; cat"' \
  94. | (
  95. # End remote flock via FIFO
  96. atexit_unlock() {
  97. echo > $LOCKCTL/lockctl
  98. }
  99. trap atexit_unlock EXIT
  100. # Read "Ok" line when remote successfully locked
  101. read LOCK_OK
  102. artiq_flash -t kc705 -H rpi-1
  103. sleep 15
  104. # ping: socket: Operation not permitted
  105. #ping kc705-1 -c10 -w30
  106. export ARTIQ_ROOT=`python -c "import artiq; print(artiq.__path__[0])"`/examples/kc705_nist_clock
  107. export ARTIQ_LOW_LATENCY=1
  108. python -m unittest discover -v artiq.test.coredevice
  109. ${windowsRunner { testCommand = "set ARTIQ_ROOT=%cd%\\anaconda\\envs\\artiq-env\\Lib\\site-packages\\artiq\\examples\\kc705_nist_clock&&python -m unittest discover -v artiq.test.coredevice"; }}/bin/run.sh
  110. )
  111. mkdir $out
  112. cp ${generatedNix}/pkgs/artiq-version.nix $out/passed
  113. '';
  114. };
  115. }