2019-12-09 03:40:48 +01:00
|
|
|
# This file sets up the top-level package set by traversing the package tree
|
2021-04-12 21:49:36 +02:00
|
|
|
# (see //nix/readTree for details) and constructing a matching attribute set
|
2019-12-09 03:40:48 +01:00
|
|
|
# tree.
|
2019-06-29 15:12:24 +02:00
|
|
|
|
2021-12-27 23:46:27 +01:00
|
|
|
{ nixpkgsBisectPath ? null, nixpkgsConfig ? {}, ... }@args:
|
2019-12-13 22:32:35 +01:00
|
|
|
|
2019-06-29 15:12:24 +02:00
|
|
|
let
|
2021-04-12 21:49:36 +02:00
|
|
|
inherit (builtins)
|
|
|
|
filter
|
|
|
|
;
|
|
|
|
|
2021-11-23 12:24:58 +01:00
|
|
|
readTree = import ./nix/readTree {};
|
2021-08-26 19:00:03 +02:00
|
|
|
|
2021-11-13 18:25:02 +01:00
|
|
|
# Disallow access to //users from other depot parts.
|
2021-11-23 12:24:58 +01:00
|
|
|
usersFilter = readTree.restrictFolder {
|
2021-11-13 18:25:02 +01:00
|
|
|
folder = "users";
|
|
|
|
reason = ''
|
|
|
|
Code under //users is not considered stable or dependable in the
|
|
|
|
wider depot context. If a project under //users is required by
|
|
|
|
something else, please move it to a different depot path.
|
|
|
|
'';
|
|
|
|
|
|
|
|
exceptions = [
|
|
|
|
# whitby is allowed to access //users for several reasons:
|
|
|
|
#
|
|
|
|
# 1. User SSH keys are set in //users.
|
|
|
|
# 2. Some personal websites or demo projects are served from it.
|
|
|
|
[ "ops" "machines" "whitby" ]
|
|
|
|
|
|
|
|
# Due to evaluation order this also affects these targets.
|
|
|
|
# TODO(tazjin): Can this one be removed somehow?
|
|
|
|
[ "ops" "nixos" ]
|
|
|
|
[ "ops" "machines" "all-systems" ]
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2021-11-13 21:37:43 +01:00
|
|
|
# Disallow access to //corp from other depot parts.
|
2021-11-23 12:24:58 +01:00
|
|
|
corpFilter = readTree.restrictFolder {
|
2021-11-13 21:37:43 +01:00
|
|
|
folder = "corp";
|
|
|
|
reason = ''
|
|
|
|
Code under //corp may use incompatible licensing terms with
|
|
|
|
other depot parts and should not be used anywhere else.
|
|
|
|
'';
|
|
|
|
|
|
|
|
exceptions = [
|
|
|
|
# For the same reason as above, whitby is exempt to serve the
|
|
|
|
# corp website.
|
|
|
|
[ "ops" "machines" "whitby" ]
|
|
|
|
[ "ops" "nixos" ]
|
|
|
|
[ "ops" "machines" "all-systems" ]
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2021-11-23 12:24:58 +01:00
|
|
|
readDepot = depotArgs: readTree {
|
2021-11-13 18:25:02 +01:00
|
|
|
args = depotArgs;
|
|
|
|
path = ./.;
|
2021-11-13 21:37:43 +01:00
|
|
|
filter = parts: args: corpFilter parts (usersFilter parts args);
|
2021-11-13 18:25:02 +01:00
|
|
|
scopedArgs = {
|
|
|
|
__findFile = _: _: throw "Do not import from NIX_PATH in the depot!";
|
2021-08-26 19:00:03 +02:00
|
|
|
};
|
2021-11-13 18:25:02 +01:00
|
|
|
};
|
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);
|
|
|
|
|
2021-11-23 12:39:20 +01:00
|
|
|
in readTree.fix(self: (readDepot {
|
2021-04-12 21:49:36 +02:00
|
|
|
depot = self;
|
|
|
|
|
|
|
|
# Pass third_party as 'pkgs' (for compatibility with external
|
|
|
|
# imports for certain subdirectories)
|
|
|
|
pkgs = self.third_party.nixpkgs;
|
|
|
|
|
|
|
|
# Expose lib attribute to packages.
|
|
|
|
lib = self.third_party.nixpkgs.lib;
|
|
|
|
|
|
|
|
# Pass arguments passed to the entire depot through, for packages
|
|
|
|
# that would like to add functionality based on this.
|
|
|
|
#
|
|
|
|
# Note that it is intended for exceptional circumstance, such as
|
|
|
|
# debugging by bisecting nixpkgs.
|
|
|
|
externalArgs = args;
|
2021-09-08 17:16:11 +02:00
|
|
|
}) // {
|
2021-04-12 22:26:55 +02:00
|
|
|
# Make the path to the depot available for things that might need it
|
|
|
|
# (e.g. NixOS module inclusions)
|
2021-12-16 17:15:07 +01:00
|
|
|
path = self.third_party.nixpkgs.lib.cleanSourceWith {
|
|
|
|
name = "depot";
|
|
|
|
src = ./.;
|
|
|
|
filter = self.third_party.nixpkgs.lib.cleanSourceFilter;
|
|
|
|
};
|
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).
|
2021-11-23 13:00:27 +01:00
|
|
|
ci.targets = readTree.gather eligible (self // {
|
2020-08-27 02:05:45 +02:00
|
|
|
# remove the pipelines themselves from the set over which to
|
|
|
|
# generate pipelines because that also leads to infinite
|
|
|
|
# recursion.
|
|
|
|
ops = self.ops // { pipelines = null; };
|
2021-04-10 18:05:16 +02:00
|
|
|
|
|
|
|
# remove nixpkgs from the set, for obvious reasons.
|
|
|
|
third_party = self.third_party // { nixpkgs = null; };
|
2020-08-27 02:05:45 +02:00
|
|
|
});
|
2021-04-11 12:19:18 +02:00
|
|
|
|
|
|
|
# Derivation that gcroots all depot targets.
|
2022-01-01 16:37:58 +01:00
|
|
|
ci.gcroot = with self.third_party.nixpkgs; makeSetupHook {
|
2021-04-11 12:19:18 +02:00
|
|
|
name = "depot-gcroot";
|
2022-01-01 16:37:58 +01:00
|
|
|
deps = self.ci.targets;
|
|
|
|
} emptyFile;
|
2021-04-12 21:49:36 +02:00
|
|
|
})
|