summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorVladimír Čunát <vcunat@gmail.com>2017-07-03 09:48:58 +0200
committerVladimír Čunát <vcunat@gmail.com>2017-07-03 09:48:58 +0200
commitd1a89ae9d702a4b91b6d661af256552e330bb995 (patch)
treeb34b95d1204ad7b4423b10cf1572d11b3293319f /pkgs/build-support
parent343ad1697d6967b7aa949752fd5c4471f691b4eb (diff)
parent0b1c8793fc20944b68562d9a73a5ce391f1603e0 (diff)
downloadnixlib-d1a89ae9d702a4b91b6d661af256552e330bb995.tar
nixlib-d1a89ae9d702a4b91b6d661af256552e330bb995.tar.gz
nixlib-d1a89ae9d702a4b91b6d661af256552e330bb995.tar.bz2
nixlib-d1a89ae9d702a4b91b6d661af256552e330bb995.tar.lz
nixlib-d1a89ae9d702a4b91b6d661af256552e330bb995.tar.xz
nixlib-d1a89ae9d702a4b91b6d661af256552e330bb995.tar.zst
nixlib-d1a89ae9d702a4b91b6d661af256552e330bb995.zip
Merge branch 'master' into staging
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/release/default.nix52
1 files changed, 52 insertions, 0 deletions
diff --git a/pkgs/build-support/release/default.nix b/pkgs/build-support/release/default.nix
index 82919cf819fb..5e3eb751b81e 100644
--- a/pkgs/build-support/release/default.nix
+++ b/pkgs/build-support/release/default.nix
@@ -73,4 +73,56 @@ rec {
         done
       '';
 
+  /* Create a channel job which success depends on the success of all of
+     its contituents. Channel jobs are a special type of jobs that are
+     listed in the channel tab of Hydra and that can be suscribed.
+     A tarball of the src attribute is distributed via the channel.
+     
+     - constituents: a list of derivations on which the channel success depends.
+     - name: the channel name that will be used in the hydra interface.
+     - src: should point to the root folder of the nix-expressions used by the
+            channel, typically a folder containing a `default.nix`.
+
+       channel {
+         constituents = [ foo bar baz ];
+         name = "my-channel";
+         src = ./.;
+       };
+     
+  */
+  channel =
+    { name, src, constituents ? [], meta ? {}, isNixOS ? true, ... }@args:
+    stdenv.mkDerivation ({
+      preferLocalBuild = true;
+      _hydraAggregate = true;
+
+      phases = [ "unpackPhase" "patchPhase" "installPhase" ];
+
+      patchPhase = stdenv.lib.optionalString isNixOS ''
+        touch .update-on-nixos-rebuild
+      '';
+
+      installPhase = ''
+        mkdir -p $out/{tarballs,nix-support}
+
+        tar cJf "$out/tarballs/nixexprs.tar.xz" \
+          --owner=0 --group=0 --mtime="1970-01-01 00:00:00 UTC" \
+          --transform='s!^\.!${name}!' .
+
+        echo "channel - $out/tarballs/nixexprs.tar.xz" > "$out/nix-support/hydra-build-products"
+        echo $constituents > "$out/nix-support/hydra-aggregate-constituents"
+
+        # Propagate build failures.
+        for i in $constituents; do
+          if [ -e "$i/nix-support/failed" ]; then
+            touch "$out/nix-support/failed"
+          fi
+        done
+      '';
+
+      meta = meta // {
+        isHydraChannel = true;
+      };
+    } // removeAttrs args [ "meta" ]);
+
 }