From d008726f692e35735796e7c8277dbfd1453481ad Mon Sep 17 00:00:00 2001
From: Jean-Paul Calderone <exarkun@twistedmatrix.com>
Date: Fri, 9 Jul 2021 07:00:53 -0400
Subject: [PATCH] unsuccessful attempt at cabal2nix-based packaging

---
 PaymentServer.nix          |  32 +++++++++
 default.nix                |  17 +++++
 nix/PaymentServer.nix      | 129 ---------------------------------
 nix/default.nix            |  23 ------
 nix/hspec-core.nix         |  33 +++++++++
 nix/hspec-discover.nix     |  27 +++++++
 nix/hspec-meta.nix         |   0
 nix/hspec.nix              |  21 ++++++
 nix/overlay.nix            |   3 -
 nix/pkgs.nix               |  14 ----
 nix/privacypass-repo.nix   |   7 --
 nix/servant-prometheus.nix | 143 ++++++++-----------------------------
 nix/stripe-core.nix        |  21 ++++++
 nix/stripe-haskell.nix     |  18 +++++
 nix/stripe-http-client.nix |  24 +++++++
 nix/stripe-tests.nix       |  22 ++++++
 16 files changed, 246 insertions(+), 288 deletions(-)
 create mode 100644 PaymentServer.nix
 create mode 100644 default.nix
 delete mode 100644 nix/PaymentServer.nix
 delete mode 100644 nix/default.nix
 create mode 100644 nix/hspec-core.nix
 create mode 100644 nix/hspec-discover.nix
 create mode 100644 nix/hspec-meta.nix
 create mode 100644 nix/hspec.nix
 delete mode 100644 nix/overlay.nix
 delete mode 100644 nix/pkgs.nix
 delete mode 100644 nix/privacypass-repo.nix
 create mode 100644 nix/stripe-core.nix
 create mode 100644 nix/stripe-haskell.nix
 create mode 100644 nix/stripe-http-client.nix
 create mode 100644 nix/stripe-tests.nix

