about summary refs log tree commit diff
path: root/pkgs/top-level/release-lib.nix
diff options
context:
space:
mode:
authorSilvan Mosberger <contact@infinisil.com>2020-11-26 15:32:08 +0100
committerSilvan Mosberger <contact@infinisil.com>2020-11-26 15:32:08 +0100
commit86f4de6ee96986137e7287e4101110c23b302a8d (patch)
treedb8fd4753c2f67efc465ff82d39a99dbab8a10b3 /pkgs/top-level/release-lib.nix
parent9c6a75e379b8f2e11c1b00e49a8c392a083df9c6 (diff)
release-lib: Don't use tryEval for packagePlatforms
This use of tryEval causes hydra to fully ignore evaluation failures of
packages that occur while trying to evaluate the hydra platforms it should be
built on. This includes failures that occur during evaluation of:
- The `.type` attribute value
- The `.meta.hydraPlatforms` or `.meta.platforms` attribute value
  - The `.version` attribute, since this can determine whether
    `.meta.position` is set
- For non-derivations, `.recurseForDerivations` or `.recurseForRelease`

Here's a minimal `release.nix` file, showcasing how a `.version` failure
is ignored:

  let
    packages = pkgs: {
      success = pkgs.stdenv.mkDerivation {
        name = "success";
      };
      ignoredFailure = pkgs.stdenv.mkDerivation {
        pname = "ignored-failure";
        version = throw "version error";
      };
      caughtFailure = pkgs.stdenv.mkDerivation {
        name = "caught-failure";
        src = throw "src error";
      };
    };

    releaseLib = import <nixpkgs/pkgs/top-level/release-lib.nix> {
      packageSet = args: packages (import <nixpkgs> args);
      supportedSystems = [ "x86_64-linux" ];
    };
  in
  releaseLib.mapTestOn (releaseLib.packagePlatforms releaseLib.pkgs)

Evaluating this with `hydra-eval-jobs` before this change yields:

  $ hydra-eval-jobs release.nix -I nixpkgs=/path/to/nixpkgs
  warning: `--gc-roots-dir' not specified
  error: "error: --- ThrownError --- hydra-eval-jobs\nsrc error"
  {
    "caughtFailure.x86_64-linux": {
      "error": "error: --- ThrownError --- hydra-eval-jobs\nsrc error"
    },
    "success.x86_64-linux": {
      "description": "",
      "drvPath": "/nix/store/q1sw933xd9bxfx6rcp0kqksbprj1wmwj-success.drv",
      "homepage": "",
      "isChannel": false,
      "license": "",
      "maintainers": "",
      "maxSilent": 7200,
      "nixName": "success",
      "outputs": {
        "out": "/nix/store/7awrz6hss4jjxvgbwi4wlyikncmslb7a-success"
      },
      "schedulingPriority": 100,
      "system": "x86_64-linux",
      "timeout": 36000
    }
  }

Where you can see that there is no job for the `ignoredFailure`
derivation. Compare this to after this change:

  $ hydra-eval-jobs release.nix -I nixpkgs=/path/to/nixpkgs
  warning: `--gc-roots-dir' not specified
  error: "error: --- ThrownError --- hydra-eval-jobs\nsrc error"
  error: "error: --- ThrownError --- hydra-eval-jobs\nversion error"
  {
    "caughtFailure.x86_64-linux": {
      "error": "error: --- ThrownError --- hydra-eval-jobs\nsrc error"
    },
    "ignoredFailure": {
      "error": "error: --- ThrownError --- hydra-eval-jobs\nversion error"
    },
    "success.x86_64-linux": {
      "description": "",
      "drvPath": "/nix/store/q1sw933xd9bxfx6rcp0kqksbprj1wmwj-success.drv",
      "homepage": "",
      "isChannel": false,
      "license": "",
      "maintainers": "",
      "maxSilent": 7200,
      "nixName": "success",
      "outputs": {
        "out": "/nix/store/7awrz6hss4jjxvgbwi4wlyikncmslb7a-success"
      },
      "schedulingPriority": 100,
      "system": "x86_64-linux",
      "timeout": 36000
    }
  }

Notice how `ignoredFailure` is now part of the result.
Diffstat (limited to 'pkgs/top-level/release-lib.nix')
-rw-r--r--pkgs/top-level/release-lib.nix4
1 files changed, 1 insertions, 3 deletions
diff --git a/pkgs/top-level/release-lib.nix b/pkgs/top-level/release-lib.nix
index 1e33c7b0585b7..411093186a6ca 100644
--- a/pkgs/top-level/release-lib.nix
+++ b/pkgs/top-level/release-lib.nix
@@ -142,15 +142,13 @@ rec {
   /* Recursively map a (nested) set of derivations to an isomorphic
      set of meta.platforms values. */
   packagePlatforms = mapAttrs (name: value:
-    let res = builtins.tryEval (
       if isDerivation value then
         value.meta.hydraPlatforms
           or (value.meta.platforms or [ "x86_64-linux" ])
       else if value.recurseForDerivations or false || value.recurseForRelease or false then
         packagePlatforms value
       else
-        []);
-    in if res.success then res.value else []
+        []
     );