From 81ca450948ce95ffaad62b36459024b61e664a71 Mon Sep 17 00:00:00 2001
From: Jean-Paul Calderone <exarkun@twistedmatrix.com>
Date: Tue, 24 Sep 2019 14:15:06 -0400
Subject: [PATCH] stack-to-nix -o ./nix

---
 nix/PaymentServer.nix | 93 +++++++++++++++++++++++++++++++++++++++++++
 nix/default.nix       | 13 ++++++
 nix/pkgs.nix          |  9 +++++
 3 files changed, 115 insertions(+)
 create mode 100644 nix/PaymentServer.nix
 create mode 100644 nix/default.nix
 create mode 100644 nix/pkgs.nix

diff --git a/nix/PaymentServer.nix b/nix/PaymentServer.nix
new file mode 100644
index 0000000..ec9fe44
--- /dev/null
+++ b/nix/PaymentServer.nix
@@ -0,0 +1,93 @@
+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.0.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."servant" or (buildDepError "servant"))
+          (hsPkgs."servant-server" or (buildDepError "servant-server"))
+          (hsPkgs."wai" or (buildDepError "wai"))
+          (hsPkgs."wai-extra" or (buildDepError "wai-extra"))
+          (hsPkgs."data-default" or (buildDepError "data-default"))
+          (hsPkgs."warp" or (buildDepError "warp"))
+          (hsPkgs."stripe-core" or (buildDepError "stripe-core"))
+          (hsPkgs."text" or (buildDepError "text"))
+          (hsPkgs."containers" or (buildDepError "containers"))
+          (hsPkgs."cryptonite" or (buildDepError "cryptonite"))
+          ];
+        pkgconfig = [
+          (pkgconfPkgs."ristretto" or (pkgConfDepError "ristretto"))
+          ];
+        };
+      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"))
+            ];
+          };
+        };
+      };
+    } // rec { src = (pkgs.lib).mkDefault ../.; }
\ No newline at end of file
diff --git a/nix/default.nix b/nix/default.nix
new file mode 100644
index 0000000..8d53ae3
--- /dev/null
+++ b/nix/default.nix
@@ -0,0 +1,13 @@
+{ pkgs ? import <nixpkgs> {} }:
+
+let
+  haskell = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) { inherit pkgs; };
+
+  pkgSet = haskell.mkStackPkgSet {
+    stack-pkgs = import ./pkgs.nix;
+    pkg-def-extras = [];
+    modules = [];
+  };
+
+in
+  pkgSet.config.hsPkgs
diff --git a/nix/pkgs.nix b/nix/pkgs.nix
new file mode 100644
index 0000000..26ae488
--- /dev/null
+++ b/nix/pkgs.nix
@@ -0,0 +1,9 @@
+{
+  extras = hackage:
+    {
+      packages = ({
+        "stripe-core" = (((hackage.stripe-core)."2.5.0").revisions).default;
+        } // { PaymentServer = ./PaymentServer.nix; }) // {};
+      };
+  resolver = "lts-14.1";
+  }
\ No newline at end of file
-- 
GitLab