about summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authoraszlig <aszlig@nix.build>2022-09-28 11:10:44 +0200
committeraszlig <aszlig@nix.build>2022-09-28 11:36:08 +0200
commite0685e81b3fdc43a272f0d5c3c0ab4ad5ed5a797 (patch)
tree127b6dbf5b16ef421a85330ed00ab072fa756bc6 /pkgs/build-support
parent770619fee4e91a74ba0a6ad83c176af2f1a5e9c6 (diff)
channel: Fix exposing meta.isHydraChannel
The isHydraChannel meta attribute is needed in order to tell Hydra that
the derivation in question should be a channel tarball. However in
Nixpkgs the meta attribute is not used, so checkMeta doesn't recognise
it as a valid attribute which leads to an evaluation error.

Recently[1] a commit got merged, which enables shallow type checking for
meta attributes by default. This led to an evaluation error for our
Hydra machine channels for the reason mentioned above.

I opted to work around that issue by adding meta.isHydraChannel after
mkDerivation, because adding isHydraChannel as a valid meta attribute to
Nixpkgs doesn't feel right to me since it's only relevant for Hydra and
its apparently deprecated[2] channel feature.

[1]: https://github.com/NixOS/nixpkgs/commit/6762de9a28e248f46bd0810e03c
[2]: https://github.com/NixOS/hydra/blob/53335323ae79ca1a42643f58e520b376898ce641/doc/manual/src/jobs.md#meta-fields

Signed-off-by: aszlig <aszlig@nix.build>
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/channel.nix50
1 files changed, 27 insertions, 23 deletions
diff --git a/pkgs/build-support/channel.nix b/pkgs/build-support/channel.nix
index a837177f..d5cc74e7 100644
--- a/pkgs/build-support/channel.nix
+++ b/pkgs/build-support/channel.nix
@@ -1,32 +1,36 @@
 { stdenv }:
 
-{ name, src, constituents ? [], meta ? {}, ... }@args:
+{ name, src, constituents ? [], ... }@args:
 
-stdenv.mkDerivation ({
-  inherit name src constituents;
-  preferLocalBuild = true;
-  _hydraAggregate = true;
+let
+  channel = stdenv.mkDerivation ({
+    inherit name src constituents;
+    preferLocalBuild = true;
+    _hydraAggregate = true;
 
-  phases = [ "unpackPhase" "patchPhase" "installPhase" ];
-  installPhase = ''
-    mkdir -p "$out/tarballs" "$out/nix-support"
+    phases = [ "unpackPhase" "patchPhase" "installPhase" ];
+    installPhase = ''
+      mkdir -p "$out/tarballs" "$out/nix-support"
 
-    tar cJf "$out/tarballs/nixexprs.tar.xz" \
-      --owner=0 --group=0 --mtime="1970-01-01 00:00:00 UTC" \
-      --transform='s!^\.!${name}!' .
+      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 "channel - $out/tarballs/nixexprs.tar.xz" \
+        > "$out/nix-support/hydra-build-products"
 
-    echo $constituents > "$out/nix-support/hydra-aggregate-constituents"
-    for i in $constituents; do
-      if [ -e "$i/nix-support/failed" ]; then
-        touch "$out/nix-support/failed"
-      fi
-    done
-  '';
-
-  meta = meta // {
+      echo $constituents > "$out/nix-support/hydra-aggregate-constituents"
+      for i in $constituents; do
+        if [ -e "$i/nix-support/failed" ]; then
+          touch "$out/nix-support/failed"
+        fi
+      done
+    '';
+  } // removeAttrs args [ "name" "channelName" "src" "constituents" ]);
+in channel // {
+  # XXX: We're adding meta.isHydraChannel outside of mkDerivation to avoid a
+  # typecheck on meta since it doesn't include isHydraChannel.
+  meta = (channel.meta or {}) // {
     isHydraChannel = true;
   };
-} // removeAttrs args [ "name" "channelName" "src" "constituents" "meta" ])
+}