From 84360968686b236434c7f7f6ea90770e1adb4ae9 Mon Sep 17 00:00:00 2001
From: Jean-Paul Calderone <exarkun@twistedmatrix.com>
Date: Fri, 4 Sep 2020 09:52:16 -0400
Subject: [PATCH] Support passing through pass-value configuration to tahoe.cfg

Also configure a new value on the staging grid
---
 morph/grid/testing/config.json    |  1 +
 nixos/modules/private-storage.nix | 15 ++++++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/morph/grid/testing/config.json b/morph/grid/testing/config.json
index eca13fe1..fb72b913 100644
--- a/morph/grid/testing/config.json
+++ b/morph/grid/testing/config.json
@@ -1,6 +1,7 @@
 { "publicStoragePort": 8898
 , "ristrettoSigningKeyPath": "../../PrivateStorageSecrets/ristretto.signing-key"
 , "stripeSecretKeyPath": "../../PrivateStorageSecrets/privatestorageio-testing-stripe.secret"
+, "pass-value": 1000000
 , "issuerDomain": "payments.privatestorage-staging.com"
 , "letsEncryptAdminEmail": "jean-paul@privatestorage.io"
 , "allowedChargeOrigins": [
diff --git a/nixos/modules/private-storage.nix b/nixos/modules/private-storage.nix
index c454dd2c..0754a072 100644
--- a/nixos/modules/private-storage.nix
+++ b/nixos/modules/private-storage.nix
@@ -78,6 +78,15 @@ in
         The path to the Ristretto signing key for the service.
       '';
     };
+    services.private-storage.passValue = lib.mkOption
+    { default = null;
+      type = lib.types.nullOr lib.types.int;
+      example = lib.literalExample (1000 * 1000);
+      description = ''
+        The bytes component of the bytes×time value of a single pass which
+        storage servers will use when making pricing decisions.
+      '';
+    };
   };
 
   # Define configuration based on values given for our options - starting with
@@ -126,7 +135,11 @@ in
         "storageserver.plugins.privatestorageio-zkapauthz-v1" =
         { "ristretto-issuer-root-url" = cfg.issuerRootURL;
           "ristretto-signing-key-path" = cfg.ristrettoSigningKeyPath;
-        };
+        } // (
+          if cfg.passValue == null
+          then {}
+          else { "pass-value" = (toString cfg.passValue); }
+        );
       };
     };
 
-- 
GitLab