From ce06c30ff0264ccfb10090f7b3ebc79d0d133eb0 Mon Sep 17 00:00:00 2001
From: Jean-Paul Calderone <exarkun@twistedmatrix.com>
Date: Mon, 3 Jan 2022 07:23:50 -0500
Subject: [PATCH] [wip]

---
 default.nix |  2 ++
 shell.nix   | 27 ++++++++++++---------------
 tests.nix   | 32 +++++++++++++-------------------
 3 files changed, 27 insertions(+), 34 deletions(-)

diff --git a/default.nix b/default.nix
index 5f8c0d7..d07b203 100644
--- a/default.nix
+++ b/default.nix
@@ -37,6 +37,8 @@ in
     };
   in
     rec {
+      inherit pkgs mach-nix;
+
       tahoe-lafs = mach-nix.buildPythonPackage rec {
         inherit python providers;
         name = "tahoe-lafs";
diff --git a/shell.nix b/shell.nix
index 0f661eb..023fc1b 100644
--- a/shell.nix
+++ b/shell.nix
@@ -1,17 +1,14 @@
+# Note: Passing arguments through here to customize the environment does not
+# work on Nix 2.3.  It works with Nix 2.5.  I'm not sure about 2.4.
+{ ... }@args:
 let
-  sources = import nix/sources.nix;
+  tests = import ./tests.nix args;
+  inherit (tests) pkgs;
 in
-{ pkgs ? import sources.release2105 {}
-, tahoe-lafs-source ? "tahoe-lafs"
-}:
-  let
-    tests = pkgs.callPackage ./tests.nix {
-      inherit tahoe-lafs-source;
-    };
-  in
-    pkgs.mkShell {
-      packages = [
-        tests.python
-        pkgs.niv
-      ];
-    }
+pkgs.mkShell {
+  buildInputs = [
+    tests.python
+    tests.lint-python
+    pkgs.niv
+  ];
+}
diff --git a/tests.nix b/tests.nix
index c985ce0..f7dc90f 100644
--- a/tests.nix
+++ b/tests.nix
@@ -1,24 +1,13 @@
-let
-  sources = import nix/sources.nix;
-in
-{ pkgs ? import sources.release2105 {}
-, pypiData ? sources.pypi-deps-db
-, mach-nix ? import sources.mach-nix { inherit pkgs pypiData; }
-, tahoe-lafs-source ? "tahoe-lafs"
-, tahoe-lafs-repo ? sources.${tahoe-lafs-source}
-, privatestorage ? import ./. {
-    inherit pkgs pypiData mach-nix;
-    inherit tahoe-lafs-repo;
-  }
+{ privatestorage ? import ./. args
 , hypothesisProfile ? null
 , collectCoverage ? false
 , testSuite ? null
 , trialArgs ? null
-,
-}:
-  let
+, ...
+}@args:
+let
+    inherit (privatestorage) pkgs mach-nix zkapauthorizer;
     inherit (pkgs) lib;
-    inherit (privatestorage) zkapauthorizer;
     hypothesisProfile' = if hypothesisProfile == null then "default" else hypothesisProfile;
     defaultTrialArgs = [ "--rterrors" ] ++ (lib.optional (! collectCoverage) "--jobs=$(($NIX_BUILD_CORES > 8 ? 8 : $NIX_BUILD_CORES))");
     trialArgs' = if trialArgs == null then defaultTrialArgs else trialArgs;
@@ -38,10 +27,11 @@ in
       requirements = ''
         isort
         black
+        flake8
       '';
     };
-  in
-    pkgs.runCommand "zkapauthorizer-tests" {
+
+    tests = pkgs.runCommand "zkapauthorizer-tests" {
       passthru = {
         inherit python;
       };
@@ -65,4 +55,8 @@ in
           cp -v .coverage.* "$out/coverage"
         ''
       }
-    ''
+    '';
+in
+{
+  inherit pkgs python lint-python tests;
+}
-- 
GitLab