# Define a function which returns a value which fills in all the holes left by
# ``storage.nix``.
{
  # See ``customize-issuer.nix``
  ristrettoSigningKeyPath
, monitoringvpnKeyDir
, monitoringvpnEndpoint
, monitoringvpnIPv4
, sshUsers

  # An integer giving the value of a single pass in byte×months.
, passValue

  # An integer giving the port number to include in Tahoe storage service
  # advertisements and on which to listen for storage connections.
, publicStoragePort

  # XXX To be removed
, publicIPv4

  # A string giving the NixOS state version for the system.
, stateVersion
, ...
}: {
  deployment.secrets = {
    "ristretto-signing-key".source = ristrettoSigningKeyPath;
    "monitoringvpn-secret-key".source = "${monitoringvpnKeyDir}/${monitoringvpnIPv4}.key";
    "monitoringvpn-preshared-key".source = "${monitoringvpnKeyDir}/preshared.key";
  };

  services.private-storage = {
    inherit sshUsers publicIPv4 passValue publicStoragePort;
  };

  services.private-storage.monitoring.vpn.client = {
    enable = true;
    ip = monitoringvpnIPv4;
    endpoint = monitoringvpnEndpoint;
    endpointPublicKeyFile = "${monitoringvpnKeyDir}/server.pub";
  };

  system.stateVersion = stateVersion;
}