diff --git a/flake.nix b/flake.nix
index 8943f3c1556afb4c39ab388d0c9547b319126954..95bd2f524acb173f8bd432726829f26c7b1109a1 100644
--- a/flake.nix
+++ b/flake.nix
@@ -49,11 +49,21 @@
         program = "${
           pkgs.writeShellApplication {
             name = "cabal-build-and-test";
-            runtimeInputs = with pkgs; [pkg-config haskell.compiler.${ghcVersion} cabal-install zlib];
+            # Only put packages with things that need to be on PATH here
+            # because that's all t hat runtimeInputs buys us.  Packages with
+            # different requirements need to be handled differently.
+            runtimeInputs = with pkgs; [
+              pkg-config
+              haskell.compiler.${ghcVersion}
+              cabal-install
+            ];
 
             text = ''
+              # Here we make zlib discoverable by pkg-config so cabal can find
+              # headers and stuff.
+              export PKG_CONFIG_PATH=${pkgs.lib.makeSearchPath "lib/pkgconfig" [pkgs.zlib.dev]}
+
               cabal update hackage.haskell.org
-              cabal build --enable-tests
               cabal run gbs-downloader-test
             '';
           }