about summary refs log tree commit diff
path: root/default.nix
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2021-04-12T19·49+0200
committertazjin <mail@tazj.in>2021-04-12T21·55+0000
commita5591359702b62e4edd7fdbbd135475037aa6727 (patch)
treef4728bf352866c2e3555011b7029c7dfe65b00c4 /default.nix
parentf59ab9aba506c1ed149f7093f5543ef021567ebc (diff)
refactor(readTree): Initialise repo roots without recursing r/2496
Plumbs an additional internal argument through readTree that indicates
whether the top-level of a tree is being read, and avoids recursing
into itself in that case. This changes the externally visible
behaviour of readTree (it is now expected to be called a level higher
than previously).

This allows us to reduce the amount of boilerplate needed to bootstrap
the TVL repository (by not having to specify the individual folders
that need to be read).

For reasons related to an infinite recursion we could not (be bothered
to) debug, the top-level `config` key (which held the attribute set
passed on by readTree) has been removed. This is not needed, as it is
already passed on by readTree ...

Co-Authored-By: Florian Klink <flokli@flokli.de>
Change-Id: Id6e39b57b2f5b3473c4b695a72dd1d01fcfb7a66
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2961
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Reviewed-by: grfn <grfn@gws.fyi>
Diffstat (limited to 'default.nix')
-rw-r--r--default.nix81
1 files changed, 28 insertions, 53 deletions
diff --git a/default.nix b/default.nix
index c5db0d1e32..a73e46877a 100644
--- a/default.nix
+++ b/default.nix
@@ -1,53 +1,21 @@
 # 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
+# (see //nix/readTree for details) and constructing a matching attribute set
 # tree.
-#
-# This makes packages accessible via the Nixery instance that is configured to
-# use this repository as its nixpkgs source.
 
 { nixpkgsBisectPath ? null, ... }@args:
 
-with builtins;
-
 let
+  inherit (builtins)
+    attrValues
+    concatMap
+    filter
+    ;
+
   # 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;
-
-  # Global configuration that all packages are called with.
-  config = depot: {
-    inherit depot;
-
-    # Expose lib attribute to packages.
-    inherit (depot.third_party.nixpkgs) lib;
-
-    # Pass third_party as 'pkgs' (for compatibility with external
-    # imports for certain subdirectories)
-    pkgs = depot.third_party.nixpkgs;
-
-    # 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;
-  };
-
   readTree' = import ./nix/readTree {};
 
-  localPkgs = readTree: {
-    fun           = readTree ./fun;
-    lisp          = readTree ./lisp;
-    net           = readTree ./net;
-    nix           = readTree ./nix;
-    ops           = readTree ./ops;
-    third_party   = readTree ./third_party;
-    tools         = readTree ./tools;
-    tvix          = readTree ./tvix;
-    users         = readTree ./users;
-    web           = readTree ./web;
-  };
-
   # To determine build targets, we walk through the depot tree and
   # fetch attributes that were imported by readTree and are buildable.
   #
@@ -78,19 +46,30 @@ let
            })
            (node.meta.targets or []))
     else [];
-in fix(self: {
-  __readTree = [];
-  config = config self;
-
-  # Expose readTree for downstream repo consumers.
-  readTree = {
-    __functor = x: (readTree' x.config);
-    config = self.config;
-  };
 
   # Make the path to the depot available for things that might need it
   # (e.g. NixOS module inclusions)
   depotPath = ./.;
+in fix(self: (readTree' {
+  # TODO(tazjin): Settle on one way of using depotPath
+  inherit depotPath;
+  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;
+} ./.) // {
+  inherit depotPath;
 
   # List of all buildable targets, for CI purposes.
   #
@@ -111,8 +90,4 @@ in fix(self: {
     name = "depot-gcroot";
     paths = self.ci.targets;
   };
-}
-
-# Add local packages as structured by readTree
-// (localPkgs (readTree' self.config))
-)
+})