From 348b8db1b319581e52c4cd8f95092f36b697465e Mon Sep 17 00:00:00 2001
From: Tom Prince <tom.prince@private.storage>
Date: Mon, 4 Oct 2021 10:09:53 -0600
Subject: [PATCH] Update zkapauthorizer package to use mach-nix packaging.

---
 nixos/pkgs/default.nix                | 18 +++---------------
 nixos/pkgs/privatestorage/default.nix |  8 ++++++++
 nixos/pkgs/privatestorage/repo.json   |  8 ++++++++
 nixpkgs-ps.json                       |  4 ----
 nixpkgs-ps.nix                        |  1 -
 5 files changed, 19 insertions(+), 20 deletions(-)
 create mode 100644 nixos/pkgs/privatestorage/default.nix
 create mode 100644 nixos/pkgs/privatestorage/repo.json
 delete mode 100644 nixpkgs-ps.json
 delete mode 100644 nixpkgs-ps.nix

diff --git a/nixos/pkgs/default.nix b/nixos/pkgs/default.nix
index 619f69e9..9e98f253 100644
--- a/nixos/pkgs/default.nix
+++ b/nixos/pkgs/default.nix
@@ -4,23 +4,11 @@
 #
 #    pkgs.callPackage ./nixos/pkgs
 {buildPlatform, hostPlatform, callPackage}:
-let
-  # Our own nixpkgs fork:
-  ourpkgs = import ../../nixpkgs-ps.nix {
-    # Ensure that the fork is configured for the same system
-    # as we were called with.
-    localSystem = buildPlatform;
-    crossSystem = hostPlatform;
-    # Ensure that configuration of the system where this runs
-    # doesn't leak into what we build.
-    # See https://github.com/NixOS/nixpkgs/issues/62513
-    config = {};
-    overlays = [];
-  };
-in
 {
-  inherit (ourpkgs) privatestorage;
   leasereport = callPackage ./leasereport {};
+  # `privatestorage` is a derivation with a good Tahoe+ZKAP environment
+  # that is exposed by ZKAPAuthorizer.
+  privatestorage = callPackage ./privatestorage {};
   zkap-spending-service = callPackage ./zkap-spending-service {};
   zkapissuer = callPackage ./zkapissuer {};
 }
diff --git a/nixos/pkgs/privatestorage/default.nix b/nixos/pkgs/privatestorage/default.nix
new file mode 100644
index 00000000..bd487af3
--- /dev/null
+++ b/nixos/pkgs/privatestorage/default.nix
@@ -0,0 +1,8 @@
+{ fetchFromGitHub, callPackage, lib }:
+let
+  repo-data = lib.importJSON ./repo.json;
+  repo = fetchFromGitHub (builtins.removeAttrs repo-data [ "branch" ]);
+  privatestorage = callPackage repo {};
+in
+  privatestorage.privatestorage
+
diff --git a/nixos/pkgs/privatestorage/repo.json b/nixos/pkgs/privatestorage/repo.json
new file mode 100644
index 00000000..f8bf81b5
--- /dev/null
+++ b/nixos/pkgs/privatestorage/repo.json
@@ -0,0 +1,8 @@
+{
+  "owner": "PrivateStorageio",
+  "branch": "main",
+  "repo": "ZKAPAuthorizer",
+  "rev": "c38c42362ac81dad25b4c5bcfe7a5cf0d49e1401",
+  "outputHashAlgo": "sha512",
+  "outputHash": "1pm44ihqn0m2zckmnzdxn7sj6v67m2kaqhpkpv9b48palyd8109ajh818aaj8rw6mlh2k9nrrza39khbqzh1910k8d6dk72ldqkqibl"
+}
diff --git a/nixpkgs-ps.json b/nixpkgs-ps.json
deleted file mode 100644
index 58add307..00000000
--- a/nixpkgs-ps.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{ "name": "nixpkgs"
-, "url": "https://github.com/PrivateStorageio/nixpkgs/archive/5ebd5af2d5c6caf23735c8c0e6bc27357fa8d2a8.tar.gz"
-, "sha256": "1g2bvs8prqjskzv8s1qmh36k7rmj98jib0syqbrq02xxzw5dpqb4"
-}
diff --git a/nixpkgs-ps.nix b/nixpkgs-ps.nix
deleted file mode 100644
index d98a5384..00000000
--- a/nixpkgs-ps.nix
+++ /dev/null
@@ -1 +0,0 @@
-import (builtins.fetchTarball (builtins.fromJSON (builtins.readFile ./nixpkgs-ps.json)))
-- 
GitLab