From c1dc737eef1c8ffccd6d0b1d962da770112b40d0 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 16 Feb 2019 00:24:20 +0800 Subject: [PATCH] create sinara-systems channel --- sinara-systems.nix | 61 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 18 deletions(-) diff --git a/sinara-systems.nix b/sinara-systems.nix index 2472744..f006bac 100644 --- a/sinara-systems.nix +++ b/sinara-systems.nix @@ -1,27 +1,52 @@ { pkgs ? import {}}: let - artiq-board = import { inherit pkgs; }; - conda-artiq-board = import { inherit pkgs; }; + sinaraSystemsSrc = ; - target = "kasli"; + generatedNix = pkgs.runCommand "generated-nix" { buildInputs = [ pkgs.nix pkgs.git ]; } + '' + mkdir $out + REV=`git --git-dir ${sinaraSystemsSrc}/.git rev-parse HEAD` + HASH=`nix-hash --type sha256 --base32 ${sinaraSystemsSrc}` + cat > $out/default.nix << EOF + { pkgs ? import {}}: - variants = ["berkeley" "mitll2" "mitll" "nudt" "sysu" "tsinghua2" "tsinghua" "unsw" "ustc" "wipm"]; - sinaraSystemsPkgs = pkgs.lib.lists.foldr (variant: start: let - json = + "/${variant}.json"; - boardBinaries = artiq-board { - inherit target variant; - buildCommand = "python -m artiq.gateware.targets.kasli_generic ${json}"; + target = "kasli"; + variants = ["berkeley" "mitll2" "mitll" "nudt" "sysu" "tsinghua2" "tsinghua" "unsw" "ustc" "wipm"]; + + artiq-board = import { inherit pkgs; }; + conda-artiq-board = import { inherit pkgs; }; + src = pkgs.fetchgit { + url = "git://github.com/m-labs/sinara-systems.git"; + rev = "$REV"; + sha256 = "$HASH"; + leaveDotGit = true; }; in - start // { - "artiq-board-${target}-${variant}" = boardBinaries; - "conda-artiq-board-${target}-${variant}" = conda-artiq-board { - boardBinaries = boardBinaries; - inherit target variant; - }; - }) {} variants; - jobs = builtins.mapAttrs (key: value: pkgs.lib.hydraJob value) sinaraSystemsPkgs; + pkgs.lib.lists.foldr (variant: start: + let + json = src + "/\''${variant}.json"; + boardBinaries = artiq-board { + inherit target variant; + buildCommand = "python -m artiq.gateware.targets.kasli_generic \''${json}"; + }; + in + start // { + "artiq-board-\''${target}-\''${variant}" = boardBinaries; + "conda-artiq-board-\''${target}-\''${variant}" = conda-artiq-board { + boardBinaries = boardBinaries; + inherit target variant; + }; + }) {} variants + EOF + ''; + jobs = builtins.mapAttrs (key: value: pkgs.lib.hydraJob value) (import generatedNix { inherit pkgs; }); in - jobs + jobs // { + channel = pkgs.releaseTools.channel { + name = "sinara-systems"; + src = generatedNix; + constituents = builtins.attrValues jobs; + }; + }