about summary refs log tree commit diff
path: root/default.nix
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-11-15T23·25+0000
committerVincent Ambo <tazjin@google.com>2019-11-15T23·25+0000
commit45d63bce1728589836079ecbce83c08f8220845a (patch)
treef52007db7475f2ed3d85fec5236bc9380335af00 /default.nix
parentc1c379848a19a31de8febb1385c7b9e4d2a474a3 (diff)
feat(nix): Filter projects that should be built by CI
Instead of specifying CI projects manually, this filters them to move
the CI configuration into the derivations `meta` attributes.
Diffstat (limited to 'default.nix')
-rw-r--r--default.nix33
1 files changed, 20 insertions, 13 deletions
diff --git a/default.nix b/default.nix
index 789098667a..d7ef5b72bc 100644
--- a/default.nix
+++ b/default.nix
@@ -16,7 +16,16 @@ let
   };
   readTree = import ./read-tree.nix;
 
-  localPkgs = self: super:
+  # Derivations that have `meta.enableCI` set to `true` should be
+  # built by the CI system on every commit. This code implements
+  # filtering of all derivations in the local sets against this
+  # condition.
+  filterCI = lib: pkgs: let
+    inherit (lib) collect isDerivation filterAttrsRecursive;
+    ciCondition = _: x: (!isDerivation x) || ((x ? meta.enableCI) && (x.meta.enableCI));
+  in collect isDerivation (filterAttrsRecursive ciCondition pkgs);
+
+  repoPkgs = self: super:
     let config = {
       pkgs = self;
       upstream = super;
@@ -32,19 +41,17 @@ let
       services = readTree ./services config;
       tools = readTree ./tools config;
       third_party = readTree ./third_party config;
-    } // (readTree ./overrides config);
-
-  #   # All projects that should be built by CI should be added here:
-  #   ciProjects = [
-  #     self.kontemplate
-  #     self.nixery
-  #     self.ormolu
-  #     self.terraform-gcp
-  #   ] ++ filter (d: d ? meta.broken && !d.meta.broken) (attrValues self.tazjin);
-  # };
-
+    }
+    # Load overrides into the top-level:
+    // (readTree ./overrides config)
+    # Collect all projects that should be built by CI
+    // {
+      ciProjects = (filterCI super.lib self.services)
+        ++ (filterCI super.lib self.tools)
+        ++ (filterCI super.lib self.third_party);
+    };
 in { ... } @ args: import stableSrc (args // {
-    overlays = [ localPkgs ];
+    overlays = [ repoPkgs ];
     config.allowUnfree = true;
     config.allowBroken = true;
 })