From d633401dc22fcdd3a406a5d3091fc91fc1769d3c Mon Sep 17 00:00:00 2001
From: Jean-Paul Calderone <exarkun@twistedmatrix.com>
Date: Fri, 6 Sep 2019 10:30:10 -0400
Subject: [PATCH] Get building and linking against Ristretto working

---
 ristretto.nix   | 10 ++++++++++
 stack-shell.nix | 17 +++++++++++++++++
 stack.yaml      |  4 ++++
 3 files changed, 31 insertions(+)
 create mode 100644 ristretto.nix
 create mode 100644 stack-shell.nix

diff --git a/ristretto.nix b/ristretto.nix
new file mode 100644
index 0000000..ba86315
--- /dev/null
+++ b/ristretto.nix
@@ -0,0 +1,10 @@
+{ fetchFromGitHub, callPackage }:
+let
+  src = fetchFromGitHub {
+    owner = "LeastAuthority";
+    repo = "privacypass";
+    rev = "f74b371cdf179454f3ad540a4d0deea879fbe5e1";
+    sha256 = "0a020ks8awlpil58zcaj5apk1ls0q2y492wsh62kl529jp518v4b";
+  };
+in
+  callPackage "${src}/ristretto.nix" { }
diff --git a/stack-shell.nix b/stack-shell.nix
new file mode 100644
index 0000000..8800cbb
--- /dev/null
+++ b/stack-shell.nix
@@ -0,0 +1,17 @@
+# This is intended to be used as the shell-file for the stack configuration.
+# It sets up the non-Haskell parts of the stack build environment.
+{ ghc }:
+let
+  pkgs = import <nixpkgs> { };
+  # Get our Ristretto bindings.
+  ristretto = pkgs.callPackage ./ristretto.nix { };
+in
+  # This is what you're supposed to call in a stack shell-file.  I don't
+  # *really* know what it does but I know it works...
+  pkgs.haskell.lib.buildStackProject {
+    inherit ghc;
+    name = "PrivacyPass";
+    # zlib is a common dependency of many of our dependencies.  and we put our
+    # ristretto library in as well.
+    buildInputs = [ pkgs.zlib ristretto ];
+  }
diff --git a/stack.yaml b/stack.yaml
index 68525a9..82ee2a9 100644
--- a/stack.yaml
+++ b/stack.yaml
@@ -64,3 +64,7 @@ extra-deps:
 #
 # Allow a newer minor version of GHC than the snapshot specifies
 # compiler-check: newer-minor
+
+nix:
+  enable: true
+  shell-file: "stack-shell.nix"
-- 
GitLab