ATproto Nix User Repo
1# This file provides all the buildable and cacheable packages and
2# package outputs in your package set. These are what gets built by CI,
3# so if you correctly mark packages as
4#
5# - broken (using `meta.broken`),
6# - unfree (using `meta.license.free`), and
7# - locally built (using `preferLocalBuild`)
8#
9# then your CI will be able to build and cache only those packages for
10# which this is possible.
11
12{ pkgs ? import <nixpkgs> { } }:
13
14with builtins;
15let
16 isReserved = n: n == "lib" || n == "overlays" || n == "modules";
17 isDerivation = p: isAttrs p && p ? type && p.type == "derivation";
18 isBuildable = p: let
19 licenseFromMeta = p.meta.license or [];
20 licenseList = if builtins.isList licenseFromMeta then licenseFromMeta else [licenseFromMeta];
21 in !(p.meta.broken or false) && builtins.all (license: license.free or true) licenseList;
22 isCacheable = p: !(p.preferLocalBuild or false);
23 shouldRecurseForDerivations = p: isAttrs p && p.recurseForDerivations or false;
24
25 nameValuePair = n: v: { name = n; value = v; };
26
27 concatMap = builtins.concatMap or (f: xs: concatLists (map f xs));
28
29 flattenPkgs = s:
30 let
31 f = p:
32 if shouldRecurseForDerivations p then flattenPkgs p
33 else if isDerivation p then [ p ]
34 else [ ];
35 in
36 concatMap f (attrValues s);
37
38 outputsOf = p: map (o: p.${o}) p.outputs;
39
40 nurAttrs = import ./default.nix { inherit pkgs; };
41
42 nurPkgs =
43 flattenPkgs
44 (listToAttrs
45 (map (n: nameValuePair n nurAttrs.${n})
46 (filter (n: !isReserved n)
47 (attrNames nurAttrs))));
48
49in
50rec {
51 buildPkgs = filter isBuildable nurPkgs;
52 cachePkgs = filter isCacheable buildPkgs;
53
54 buildOutputs = concatMap outputsOf buildPkgs;
55 cacheOutputs = concatMap outputsOf cachePkgs;
56}