From e0685e81b3fdc43a272f0d5c3c0ab4ad5ed5a797 Mon Sep 17 00:00:00 2001 From: aszlig Date: Wed, 28 Sep 2022 11:10:44 +0200 Subject: 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 --- pkgs/build-support/channel.nix | 50 +++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 23 deletions(-) (limited to 'pkgs') 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" ]) +} -- cgit 1.4.1