diff --git a/PaymentServer.nix b/PaymentServer.nix
new file mode 100644
index 0000000..0d26547
--- /dev/null
+++ b/PaymentServer.nix
@@ -0,0 +1,32 @@
+{ mkDerivation, aeson, async, base, bytestring, containers
+, cryptonite, data-default, directory, http-types, lib
+, libchallenge_bypass_ristretto_ffi, optparse-applicative
+, prometheus-client, raw-strings-qq, retry, servant
+, servant-prometheus, servant-server, sqlite-simple, stripe-core
+, stripe-haskell, tasty, tasty-hunit, text, time, transformers
+, utf8-string, wai, wai-cors, wai-extra, warp, warp-tls
+}:
+mkDerivation {
+  pname = "PaymentServer";
+  version = "0.1.1.0";
+  src = ./.;
+  isLibrary = true;
+  isExecutable = true;
+  libraryHaskellDepends = [
+    aeson base bytestring containers cryptonite data-default http-types
+    optparse-applicative prometheus-client retry servant
+    servant-prometheus servant-server sqlite-simple stripe-core
+    stripe-haskell text utf8-string wai wai-cors wai-extra warp
+    warp-tls
+  ];
+  libraryPkgconfigDepends = [ libchallenge_bypass_ristretto_ffi ];
+  executableHaskellDepends = [ base text ];
+  testHaskellDepends = [
+    async base bytestring directory http-types prometheus-client
+    raw-strings-qq servant-server sqlite-simple stripe-core tasty
+    tasty-hunit text time transformers wai wai-extra warp
+  ];
+  homepage = "https://github.com/privatestorageio/PaymentServer#readme";
+  description = "Coordinate entities for the purchase of PrivateStorage.io vouchers.";
+  license = lib.licenses.asl20;
+}
diff --git a/default.nix b/default.nix
new file mode 100644
index 0000000..01b957e
--- /dev/null
+++ b/default.nix
@@ -0,0 +1,17 @@
+with import <nixpkgs> { };
+haskell.packages.ghc865.callPackage ./PaymentServer.nix {
+  libchallenge_bypass_ristretto_ffi = callPackage ./nix/challenge-bypass-ristretto.nix { };
+  servant-prometheus = haskell.packages.ghc865.callPackage ./nix/servant-prometheus.nix { };
+  stripe-core = haskell.packages.ghc865.callPackage ./nix/stripe-core.nix { };
+  stripe-haskell = haskell.packages.ghc865.callPackage ./nix/stripe-haskell.nix {
+    stripe-http-client = haskell.packages.ghc865.callPackage ./nix/stripe-http-client.nix {
+      stripe-tests = haskell.packages.ghc865.callPackage ./nix/stripe-tests.nix rec {
+        hspec = haskell.packages.ghc865.callPackage ./nix/hspec.nix {
+          inherit hspec-core;
+          hspec-discover = haskell.packages.ghc865.callPackage ./nix/hspec-discover.nix { };
+        };
+        hspec-core = haskell.packages.ghc865.callPackage ./nix/hspec-core.nix { };
+      };
+    };
+  };
+}
diff --git a/nix/PaymentServer.nix b/nix/PaymentServer.nix
deleted file mode 100644
index 993b320..0000000
--- a/nix/PaymentServer.nix
+++ /dev/null
@@ -1,129 +0,0 @@
-let
-  buildDepError = pkg:
-    builtins.throw ''
-      The Haskell package set does not contain the package: ${pkg} (build dependency).
-
-      If you are using Stackage, make sure that you are using a snapshot that contains the package. Otherwise you may need to update the Hackage snapshot you are using, usually by updating haskell.nix.
-      '';
-  sysDepError = pkg:
-    builtins.throw ''
-      The Nixpkgs package set does not contain the package: ${pkg} (system dependency).
-
-      You may need to augment the system package mapping in haskell.nix so that it can be found.
-      '';
-  pkgConfDepError = pkg:
-    builtins.throw ''
-      The pkg-conf packages does not contain the package: ${pkg} (pkg-conf dependency).
-
-      You may need to augment the pkg-conf package mapping in haskell.nix so that it can be found.
-      '';
-  exeDepError = pkg:
-    builtins.throw ''
-      The local executable components do not include the component: ${pkg} (executable dependency).
-      '';
-  legacyExeDepError = pkg:
-    builtins.throw ''
-      The Haskell package set does not contain the package: ${pkg} (executable dependency).
-
-      If you are using Stackage, make sure that you are using a snapshot that contains the package. Otherwise you may need to update the Hackage snapshot you are using, usually by updating haskell.nix.
-      '';
-  buildToolDepError = pkg:
-    builtins.throw ''
-      Neither the Haskell package set or the Nixpkgs package set contain the package: ${pkg} (build tool dependency).
-
-      If this is a system dependency:
-      You may need to augment the system package mapping in haskell.nix so that it can be found.
-
-      If this is a Haskell dependency:
-      If you are using Stackage, make sure that you are using a snapshot that contains the package. Otherwise you may need to update the Hackage snapshot you are using, usually by updating haskell.nix.
-      '';
-in { system, compiler, flags, pkgs, hsPkgs, pkgconfPkgs, ... }:
-  {
-    flags = {};
-    package = {
-      specVersion = "1.10";
-      identifier = { name = "PaymentServer"; version = "0.1.1.0"; };
-      license = "Apache-2.0";
-      copyright = "2019 Private Storage.io, LLC.";
-      maintainer = "support@privatestorage.io";
-      author = "Jean-Paul Calderone";
-      homepage = "https://github.com/privatestorageio/PaymentServer#readme";
-      url = "";
-      synopsis = "Coordinate entities for the purchase of PrivateStorage.io vouchers.";
-      description = "";
-      buildType = "Simple";
-      };
-    components = {
-      "library" = {
-        depends = [
-          (hsPkgs."base" or (buildDepError "base"))
-          (hsPkgs."optparse-applicative" or (buildDepError "optparse-applicative"))
-          (hsPkgs."aeson" or (buildDepError "aeson"))
-          (hsPkgs."bytestring" or (buildDepError "bytestring"))
-          (hsPkgs."utf8-string" or (buildDepError "utf8-string"))
-          (hsPkgs."servant" or (buildDepError "servant"))
-          (hsPkgs."servant-server" or (buildDepError "servant-server"))
-          (hsPkgs."http-types" or (buildDepError "http-types"))
-          (hsPkgs."wai" or (buildDepError "wai"))
-          (hsPkgs."wai-extra" or (buildDepError "wai-extra"))
-          (hsPkgs."wai-cors" or (buildDepError "wai-cors"))
-          (hsPkgs."data-default" or (buildDepError "data-default"))
-          (hsPkgs."warp" or (buildDepError "warp"))
-          (hsPkgs."warp-tls" or (buildDepError "warp-tls"))
-          (hsPkgs."stripe-haskell" or (buildDepError "stripe-haskell"))
-          (hsPkgs."stripe-core" or (buildDepError "stripe-core"))
-          (hsPkgs."text" or (buildDepError "text"))
-          (hsPkgs."containers" or (buildDepError "containers"))
-          (hsPkgs."cryptonite" or (buildDepError "cryptonite"))
-          (hsPkgs."sqlite-simple" or (buildDepError "sqlite-simple"))
-          (hsPkgs."retry" or (buildDepError "retry"))
-          (hsPkgs."prometheus-client" or (buildDepError "prometheus-client"))
-          (hsPkgs."servant-prometheus" or (buildDepError "servant-prometheus"))
-          ];
-        pkgconfig = [
-          (pkgconfPkgs."libchallenge_bypass_ristretto_ffi" or (pkgConfDepError "libchallenge_bypass_ristretto_ffi"))
-          ];
-        };
-      exes = {
-        "PaymentServer-exe" = {
-          depends = [
-            (hsPkgs."base" or (buildDepError "base"))
-            (hsPkgs."PaymentServer" or (buildDepError "PaymentServer"))
-            ];
-          };
-        "PaymentServer-generate-key" = {
-          depends = [
-            (hsPkgs."base" or (buildDepError "base"))
-            (hsPkgs."text" or (buildDepError "text"))
-            (hsPkgs."PaymentServer" or (buildDepError "PaymentServer"))
-            ];
-          };
-        };
-      tests = {
-        "PaymentServer-tests" = {
-          depends = [
-            (hsPkgs."base" or (buildDepError "base"))
-            (hsPkgs."bytestring" or (buildDepError "bytestring"))
-            (hsPkgs."text" or (buildDepError "text"))
-            (hsPkgs."transformers" or (buildDepError "transformers"))
-            (hsPkgs."raw-strings-qq" or (buildDepError "raw-strings-qq"))
-            (hsPkgs."time" or (buildDepError "time"))
-            (hsPkgs."tasty" or (buildDepError "tasty"))
-            (hsPkgs."tasty-hunit" or (buildDepError "tasty-hunit"))
-            (hsPkgs."directory" or (buildDepError "directory"))
-            (hsPkgs."async" or (buildDepError "async"))
-            (hsPkgs."sqlite-simple" or (buildDepError "sqlite-simple"))
-            (hsPkgs."http-types" or (buildDepError "http-types"))
-            (hsPkgs."wai" or (buildDepError "wai"))
-            (hsPkgs."wai-extra" or (buildDepError "wai-extra"))
-            (hsPkgs."warp" or (buildDepError "warp"))
-            (hsPkgs."http-types" or (buildDepError "http-types"))
-            (hsPkgs."servant-server" or (buildDepError "servant-server"))
-            (hsPkgs."prometheus-client" or (buildDepError "prometheus-client"))
-            (hsPkgs."stripe-core" or (buildDepError "stripe-core"))
-            (hsPkgs."PaymentServer" or (buildDepError "PaymentServer"))
-            ];
-          };
-        };
-      };
-    } // rec { src = (pkgs.lib).mkDefault .././.; }
\ No newline at end of file
diff --git a/nix/default.nix b/nix/default.nix
deleted file mode 100644
index 64d71bb..0000000
--- a/nix/default.nix
+++ /dev/null
@@ -1,23 +0,0 @@
-{ pkgs ? import <nixpkgs> { } }:
-
-let
-  # Get our overlay in place regardless of whether a value is passed for pkgs.
-  # The build fails without it and it's unreasonable to expect our caller to
-  # know to apply it.
-  nixpkgs = import pkgs.path { overlays = [ (import ./overlay.nix) ]; };
-
-  # Pin a particular version of haskell.nix.  The particular version isn't
-  # special.  It's just recent at the time this expression was written and it
-  # is known to work with PaymentServer.  It could be bumped if necessary but
-  # this would probably only happen as a result of bumping the resolver in
-  # stack.yaml.
-  haskell = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/0cb32e695d7014908fb01fd7e3d225ea33dbdc98.tar.gz) { pkgs = nixpkgs; };
-
-  pkgSet = haskell.mkStackPkgSet {
-    stack-pkgs = import ./pkgs.nix;
-    pkg-def-extras = [];
-    modules = [];
-  };
-
-in
-  pkgSet.config.hsPkgs
diff --git a/nix/hspec-core.nix b/nix/hspec-core.nix
new file mode 100644
index 0000000..582fa6a
--- /dev/null
+++ b/nix/hspec-core.nix
@@ -0,0 +1,33 @@
+{ mkDerivation, ansi-terminal, array, base, call-stack, clock
+, deepseq, directory, fetchgit, filepath, hpack, hspec-expectations
+, hspec-meta, HUnit, lib, process, QuickCheck, quickcheck-io
+, random, setenv, silently, stm, temporary, tf-random, transformers
+}:
+mkDerivation {
+  pname = "hspec-core";
+  version = "2.6.1";
+  src = fetchgit {
+    url = "https://github.com/hspec/hspec";
+    sha256 = "0nqvkp6a8ii4sgv9cl4vr0f2bby4a91m6sr5sjlv0nvycqwin69m";
+    rev = "95ad518ae49ef6596e7ed55c47084cd75045c169";
+    fetchSubmodules = true;
+  };
+  postUnpack = "sourceRoot+=/hspec-core; echo source root reset to $sourceRoot";
+  libraryHaskellDepends = [
+    ansi-terminal array base call-stack clock deepseq directory
+    filepath hspec-expectations HUnit QuickCheck quickcheck-io random
+    setenv stm tf-random transformers
+  ];
+  libraryToolDepends = [ hpack ];
+  testHaskellDepends = [
+    ansi-terminal array base call-stack clock deepseq directory
+    filepath hspec-expectations hspec-meta HUnit process QuickCheck
+    quickcheck-io random setenv silently stm temporary tf-random
+    transformers
+  ];
+  testToolDepends = [ hspec-meta ];
+  testTarget = "--test-option=--skip --test-option='Test.Hspec.Core.Runner.hspecResult runs specs in parallel'";prePatch = "hpack";
+  homepage = "http://hspec.github.io/";
+  description = "A Testing Framework for Haskell";
+  license = lib.licenses.mit;
+}
diff --git a/nix/hspec-discover.nix b/nix/hspec-discover.nix
new file mode 100644
index 0000000..e8f5f27
--- /dev/null
+++ b/nix/hspec-discover.nix
@@ -0,0 +1,27 @@
+{ mkDerivation, base, directory, fetchgit, filepath, hpack
+, hspec-meta, lib, QuickCheck
+}:
+mkDerivation {
+  pname = "hspec-discover";
+  version = "2.6.1";
+  src = fetchgit {
+    url = "https://github.com/hspec/hspec";
+    sha256 = "0nqvkp6a8ii4sgv9cl4vr0f2bby4a91m6sr5sjlv0nvycqwin69m";
+    rev = "95ad518ae49ef6596e7ed55c47084cd75045c169";
+    fetchSubmodules = true;
+  };
+  postUnpack = "sourceRoot+=/hspec-discover; echo source root reset to $sourceRoot";
+  isLibrary = true;
+  isExecutable = true;
+  libraryHaskellDepends = [ base directory filepath ];
+  libraryToolDepends = [ hpack ];
+  executableHaskellDepends = [ base directory filepath ];
+  testHaskellDepends = [
+    base directory filepath hspec-meta QuickCheck
+  ];
+  testToolDepends = [ hspec-meta ];
+  prePatch = "hpack";
+  homepage = "http://hspec.github.io/";
+  description = "Automatically discover and run Hspec tests";
+  license = lib.licenses.mit;
+}
diff --git a/nix/hspec-meta.nix b/nix/hspec-meta.nix
new file mode 100644
index 0000000..e69de29
diff --git a/nix/hspec.nix b/nix/hspec.nix
new file mode 100644
index 0000000..381836d
--- /dev/null
+++ b/nix/hspec.nix
@@ -0,0 +1,21 @@
+{ mkDerivation, base, fetchgit, hpack, hspec-core, hspec-discover
+, hspec-expectations, lib, QuickCheck
+}:
+mkDerivation {
+  pname = "hspec";
+  version = "2.6.1";
+  src = fetchgit {
+    url = "https://github.com/hspec/hspec";
+    sha256 = "0nqvkp6a8ii4sgv9cl4vr0f2bby4a91m6sr5sjlv0nvycqwin69m";
+    rev = "95ad518ae49ef6596e7ed55c47084cd75045c169";
+    fetchSubmodules = true;
+  };
+  libraryHaskellDepends = [
+    base hspec-core hspec-discover hspec-expectations QuickCheck
+  ];
+  libraryToolDepends = [ hpack ];
+  prePatch = "hpack";
+  homepage = "http://hspec.github.io/";
+  description = "A Testing Framework for Haskell";
+  license = lib.licenses.mit;
+}
diff --git a/nix/overlay.nix b/nix/overlay.nix
deleted file mode 100644
index dc4b0ae..0000000
--- a/nix/overlay.nix
+++ /dev/null
@@ -1,3 +0,0 @@
-self: super: {
-  libchallenge_bypass_ristretto_ffi = super.callPackage ./challenge-bypass-ristretto.nix { };
-}
diff --git a/nix/pkgs.nix b/nix/pkgs.nix
deleted file mode 100644
index 24d76f5..0000000
--- a/nix/pkgs.nix
+++ /dev/null
@@ -1,14 +0,0 @@
-{
-  extras = hackage:
-    {
-      packages = ({
-        "stripe-core" = (((hackage.stripe-core)."2.5.0").revisions).default;
-        "stripe-haskell" = (((hackage.stripe-haskell)."2.5.0").revisions).default;
-        "stripe-http-client" = (((hackage.stripe-http-client)."2.5.0").revisions).default;
-        } // {
-        PaymentServer = ./PaymentServer.nix;
-        servant-prometheus = ./servant-prometheus.nix;
-        }) // {};
-      };
-  resolver = "lts-14.1";
-  }
\ No newline at end of file
diff --git a/nix/privacypass-repo.nix b/nix/privacypass-repo.nix
deleted file mode 100644
index 6b0c64c..0000000
--- a/nix/privacypass-repo.nix
+++ /dev/null
@@ -1,7 +0,0 @@
-{ fetchFromGitHub }:
-fetchFromGitHub {
-  owner = "LeastAuthority";
-  repo = "privacypass";
-  rev = "45855401e163f8e622bd93a5c5bce13de8c8510a";
-  sha256 = "sha256:15wv8vas6x8cdicylp0m632c916p7qxq1k4lnchr8c92lldp0rv7";
-}
diff --git a/nix/servant-prometheus.nix b/nix/servant-prometheus.nix
index 07ee24d..77abb31 100644
--- a/nix/servant-prometheus.nix
+++ b/nix/servant-prometheus.nix
@@ -1,112 +1,31 @@
-let
-  buildDepError = pkg:
-    builtins.throw ''
-      The Haskell package set does not contain the package: ${pkg} (build dependency).
-      
-      If you are using Stackage, make sure that you are using a snapshot that contains the package. Otherwise you may need to update the Hackage snapshot you are using, usually by updating haskell.nix.
-      '';
-  sysDepError = pkg:
-    builtins.throw ''
-      The Nixpkgs package set does not contain the package: ${pkg} (system dependency).
-      
-      You may need to augment the system package mapping in haskell.nix so that it can be found.
-      '';
-  pkgConfDepError = pkg:
-    builtins.throw ''
-      The pkg-conf packages does not contain the package: ${pkg} (pkg-conf dependency).
-      
-      You may need to augment the pkg-conf package mapping in haskell.nix so that it can be found.
-      '';
-  exeDepError = pkg:
-    builtins.throw ''
-      The local executable components do not include the component: ${pkg} (executable dependency).
-      '';
-  legacyExeDepError = pkg:
-    builtins.throw ''
-      The Haskell package set does not contain the package: ${pkg} (executable dependency).
-      
-      If you are using Stackage, make sure that you are using a snapshot that contains the package. Otherwise you may need to update the Hackage snapshot you are using, usually by updating haskell.nix.
-      '';
-  buildToolDepError = pkg:
-    builtins.throw ''
-      Neither the Haskell package set or the Nixpkgs package set contain the package: ${pkg} (build tool dependency).
-      
-      If this is a system dependency:
-      You may need to augment the system package mapping in haskell.nix so that it can be found.
-      
-      If this is a Haskell dependency:
-      If you are using Stackage, make sure that you are using a snapshot that contains the package. Otherwise you may need to update the Hackage snapshot you are using, usually by updating haskell.nix.
-      '';
-in { system, compiler, flags, pkgs, hsPkgs, pkgconfPkgs, ... }:
-  {
-    flags = {};
-    package = {
-      specVersion = "1.10";
-      identifier = { name = "servant-prometheus"; version = "0.2.0.0"; };
-      license = "BSD-3-Clause";
-      copyright = "";
-      maintainer = "Alex Mason <axman6@gmail.com>, Jack Kelly <jack.kelly@data61.csiro.au>";
-      author = "Alex Mason <axman6@gmail.com>, Anchor Engineering <engineering@lists.anchor.net.au>, Servant Contributors";
-      homepage = "";
-      url = "";
-      synopsis = "Helpers for using prometheus with servant";
-      description = "Helpers for using prometheus with servant. Each endpoint has its own metrics allowing more detailed monitoring than wai-middleware-prometheus allows";
-      buildType = "Simple";
-      };
-    components = {
-      "library" = {
-        depends = [
-          (hsPkgs."base" or (buildDepError "base"))
-          (hsPkgs."prometheus-client" or (buildDepError "prometheus-client"))
-          (hsPkgs."servant" or (buildDepError "servant"))
-          (hsPkgs."http-types" or (buildDepError "http-types"))
-          (hsPkgs."text" or (buildDepError "text"))
-          (hsPkgs."time" or (buildDepError "time"))
-          (hsPkgs."unordered-containers" or (buildDepError "unordered-containers"))
-          (hsPkgs."wai" or (buildDepError "wai"))
-          (hsPkgs."bytestring" or (buildDepError "bytestring"))
-          ];
-        };
-      exes = {
-        "bench" = {
-          depends = [
-            (hsPkgs."base" or (buildDepError "base"))
-            (hsPkgs."aeson" or (buildDepError "aeson"))
-            (hsPkgs."servant-prometheus" or (buildDepError "servant-prometheus"))
-            (hsPkgs."servant-server" or (buildDepError "servant-server"))
-            (hsPkgs."prometheus-client" or (buildDepError "prometheus-client"))
-            (hsPkgs."text" or (buildDepError "text"))
-            (hsPkgs."wai" or (buildDepError "wai"))
-            (hsPkgs."warp" or (buildDepError "warp"))
-            (hsPkgs."process" or (buildDepError "process"))
-            ];
-          };
-        };
-      tests = {
-        "spec" = {
-          depends = [
-            (hsPkgs."base" or (buildDepError "base"))
-            (hsPkgs."aeson" or (buildDepError "aeson"))
-            (hsPkgs."servant-prometheus" or (buildDepError "servant-prometheus"))
-            (hsPkgs."servant-server" or (buildDepError "servant-server"))
-            (hsPkgs."servant-client" or (buildDepError "servant-client"))
-            (hsPkgs."servant" or (buildDepError "servant"))
-            (hsPkgs."prometheus-client" or (buildDepError "prometheus-client"))
-            (hsPkgs."http-client" or (buildDepError "http-client"))
-            (hsPkgs."text" or (buildDepError "text"))
-            (hsPkgs."wai" or (buildDepError "wai"))
-            (hsPkgs."warp" or (buildDepError "warp"))
-            (hsPkgs."hspec" or (buildDepError "hspec"))
-            (hsPkgs."unordered-containers" or (buildDepError "unordered-containers"))
-            (hsPkgs."transformers" or (buildDepError "transformers"))
-            ];
-          };
-        };
-      };
-    } // {
-    src = (pkgs.lib).mkDefault (pkgs.fetchgit {
-      url = "https://github.com/PrivateStorageio/servant-prometheus.git";
-      rev = "b9461cbf689b47506b2eee973136706092b74968";
-      sha256 = "1gfslw670ri119bnq3szc8b08n504f8cnzs5cgk5qvfwvfmsr1xh";
-      });
-    }
\ No newline at end of file
+{ mkDerivation, aeson, base, bytestring, fetchgit, hspec
+, http-client, http-types, lib, process, prometheus-client, servant
+, servant-client, servant-server, text, time, transformers
+, unordered-containers, wai, warp
+}:
+mkDerivation {
+  pname = "servant-prometheus";
+  version = "0.2.0.0";
+  src = fetchgit {
+    url = "https://github.com/PrivateStorageio/servant-prometheus.git";
+    sha256 = "1gfslw670ri119bnq3szc8b08n504f8cnzs5cgk5qvfwvfmsr1xh";
+    rev = "b9461cbf689b47506b2eee973136706092b74968";
+    fetchSubmodules = true;
+  };
+  isLibrary = true;
+  isExecutable = true;
+  libraryHaskellDepends = [
+    base bytestring http-types prometheus-client servant text time
+    unordered-containers wai
+  ];
+  executableHaskellDepends = [
+    aeson base process prometheus-client servant-server text wai warp
+  ];
+  testHaskellDepends = [
+    aeson base hspec http-client prometheus-client servant
+    servant-client servant-server text transformers
+    unordered-containers wai warp
+  ];
+  description = "Helpers for using prometheus with servant";
+  license = lib.licenses.bsd3;
+}
diff --git a/nix/stripe-core.nix b/nix/stripe-core.nix
new file mode 100644
index 0000000..6d5713b
--- /dev/null
+++ b/nix/stripe-core.nix
@@ -0,0 +1,21 @@
+{ mkDerivation, aeson, base, bytestring, fetchgit, lib, mtl, text
+, time, transformers, unordered-containers
+}:
+mkDerivation {
+  pname = "stripe-core";
+  version = "2.5.0";
+  src = fetchgit {
+    url = "https://github.com/dmjio/stripe.git";
+    sha256 = "0hwc0x7vs25047rybnm71x4c5v37k69iq66g697hdal0ccnmadns";
+    rev = "913b88e7c71c783549919a6019ad5cd9306f80e8";
+    fetchSubmodules = true;
+  };
+  postUnpack = "sourceRoot+=/stripe-core; echo source root reset to $sourceRoot";
+  libraryHaskellDepends = [
+    aeson base bytestring mtl text time transformers
+    unordered-containers
+  ];
+  homepage = "https://github.com/dmjio/stripe-haskell";
+  description = "Stripe API for Haskell - Pure Core";
+  license = lib.licenses.mit;
+}
diff --git a/nix/stripe-haskell.nix b/nix/stripe-haskell.nix
new file mode 100644
index 0000000..8bd9fe0
--- /dev/null
+++ b/nix/stripe-haskell.nix
@@ -0,0 +1,18 @@
+{ mkDerivation, base, fetchgit, lib, stripe-core
+, stripe-http-client
+}:
+mkDerivation {
+  pname = "stripe-haskell";
+  version = "2.5.0";
+  src = fetchgit {
+    url = "https://github.com/dmjio/stripe.git";
+    sha256 = "0hwc0x7vs25047rybnm71x4c5v37k69iq66g697hdal0ccnmadns";
+    rev = "913b88e7c71c783549919a6019ad5cd9306f80e8";
+    fetchSubmodules = true;
+  };
+  postUnpack = "sourceRoot+=/stripe-haskell; echo source root reset to $sourceRoot";
+  libraryHaskellDepends = [ base stripe-core stripe-http-client ];
+  homepage = "https://github.com/dmjio/stripe";
+  description = "Stripe API for Haskell";
+  license = lib.licenses.mit;
+}
diff --git a/nix/stripe-http-client.nix b/nix/stripe-http-client.nix
new file mode 100644
index 0000000..ad0acfc
--- /dev/null
+++ b/nix/stripe-http-client.nix
@@ -0,0 +1,24 @@
+{ mkDerivation, aeson, base, bytestring, fetchgit, free, hspec
+, http-client, http-client-tls, http-types, lib, stripe-core
+, stripe-tests, text
+}:
+mkDerivation {
+  pname = "stripe-http-client";
+  version = "2.5.0";
+  src = fetchgit {
+    url = "https://github.com/dmjio/stripe.git";
+    sha256 = "0hwc0x7vs25047rybnm71x4c5v37k69iq66g697hdal0ccnmadns";
+    rev = "913b88e7c71c783549919a6019ad5cd9306f80e8";
+    fetchSubmodules = true;
+  };
+  postUnpack = "sourceRoot+=/stripe-http-client; echo source root reset to $sourceRoot";
+  libraryHaskellDepends = [
+    aeson base bytestring http-client http-client-tls http-types
+    stripe-core text
+  ];
+  testHaskellDepends = [
+    base free hspec http-client stripe-core stripe-tests
+  ];
+  description = "Stripe API for Haskell - http-client backend";
+  license = lib.licenses.mit;
+}
diff --git a/nix/stripe-tests.nix b/nix/stripe-tests.nix
new file mode 100644
index 0000000..3abf30c
--- /dev/null
+++ b/nix/stripe-tests.nix
@@ -0,0 +1,22 @@
+{ mkDerivation, aeson, base, bytestring, fetchgit, free, hspec
+, hspec-core, lib, mtl, random, stripe-core, text, time
+, transformers, unordered-containers
+}:
+mkDerivation {
+  pname = "stripe-tests";
+  version = "2.5.0";
+  src = fetchgit {
+    url = "https://github.com/dmjio/stripe.git";
+    sha256 = "0hwc0x7vs25047rybnm71x4c5v37k69iq66g697hdal0ccnmadns";
+    rev = "913b88e7c71c783549919a6019ad5cd9306f80e8";
+    fetchSubmodules = true;
+  };
+  postUnpack = "sourceRoot+=/stripe-tests; echo source root reset to $sourceRoot";
+  libraryHaskellDepends = [
+    aeson base bytestring free hspec hspec-core mtl random stripe-core
+    text time transformers unordered-containers
+  ];
+  homepage = "https://github.com/dmjio/stripe-haskell";
+  description = "Tests for Stripe API bindings for Haskell";
+  license = lib.licenses.mit;
+}
-- 
GitLab