From 738cf42639c6e45b097bb1fd29508e95a36eb5c0 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 20 Mar 2015 18:16:43 +0100 Subject: release-lib: Simplify --- pkgs/top-level/release-lib.nix | 78 ++++++++++++---------------------------- pkgs/top-level/release-small.nix | 2 +- pkgs/top-level/release.nix | 4 +-- 3 files changed, 26 insertions(+), 58 deletions(-) (limited to 'pkgs') diff --git a/pkgs/top-level/release-lib.nix b/pkgs/top-level/release-lib.nix index a5a74de66907..0d608ed44ac5 100644 --- a/pkgs/top-level/release-lib.nix +++ b/pkgs/top-level/release-lib.nix @@ -38,18 +38,13 @@ rec { crossMaintainers = [ maintainers.viric ]; - toJob = x: if isAttrs x then x else - { type = "job"; systems = x; }; - - /* Build a package on the given set of platforms. The function `f' is called for each supported platform with Nixpkgs for that platform as an argument . We return an attribute set containing a derivation for each supported platform, i.e. ‘{ x86_64-linux = f pkgs_x86_64_linux; i686-linux = f pkgs_i686_linux; ... }’. */ testOn = systems: f: genAttrs - (filter (x: elem x supportedSystems) systems) - (system: f (pkgsFor system)); + (filter (x: elem x supportedSystems) systems) (system: f (pkgsFor system)); /* Similar to the testOn function, but with an additional @@ -61,60 +56,33 @@ rec { else {}; - /* Map an attribute of the form `foo = [platforms...]' to `testOn - [platforms...] (pkgs: pkgs.foo)'. */ - mapTestOn = mapAttrsRecursiveCond - (as: as.type or "" != "job") - (path: value: - let - job = toJob value; - getPkg = pkgs: getAttrFromPath path pkgs; - in testOn job.systems getPkg); + /* Given a nested set where the leaf nodes are lists of platforms, + map each leaf node to `testOn [platforms...] (pkgs: + pkgs.)'. */ + mapTestOn = mapAttrsRecursive + (path: systems: testOn systems (pkgs: getAttrFromPath path pkgs)); /* Similar to the testOn function, but with an additional 'crossSystem' * parameter for allPackages, defining the target platform for cross builds, * and triggering the build of the host derivation (cross built - crossDrv). */ - mapTestOnCross = crossSystem: mapAttrsRecursiveCond - (as: as.type or "" != "job") - (path: value: - let - job = toJob value; - getPkg = pkgs: addMetaAttrs { maintainers = crossMaintainers; } - (getAttrFromPath path pkgs); - in testOnCross crossSystem job.systems getPkg); - - - /* Find all packages that have a meta.platforms field listing the - supported platforms. */ - packagesWithMetaPlatform = attrSet: - let pairs = concatMap - (x: - let pair = builtins.tryEval - (let - attrVal = attrSet.${x}; - in - { val = processPackage attrVal; - attrVal = attrVal; - attrValIsAttrs = isAttrs attrVal; - }); - success = (builtins.tryEval pair.value.attrVal).success; - in - optional (success && pair.value.attrValIsAttrs && pair.value.val != []) - { name = x; value = pair.value.val; }) - (attrNames attrSet); - in - listToAttrs pairs; - - - # May fail as much as it wishes, we will catch the error. - processPackage = attrSet: - if attrSet.recurseForDerivations or false || attrSet.recurseForRelease or false then - packagesWithMetaPlatform attrSet - else if attrSet.meta.broken or false then - [] - else - attrSet.meta.hydraPlatforms or (attrSet.meta.platforms or []); + mapTestOnCross = crossSystem: mapAttrsRecursive + (path: systems: testOnCross crossSystem systems + (pkgs: addMetaAttrs { maintainers = crossMaintainers; } (getAttrFromPath path pkgs))); + + + /* 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 []) + else if value.recurseForDerivations or false || value.recurseForRelease or false then + packagePlatforms value + else + []); + in if res.success then res.value else [] + ); /* Common platform groups on which to test packages. */ diff --git a/pkgs/top-level/release-small.nix b/pkgs/top-level/release-small.nix index 85ee84d8d6d6..8f2c548bebcf 100644 --- a/pkgs/top-level/release-small.nix +++ b/pkgs/top-level/release-small.nix @@ -153,7 +153,7 @@ with import ./release-lib.nix { inherit supportedSystems; }; sqlite = allBut cygwin; squid = linux; ssmtp = linux; - stdenv = prio 175 all; + stdenv = all; strace = linux; su = linux; sudo = linux; diff --git a/pkgs/top-level/release.nix b/pkgs/top-level/release.nix index d2f9daafa47d..4d5237504cac 100644 --- a/pkgs/top-level/release.nix +++ b/pkgs/top-level/release.nix @@ -47,7 +47,7 @@ let ]; }; - } // (mapTestOn ((packagesWithMetaPlatform pkgs) // rec { + } // (mapTestOn ((packagePlatforms pkgs) // rec { abcde = linux; apacheHttpd = linux; @@ -270,7 +270,7 @@ let gnome_vfs = linux; }; - haskell-ng.compiler = packagesWithMetaPlatform pkgs.haskell-ng.compiler; + haskell-ng.compiler = packagePlatforms pkgs.haskell-ng.compiler; strategoPackages = { sdf = linux; -- cgit v1.2.3