From 23c61f3d9597c303ba7233b3e667cf44f59af61d Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 14 Feb 2019 19:31:46 +0800 Subject: [PATCH] back to using fetchgit for artiq-src --- artiq/artiq-board.nix | 2 +- artiq/pkgs/artiq.nix | 4 ++-- main.nix | 19 +++++++++++++++---- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/artiq/artiq-board.nix b/artiq/artiq-board.nix index 1bf228e..c535154 100644 --- a/artiq/artiq-board.nix +++ b/artiq/artiq-board.nix @@ -9,7 +9,7 @@ let fetchcargo = import ./fetchcargo.nix { inherit (pkgs) stdenv cacert git cargo cargo-vendor; }; - artiqSrc = import ./pkgs/artiq-src.nix; + artiqSrc = import ./pkgs/artiq-src.nix { fetchgit = pkgs.fetchgit; }; cargoDeps = fetchcargo rec { name = "artiq-firmware-cargo-deps"; src = "${artiqSrc}/artiq/firmware"; diff --git a/artiq/pkgs/artiq.nix b/artiq/pkgs/artiq.nix index ac63e8a..419d9d1 100644 --- a/artiq/pkgs/artiq.nix +++ b/artiq/pkgs/artiq.nix @@ -1,4 +1,4 @@ -{ stdenv, git, fetchFromGitHub, python3Packages, qt5Full, binutils-or1k, llvm-or1k, llvmlite, python3 }: +{ stdenv, git, fetchFromGitHub, fetchgit, python3Packages, qt5Full, binutils-or1k, llvm-or1k, llvmlite, python3 }: let @@ -65,7 +65,7 @@ in python3Packages.buildPythonPackage rec { name = "artiq"; - src = import ./artiq-src.nix; + src = import ./artiq-src.nix { inherit fetchgit; }; buildInputs = [ git ]; propagatedBuildInputs = with python3Packages; [ binutils-or1k llvm-or1k llvmlite levenshtein pyqtgraph-qt5 aiohttp pygit2 pythonparser numpy dateutil quamash scipy prettytable pyserial asyncserial h5py cython regex qt5Full pyqt5 ]; checkPhase = "python -m unittest discover -v artiq.test"; diff --git a/main.nix b/main.nix index 1eaff86..287a912 100644 --- a/main.nix +++ b/main.nix @@ -1,10 +1,21 @@ { pkgs ? import {}}: let artiqSrc = builtins.toString ; - generatedNix = pkgs.runCommand "generated-nix" { } + generatedNix = pkgs.runCommand "generated-nix" { buildInputs = [ pkgs.nix pkgs.git ]; } '' cp --no-preserve=mode,ownership -R ${./artiq} $out - echo ${artiqSrc} > $out/pkgs/artiq-src.nix + 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"; + deepClone = true; + leaveDotGit = true; + } + EOF ''; artiqPkgs = import "${generatedNix}/default.nix" { inherit pkgs; }; @@ -22,7 +33,7 @@ let start // { "artiq-board-${board.target}-${board.variant}" = boardBinaries; "conda-artiq-board-${board.target}-${board.variant}" = import "${generatedNix}/conda-board.nix" { inherit pkgs; } { - artiqSrc = import "${generatedNix}/pkgs/artiq-src.nix"; + artiqSrc = import "${generatedNix}/pkgs/artiq-src.nix" { fetchgit = pkgs.fetchgit; }; boardBinaries = boardBinaries; target = board.target; variant = board.variant; @@ -32,7 +43,7 @@ let jobs = { conda-artiq = import "${generatedNix}/conda-build.nix" { inherit pkgs; } { name = "conda-artiq"; - src = import "${generatedNix}/pkgs/artiq-src.nix"; + src = import "${generatedNix}/pkgs/artiq-src.nix" { fetchgit = pkgs.fetchgit; }; recipe = "conda/artiq"; }; } // boardJobs // artiqPkgs;