From d411e9037c860368e433f9e413fc28b31f3e0e38 Mon Sep 17 00:00:00 2001
From: Charles Hall <charles@computer.surgery>
Date: Tue, 5 Mar 2024 12:05:50 -0800
Subject: [PATCH] upload all devshell inputs to the cache

This will also include attic, so we don't need to explicitly do this
in `./bin/nix-build-and-cache` anymore, which is good because that
script gets called a good number of times and doing that repeatedly was
a bit of a waste.
---
 .gitlab-ci.yml          |  3 +++
 bin/nix-build-and-cache | 15 +++++----------
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 866ef11f..e0ed08ee 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -36,6 +36,9 @@ ci:
   stage: ci
   image: nixos/nix:2.20.4
   script:
+    # Cache the inputs required for the devShell
+    - ./bin/nix-build-and-cache .#devShells.x86_64-linux.default.inputDerivation
+
     - direnv exec . engage
   cache:
     key: nix
diff --git a/bin/nix-build-and-cache b/bin/nix-build-and-cache
index b37ebd85..0eb816c3 100755
--- a/bin/nix-build-and-cache
+++ b/bin/nix-build-and-cache
@@ -15,17 +15,12 @@ nix run --inputs-from . attic -- login \
         https://nix.computer.surgery/conduit \
         "$ATTIC_TOKEN"
 
-    push_args=(
-        # Attic and its build dependencies
-        "$(nix path-info --inputs-from . attic)"
-        "$(nix path-info --inputs-from . attic --derivation)"
-
-        # The target installable and its build dependencies
-        "$(nix path-info "$INSTALLABLE" --derivation)"
+    # Push the target installable and its build dependencies
+    nix run --inputs-from . attic -- \
+        push \
+        conduit \
+        "$(nix path-info "$INSTALLABLE" --derivation)" \
         "$(nix path-info "$INSTALLABLE")"
-    )
-
-    nix run --inputs-from . attic -- push conduit "${push_args[@]}"
 else
     echo "\$ATTIC_TOKEN is unset, skipping uploading to the binary cache"
 fi