From 62835d00b6624feb2423f2a4e6dce519e182b6ec Mon Sep 17 00:00:00 2001
From: Jean-Paul Calderone <exarkun@twistedmatrix.com>
Date: Fri, 25 Oct 2019 13:57:28 -0400
Subject: [PATCH] Refactor to improve reusability

---
 morph/grid.nix                             |  5 ++++-
 morph/{storage000.nix => make-storage.nix} | 19 ++++++++-----------
 2 files changed, 12 insertions(+), 12 deletions(-)
 rename morph/{storage000.nix => make-storage.nix} (80%)

diff --git a/morph/grid.nix b/morph/grid.nix
index c6de769a..2c3aabec 100644
--- a/morph/grid.nix
+++ b/morph/grid.nix
@@ -19,6 +19,9 @@ import ./make-grid.nix {
 
     # Pass the whole grid configuration to the module and let it take what it
     # wants.
-    "storage000" = import ./storage000.nix cfg;
+    "storage000" = import ./make-storage.nix ({
+        cfg = import ./storage000-config.nix;
+        hardware = ./storage000-hardware.nix;
+    } // cfg);
   };
 }
diff --git a/morph/storage000.nix b/morph/make-storage.nix
similarity index 80%
rename from morph/storage000.nix
rename to morph/make-storage.nix
index cd2b6c1f..97c6d89b 100644
--- a/morph/storage000.nix
+++ b/morph/make-storage.nix
@@ -1,12 +1,9 @@
-let
-  # Get the configuration that's specific to this node.
-  cfg = import ./storage000-config.nix;
-in
-# Define the function that defines the node.  Accept the public storage server
-# port argument so we can configure Tahoe-LAFS with it.  Accept but ignore any
-# other arguments.
-{ publicStoragePort, ristrettoSigningKeyPath, ... }: rec {
-
+# Define the function that defines the node.
+{ cfg                        # Get the configuration that's specific to this node.
+, hardware                   # The path to the hardware configuration for this node.
+, publicStoragePort          # The storage port number on which to accept connections.
+, ristrettoSigningKeyPath    # The *local* path to the Ristretto signing key file.
+}: rec {
   deployment = {
     secrets = {
       "ristretto-signing-key" = {
@@ -26,7 +23,7 @@ in
   # Any extra NixOS modules to load on this server.
   imports = [
     # Include the results of the hardware scan.
-    ./storage000-hardware.nix
+    hardware
     # Configure it as a system operated by 100TB.
     ../nixos/modules/100tb.nix
     # Bring in our module for configuring the Tahoe-LAFS service and other
@@ -58,5 +55,5 @@ in
   # compatible, in order to avoid breaking some software such as database
   # servers. You should change this only after NixOS release notes say you
   # should.
-  system.stateVersion = "19.03"; # Did you read the comment?
+  system.stateVersion = "19.09"; # Did you read the comment?
 }
-- 
GitLab