From 5d176845bfd4e31ca3b0de919d3e75b14917059a Mon Sep 17 00:00:00 2001 From: Tobias Happ Date: Sun, 22 Sep 2019 09:22:47 +0200 Subject: [PATCH] Filter derivation with preferLocalBuild --- ci.nix | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/ci.nix b/ci.nix index ef1aab0..6a934c0 100644 --- a/ci.nix +++ b/ci.nix @@ -3,10 +3,30 @@ with import { }; +with lib; + let src = import ./src; + + attrs = genAttrs + [ "aarch64" "i686" ] + (arch: (src { inherit arch; }) // { recurseForDerivations = true; }); + + isCacheable = p: !(p.preferLocalBuild or false); + shouldRecurseForDerivations = p: isAttrs p && p.recurseForDerivations or false; + + flattenPkgs = s: + let + f = p: + if shouldRecurseForDerivations p then flattenPkgs p + else if isDerivation p then [ p ] + else [ ]; + in + concatMap f (attrValues s); + + cachePkgs = filter isCacheable (flattenPkgs attrs); + + outputsOf = p: map (o: p.${o}) p.outputs; in -lib.genAttrs - [ "aarch64" "i686" ] - (arch: (src { inherit arch; }) // { recurseForDerivations = true; }) +concatMap outputsOf cachePkgs