2019-12-09 03:40:48 +01:00
|
|
|
# This file sets up the top-level package set by traversing the package tree
|
|
|
|
# (see read-tree.nix for details) and constructing a matching attribute set
|
|
|
|
# tree.
|
2019-08-15 17:07:28 +02:00
|
|
|
#
|
|
|
|
# This makes packages accessible via the Nixery instance that is configured to
|
|
|
|
# use this repository as its nixpkgs source.
|
2019-06-29 15:12:24 +02:00
|
|
|
|
2019-12-13 22:32:35 +01:00
|
|
|
{ ... }@args:
|
|
|
|
|
2019-08-19 03:28:03 +02:00
|
|
|
with builtins;
|
|
|
|
|
2019-06-29 15:12:24 +02:00
|
|
|
let
|
2019-12-09 03:40:48 +01:00
|
|
|
# This definition of fix is identical to <nixpkgs>.lib.fix, but the global
|
|
|
|
# package set is not available here.
|
|
|
|
fix = f: let x = f x; in x;
|
2019-08-25 18:54:17 +02:00
|
|
|
|
2019-12-09 03:40:48 +01:00
|
|
|
# Global configuration that all packages are called with.
|
2020-02-21 13:45:43 +01:00
|
|
|
config = depot: {
|
|
|
|
inherit depot;
|
|
|
|
|
2021-02-06 18:41:14 +01:00
|
|
|
# Expose lib attribute to packages.
|
|
|
|
inherit (depot) lib;
|
2020-06-24 04:08:53 +02:00
|
|
|
|
2020-02-21 13:45:43 +01:00
|
|
|
# Pass third_party as 'pkgs' (for compatibility with external
|
|
|
|
# imports for certain subdirectories)
|
|
|
|
pkgs = depot.third_party;
|
2019-12-09 03:40:48 +01:00
|
|
|
};
|
|
|
|
|
2019-12-21 06:42:32 +01:00
|
|
|
readTree' = import ./nix/readTree {};
|
2019-12-09 03:40:48 +01:00
|
|
|
|
|
|
|
localPkgs = readTree: {
|
2019-12-21 02:07:29 +01:00
|
|
|
fun = readTree ./fun;
|
2020-06-08 00:50:47 +02:00
|
|
|
lisp = readTree ./lisp;
|
|
|
|
net = readTree ./net;
|
2019-12-21 02:07:29 +01:00
|
|
|
nix = readTree ./nix;
|
|
|
|
ops = readTree ./ops;
|
|
|
|
third_party = readTree ./third_party;
|
|
|
|
tools = readTree ./tools;
|
2020-06-13 22:52:20 +02:00
|
|
|
users = readTree ./users;
|
2019-12-21 02:07:29 +01:00
|
|
|
web = readTree ./web;
|
2019-12-09 03:40:48 +01:00
|
|
|
};
|
2020-08-27 01:11:11 +02:00
|
|
|
|
|
|
|
# To determine build targets, we walk through the depot tree and
|
|
|
|
# fetch attributes that were imported by readTree and are buildable.
|
|
|
|
#
|
|
|
|
# Any build target that contains `meta.ci = false` will be skipped.
|
|
|
|
|
|
|
|
# Is this tree node eligible for build inclusion?
|
|
|
|
eligible = node: (node ? outPath) && (node.meta.ci or true);
|
|
|
|
|
|
|
|
# Walk the tree starting with 'node', recursively extending the list
|
|
|
|
# of build targets with anything that looks buildable.
|
2020-08-31 02:36:03 +02:00
|
|
|
#
|
|
|
|
# Any tree node can specify logical targets by exporting a
|
|
|
|
# 'meta.targets' attribute containing a list of keys in itself. This
|
|
|
|
# enables target specifications that do not exist on disk directly.
|
2020-08-27 01:11:11 +02:00
|
|
|
gather = node:
|
|
|
|
if node ? __readTree then
|
2020-08-31 02:36:03 +02:00
|
|
|
# Include the node itself if it is eligible.
|
|
|
|
(if eligible node then [ node ] else [])
|
|
|
|
# Include eligible children of the node
|
|
|
|
++ concatMap gather (attrValues node)
|
|
|
|
# Include specified sub-targets of the node
|
|
|
|
++ filter eligible (map
|
|
|
|
(k: (node."${k}" or {}) // {
|
|
|
|
# Keep the same tree location, but explicitly mark this
|
|
|
|
# node as a subtarget.
|
|
|
|
__readTree = node.__readTree;
|
|
|
|
__subtarget = k;
|
|
|
|
})
|
|
|
|
(node.meta.targets or []))
|
2020-08-27 01:11:11 +02:00
|
|
|
else [];
|
2019-12-09 03:40:48 +01:00
|
|
|
in fix(self: {
|
2021-03-23 22:46:00 +01:00
|
|
|
__readTree = [];
|
2019-12-09 03:40:48 +01:00
|
|
|
config = config self;
|
|
|
|
|
|
|
|
# Elevate 'lib' from nixpkgs
|
2019-12-09 03:52:11 +01:00
|
|
|
lib = import (self.third_party.nixpkgsSrc + "/lib");
|
2019-12-16 14:32:10 +01:00
|
|
|
|
|
|
|
# Expose readTree for downstream repo consumers.
|
|
|
|
readTree = {
|
|
|
|
__functor = x: (readTree' x.config);
|
|
|
|
config = self.config;
|
|
|
|
};
|
2020-06-13 22:39:48 +02:00
|
|
|
|
|
|
|
# Make the path to the depot available for things that might need it
|
|
|
|
# (e.g. NixOS module inclusions)
|
|
|
|
depotPath = ./.;
|
2020-06-24 04:08:53 +02:00
|
|
|
|
2020-08-27 01:11:11 +02:00
|
|
|
# List of all buildable targets, for CI purposes.
|
|
|
|
#
|
2020-08-27 02:05:45 +02:00
|
|
|
# Note: To prevent infinite recursion, this *must* be a nested
|
|
|
|
# attribute set (which does not have a __readTree attribute).
|
|
|
|
ci.targets = gather (self // {
|
|
|
|
# remove the pipelines themselves from the set over which to
|
|
|
|
# generate pipelines because that also leads to infinite
|
|
|
|
# recursion.
|
|
|
|
ops = self.ops // { pipelines = null; };
|
|
|
|
});
|
2019-12-09 03:40:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# Add local packages as structured by readTree
|
2020-06-24 04:08:53 +02:00
|
|
|
// (localPkgs (readTree' self.config))
|
2019-12-19 16:35:03 +01:00
|
|
|
)
|