consolidated options

This commit is contained in:
John Lancaster
2026-07-01 00:19:17 -05:00
parent 43fe37d4e2
commit b13b774738
2 changed files with 69 additions and 16 deletions
+59 -4
View File
@@ -1,10 +1,65 @@
{ self, inputs, ... }: { { self, inputs, ... }: {
flake.modules.nixos.restic-server = { config, pkgs, lib, ... }: { flake.modules.nixos.restic-server = { config, pkgs, lib, ... }:
let
cfg = config.resticServer;
port = builtins.fromJSON (lib.last (lib.splitString ":" cfg.listenAddress));
in {
options.resticServer = {
enable = lib.mkEnableOption "Enable the RESTic REST server";
dataDir = lib.mkOption {
description = "Storage directory for RESTic repositories served by this host.";
type = lib.types.str;
default = "/mnt/restic";
};
listenAddress = lib.mkOption {
description = "Listen address for the RESTic REST server.";
type = lib.types.str;
default = "0.0.0.0:8080";
};
privateRepos = lib.mkOption {
description = "Whether the RESTic server should use private repository mode.";
type = lib.types.bool;
default = true;
};
extraFlags = lib.mkOption {
description = "Additional flags to pass to the RESTic REST server before TLS flags are appended.";
type = lib.types.listOf lib.types.str;
default = [ "--no-auth" ];
};
tls = {
certFile = lib.mkOption {
description = "Path to the TLS certificate file for the RESTic REST server, or null to disable TLS.";
type = lib.types.nullOr lib.types.str;
default = null;
};
keyFile = lib.mkOption {
description = "Path to the TLS private key file for the RESTic REST server, or null to disable TLS.";
type = lib.types.nullOr lib.types.str;
default = null;
};
};
};
config = lib.mkIf cfg.enable {
networking.firewall.allowedTCPPorts = [ port ];
services.restic.server = { services.restic.server = {
enable = true; enable = true;
dataDir = "/mnt/restic"; inherit (cfg) dataDir listenAddress privateRepos;
listenAddress = "0.0.0.0:8080"; extraFlags =
extraFlags = [ "--no-auth" ]; cfg.extraFlags
++ lib.optionals (cfg.tls.certFile != null && cfg.tls.keyFile != null) [
"--tls"
"--tls-cert=${cfg.tls.certFile}"
"--tls-key=${cfg.tls.keyFile}"
];
};
}; };
}; };
+7 -9
View File
@@ -16,7 +16,7 @@ in
nixos.mtls nixos.mtls
nixos.janus-ca nixos.janus-ca
nixos.forgejo nixos.forgejo
# nixos.restic-server nixos.restic-server
# nixos.restic-envoy # nixos.restic-envoy
({ config, pkgs, ... }: { ({ config, pkgs, ... }: {
networking.hostName = hostname; networking.hostName = hostname;
@@ -58,17 +58,15 @@ in
port = 443; port = 443;
}; };
networking.firewall.allowedTCPPorts = [ 8000 ]; resticServer = {
services.restic.server = {
enable = true; enable = true;
dataDir = "/mnt/restic";
privateRepos = true; privateRepos = true;
listenAddress = "0.0.0.0:8000"; listenAddress = "0.0.0.0:8000";
extraFlags = [ tls = {
"--no-auth" certFile = config.mtls.certFile;
"--tls" keyFile = config.mtls.keyFile;
"--tls-cert=${config.mtls.certFile}" };
"--tls-key=${config.mtls.keyFile}"
];
}; };
loginText.extraServiceStatus = { loginText.extraServiceStatus = {