From 79305788efbf0860d12b47a59ce8c9eec5f34e43 Mon Sep 17 00:00:00 2001
From: Jean-Paul Calderone <exarkun@twistedmatrix.com>
Date: Wed, 28 Aug 2019 14:22:19 -0400
Subject: [PATCH] Single node staging grid configuration on AWS EC2

---
 morph/staging.nix             | 21 +++++++++++++++++++++
 morph/staging000-hardware.nix |  7 +++++++
 morph/staging000.nix          | 12 ++++++++++++
 3 files changed, 40 insertions(+)
 create mode 100644 morph/staging.nix
 create mode 100644 morph/staging000-hardware.nix
 create mode 100644 morph/staging000.nix

diff --git a/morph/staging.nix b/morph/staging.nix
new file mode 100644
index 00000000..d9c5d9f1
--- /dev/null
+++ b/morph/staging.nix
@@ -0,0 +1,21 @@
+let
+  # Pin the deployment package-set to a specific version of nixpkgs.  This is
+  # NixOS 19.03 as of Aug 28 2019.  There's nothing special about it.  It's
+  # just recent at the time of development.  It can be upgraded when there is
+  # value in doing so.
+  pkgs = import (builtins.fetchTarball {
+    url = "https://github.com/NixOS/nixpkgs/archive/3c83ad6ac13b67101cc3e2e07781963a010c1624.tar.gz";
+    sha256 = "0cdq342wrkvkyccygpp1gvwp7hhqg68hljjwld4vjixm901ayy14";
+  }) {};
+in
+{
+  network =  {
+    inherit pkgs;
+    description = "PrivateStorage.io Staging Grid";
+  };
+
+  "staging000" = import ./staging000.nix {
+    publicIPv4 = "3.123.26.90";
+    publicStoragePort = 8898;
+  };
+}
diff --git a/morph/staging000-hardware.nix b/morph/staging000-hardware.nix
new file mode 100644
index 00000000..8eccc4b3
--- /dev/null
+++ b/morph/staging000-hardware.nix
@@ -0,0 +1,7 @@
+{
+  imports = [
+    <nixpkgs/nixos/modules/virtualisation/amazon-image.nix>
+  ];
+
+  config.ec2.hvm = true;
+}
diff --git a/morph/staging000.nix b/morph/staging000.nix
new file mode 100644
index 00000000..cf726b45
--- /dev/null
+++ b/morph/staging000.nix
@@ -0,0 +1,12 @@
+{ publicIPv4, publicStoragePort }:
+{ imports = [
+    ./staging000-hardware.nix
+    ../nixos/modules/private-storage.nix
+  ];
+
+  services.private-storage.enable = true;
+  services.private-storage.tahoe.node."tub.port" = "tcp:${toString publicStoragePort}";
+  services.private-storage.tahoe.node."tub.location" = "tcp:${publicIPv4}:${toString publicStoragePort}";
+
+  networking.firewall.allowedTCPPorts = [ publicStoragePort ];
+}
-- 
GitLab