diff --git a/morph/staging000.nix b/morph/staging000.nix index cf726b457475c0f8d5a05f9f0a6a44ce711fe960..592c124b9bdee754dc515f6a15e8c1cb6bcc971b 100644 --- a/morph/staging000.nix +++ b/morph/staging000.nix @@ -4,9 +4,9 @@ ../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 ]; + services.private-storage = + { enable = true; + inherit publicIPv4; + inherit publicStoragePort; + }; } diff --git a/morph/staging001.nix b/morph/staging001.nix index 488fc907e6a62a3d3b0f31062c07d0f23849a052..873d8d35a8c8bc303e9180c340eea784abdcbd3d 100644 --- a/morph/staging001.nix +++ b/morph/staging001.nix @@ -1,11 +1,7 @@ -# Edit this configuration file to define what should be installed on -# your system. Help is available in the configuration.nix(5) man page -# and in the NixOS manual (accessible by running ‘nixos-help’). +{ publicIPv4, publicStoragePort }: { config, pkgs, ... }: - -{ - imports = +{ imports = [ # Include the results of the hardware scan. ./staging001-hardware.nix ]; @@ -27,7 +23,7 @@ # Provide the static network configuration. networking.interfaces = { enp2s0f0.ipv4.addresses = [ - { address = "209.95.51.251"; prefixLength = 24; } + { address = publicIPv4; prefixLength = 24; } ]; }; networking.defaultGateway = { diff --git a/nixos/modules/private-storage.nix b/nixos/modules/private-storage.nix index ae0eb077abeb1098e40ae41442d50fbe2ea8981e..dc83150f12b5bb04225db7b64c497135557f02cc 100644 --- a/nixos/modules/private-storage.nix +++ b/nixos/modules/private-storage.nix @@ -33,20 +33,20 @@ in The package to use for the Tahoe-LAFS daemon. ''; }; - services.private-storage.tahoe.node."tub.port" = lib.mkOption - { default = "disabled"; + services.private-storage.publicIPv4 = lib.mkOption + { default = "127.0.0.1"; type = lib.types.str; - example = lib.literalExample "tcp:8098"; + example = lib.literalExample "192.0.2.0"; description = '' - A value for the [node]tub.port in tahoe.cfg. + An IPv4 address to advertise for this storage service. ''; }; - services.private-storage.tahoe.node."tub.location" = lib.mkOption - { default = "disabled"; - type = lib.types.str; - example = lib.literalExample "tcp:192.0.2.0:8098"; + services.private-storage.publicStoragePort = lib.mkOption + { default = 8898; + type = lib.types.int; + example = lib.literalExample 8098; description = '' - A value for the [node]tub.location in tahoe.cfg. + The port number on which to service storage clients. ''; }; }; @@ -58,8 +58,8 @@ in # XXX Should try to name that is unique across the grid. { nickname = "storage"; "web.port" = "tcp:3456:interface=127.0.0.1"; - "tub.port" = cfg.tahoe.node."tub.port"; - "tub.location" = cfg.tahoe.node."tub.location"; + "tub.port" = "tcp:${toString cfg.publicStoragePort}"; + "tub.location" = "tcp:${cfg.publicIPv4}:${toString cfg.publicStoragePort}"; }; storage = { enabled = true; @@ -70,5 +70,7 @@ in }; }; }; + networking.firewall.allowedTCPPorts = [ cfg.publicStoragePort ]; + }; }