-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Imported from https://github.com/tomodachi94/tomopkgs/blob/2c9db9bdb10a67a3463d2eb296323a7ad406ee2e/ci.nix
- Loading branch information
1 parent
70c6881
commit 5cb1a78
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# This file provides all the buildable and cacheable packages and | ||
# package outputs in your package set. These are what gets built by CI, | ||
# so if you correctly mark packages as | ||
# | ||
# - broken (using `meta.broken`), | ||
# - unfree (using `meta.license.free`), and | ||
# - locally built (using `preferLocalBuild`) | ||
# | ||
# then your CI will be able to build and cache only those packages for | ||
# which this is possible. | ||
|
||
{ pkgs ? import <nixpkgs> { } }: | ||
|
||
with builtins; | ||
let | ||
isReserved = n: n == "lib" || n == "overlays" || n == "modules"; | ||
isDerivation = p: isAttrs p && p ? type && p.type == "derivation"; | ||
isBuildable = p: !(p.meta.broken or false) && p.meta.license.free or true; | ||
isCacheable = p: !(p.preferLocalBuild or false); | ||
shouldRecurseForDerivations = p: isAttrs p && p.recurseForDerivations or false; | ||
|
||
nameValuePair = n: v: { name = n; value = v; }; | ||
|
||
concatMap = builtins.concatMap or (f: xs: concatLists (map f xs)); | ||
|
||
flattenPkgs = s: | ||
let | ||
f = p: | ||
if shouldRecurseForDerivations p then flattenPkgs p | ||
else if isDerivation p then [ p ] | ||
else [ ]; | ||
in | ||
concatMap f (attrValues s); | ||
|
||
outputsOf = p: map (o: p.${o}) p.outputs; | ||
|
||
nurAttrs = import ./default.nix { inherit pkgs; }; | ||
|
||
nurPkgs = | ||
flattenPkgs | ||
(listToAttrs | ||
(map (n: nameValuePair n nurAttrs.${n}) | ||
(filter (n: !isReserved n) | ||
(attrNames nurAttrs)))); | ||
|
||
in | ||
rec { | ||
buildPkgs = filter isBuildable nurPkgs; | ||
cachePkgs = filter isCacheable buildPkgs; | ||
|
||
buildOutputs = concatMap outputsOf buildPkgs; | ||
cacheOutputs = concatMap outputsOf cachePkgs; | ||
} |