consolidated options
This commit is contained in:
@@ -1,10 +1,65 @@
|
||||
{ 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 = {
|
||||
enable = true;
|
||||
dataDir = "/mnt/restic";
|
||||
listenAddress = "0.0.0.0:8080";
|
||||
extraFlags = [ "--no-auth" ];
|
||||
inherit (cfg) dataDir listenAddress privateRepos;
|
||||
extraFlags =
|
||||
cfg.extraFlags
|
||||
++ lib.optionals (cfg.tls.certFile != null && cfg.tls.keyFile != null) [
|
||||
"--tls"
|
||||
"--tls-cert=${cfg.tls.certFile}"
|
||||
"--tls-key=${cfg.tls.keyFile}"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ in
|
||||
nixos.mtls
|
||||
nixos.janus-ca
|
||||
nixos.forgejo
|
||||
# nixos.restic-server
|
||||
nixos.restic-server
|
||||
# nixos.restic-envoy
|
||||
({ config, pkgs, ... }: {
|
||||
networking.hostName = hostname;
|
||||
@@ -58,17 +58,15 @@ in
|
||||
port = 443;
|
||||
};
|
||||
|
||||
networking.firewall.allowedTCPPorts = [ 8000 ];
|
||||
services.restic.server = {
|
||||
resticServer = {
|
||||
enable = true;
|
||||
dataDir = "/mnt/restic";
|
||||
privateRepos = true;
|
||||
listenAddress = "0.0.0.0:8000";
|
||||
extraFlags = [
|
||||
"--no-auth"
|
||||
"--tls"
|
||||
"--tls-cert=${config.mtls.certFile}"
|
||||
"--tls-key=${config.mtls.keyFile}"
|
||||
];
|
||||
tls = {
|
||||
certFile = config.mtls.certFile;
|
||||
keyFile = config.mtls.keyFile;
|
||||
};
|
||||
};
|
||||
|
||||
loginText.extraServiceStatus = {
|
||||
|
||||
Reference in New Issue
Block a user