From 55cc7694e4bf5279703fed3b9574ddc7ea80c4d1 Mon Sep 17 00:00:00 2001
From: Jean-Paul Calderone <exarkun@twistedmatrix.com>
Date: Fri, 18 Oct 2019 15:09:02 -0400
Subject: [PATCH] Try having CircleCI cache for the huge system-tests.nix
 build.

---
 .circleci/config.yml | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/.circleci/config.yml b/.circleci/config.yml
index ae8ac923..4b26b975 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -46,8 +46,35 @@ jobs:
             # Required for the checkout step
             nix-env -i git openssh
 
+      - restore_cache:
+          # Get all of Nix's state relating to the particular revision of
+          # nixpkgs we're using.  It will always be the same.  CircleCI
+          # artifacts and nixpkgs store objects are probably mostly hosted in
+          # the same place (S3) so there's not a lot of difference for
+          # anything that's pre-built.  For anything we end up building
+          # ourselves, though, this saves us all of the build time (less the
+          # download time).
+          #
+          # Read about caching dependencies: https://circleci.com/docs/2.0/caching/
+          name: "Restore Nix Store Paths"
+          keys:
+            # Construct cache keys that allow sharing as long as nixpkgs
+            # revision is unchanged.
+            #
+            # If nixpkgs changes then potentially a lot of cached packages for
+            # the base system will be invalidated so we may as well drop them
+            # and make a new cache with the new packages.
+            - privatestorageio-nix-store-v1-{{ checksum "nixpkgs.rev" }}
+            - privatestorageio-nix-store-v1-
+
       - "checkout"
 
+      - save_cache:
+          name: "Cache Nix Store Paths"
+          key: privatestorageio-nix-store-v1-{{ checksum "nixpkgs.rev" }}
+          paths:
+            - "/nix"
+
       - run:
           name: "Run Tests"
           command: |
-- 
GitLab