From 8194f74252e546f9fdf22d6a09a569e1a1d2731e Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 9 Feb 2019 18:06:36 +0800 Subject: [PATCH] nix: build board conda package --- nix/conda-board.nix | 60 +++++++++++++++++++++++++++++++++++++++++++++ nix/conda-build.nix | 9 ++++--- nix/release.nix | 13 ++++++++-- 3 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 nix/conda-board.nix diff --git a/nix/conda-board.nix b/nix/conda-board.nix new file mode 100644 index 000000000..d8152bfc3 --- /dev/null +++ b/nix/conda-board.nix @@ -0,0 +1,60 @@ +{ pkgs ? import {}}: +{ artiqSrc, boardBinaries }: + +with pkgs; + +let + target = "kasli"; + variant = "tester"; + + fakeCondaSource = runCommand "fake-conda-source-${target}-${variant}" { } + '' + cp --no-preserve=mode,ownership -R ${artiqSrc} $out + mkdir $out/fake-conda; + + cat << EOF > $out/fake-conda/meta.yaml + package: + name: artiq-${target}-${variant} + version: {{ environ["GIT_DESCRIBE_TAG"] }} + + source: + git_url: .. + + build: + noarch: python + number: {{ environ["GIT_DESCRIBE_NUMBER"] }} + string: {{ environ["GIT_DESCRIBE_NUMBER"] }}+git{{ environ["GIT_FULL_HASH"][:8] }} + ignore_prefix_files: True + + outputs: + - name: artiq-${target}-${variant} + noarch: python + files: + - site-packages + requirements: + run: + - artiq {{ "{tag} {number}+git{hash}".format(tag=environ["GIT_DESCRIBE_TAG"], number=environ["GIT_DESCRIBE_NUMBER"], hash=environ["GIT_FULL_HASH"][:8]) }} + ignore_prefix_files: True + + about: + home: https://m-labs.hk/artiq + license: LGPL + summary: 'Bitstream, BIOS and firmware for the ${target}-${variant} board variant' + EOF + + cat << EOF > $out/fake-conda/build.sh + #!/bin/bash + set -e + SOC_PREFIX=\$PREFIX/site-packages/artiq/binaries/${target}-${variant} + mkdir -p \$SOC_PREFIX + cp ${boardBinaries}/* \$SOC_PREFIX + EOF + chmod 755 $out/fake-conda/build.sh + ''; + conda-board = import ./conda-build.nix { inherit pkgs; } { + name = "conda-board-${target}-${variant}"; + src = fakeCondaSource; + recipe = "fake-conda"; + }; +in + conda-board diff --git a/nix/conda-build.nix b/nix/conda-build.nix index 6780ff3c7..22dd9eb6d 100644 --- a/nix/conda-build.nix +++ b/nix/conda-build.nix @@ -1,4 +1,8 @@ +# We need to pass the whole source to conda for the git variables to work. +# recipe must be a string pointing to a path within the source. + { pkgs ? import {}}: +{ name, src, recipe }: with pkgs; @@ -37,8 +41,7 @@ let }; in stdenv.mkDerivation { - name = "conda-artiq"; - src = ../.; + inherit name src; buildInputs = [ condaBuilderEnv ]; buildCommand = '' @@ -54,7 +57,7 @@ in stdenv.mkDerivation { - PYTHON EOF mkdir $out - ${condaBuilderEnv}/bin/conda-builder-env -c "PYTHON=python conda build --clobber-file clobber.yaml --no-anaconda-upload --no-test --output-folder $out $src/conda/artiq" + ${condaBuilderEnv}/bin/conda-builder-env -c "PYTHON=python conda build --clobber-file clobber.yaml --no-anaconda-upload --no-test --output-folder $out $src/${recipe}" mkdir -p $out/nix-support echo file conda $out/noarch/*.tar.bz2 >> $out/nix-support/hydra-build-products diff --git a/nix/release.nix b/nix/release.nix index cd2388b69..ac927d991 100644 --- a/nix/release.nix +++ b/nix/release.nix @@ -1,9 +1,18 @@ { pkgs ? import {}}: let artiqPkgs = import ./default.nix { inherit pkgs; }; + artiq-board = import ./artiq-board.nix { inherit pkgs; }; jobs = rec { - conda-artiq = import ./conda-build.nix { inherit pkgs; }; - artiq-board = import ./artiq-board.nix { inherit pkgs; }; + conda-artiq = import ./conda-build.nix { inherit pkgs; } { + name = "conda-artiq"; + src = ../.; + recipe = "conda/artiq"; + }; + inherit artiq-board; + conda-artiq-board = import ./conda-board.nix { inherit pkgs; } { + artiqSrc = ../.; + boardBinaries = artiq-board; + }; } // artiqPkgs; in jobs