mkModule various + fixes
This commit is contained in:
@@ -6,28 +6,26 @@
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.${namespace}.services.restic;
|
||||
in
|
||||
{
|
||||
imports = [ ./options.nix ];
|
||||
name = "restic";
|
||||
cfg = config.${namespace}.services.${name};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
# Configure the standard NixOS restic server service
|
||||
services.restic.server = {
|
||||
enable = true;
|
||||
dataDir = cfg.dataDir;
|
||||
prometheus = cfg.prometheus;
|
||||
listenAddress = "${cfg.listenAddress}:${toString cfg.port}";
|
||||
extraFlags = cfg.extraFlags;
|
||||
}
|
||||
// optionalAttrs (cfg.htpasswdFile != null) {
|
||||
htpasswd-file = cfg.htpasswdFile;
|
||||
};
|
||||
|
||||
# Open firewall for restic server if enabled
|
||||
networking.firewall = mkIf cfg.openFirewall {
|
||||
allowedTCPPorts = [ cfg.port ];
|
||||
allowedUDPPorts = [ cfg.port ];
|
||||
resticConfig = lib.${namespace}.mkModule {
|
||||
inherit config name;
|
||||
description = "restic";
|
||||
options = { };
|
||||
moduleConfig = {
|
||||
# Configure the standard NixOS restic server service
|
||||
services.restic.server = {
|
||||
enable = true;
|
||||
dataDir = "${cfg.dataDir}/backup/restic";
|
||||
prometheus = true;
|
||||
listenAddress = "${cfg.listenAddress}:${toString cfg.port}";
|
||||
htpasswd-file = "${cfg.dataDir}/backup/restic/.htpasswd";
|
||||
extraFlags = [ "--no-auth" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [ resticConfig ];
|
||||
}
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
{ lib, namespace, ... }:
|
||||
with lib;
|
||||
{
|
||||
options.${namespace}.services.restic = {
|
||||
enable = mkEnableOption "restic server with enhanced configuration";
|
||||
|
||||
port = mkOption {
|
||||
type = types.port;
|
||||
default = 8008;
|
||||
description = "Port for restic server";
|
||||
};
|
||||
|
||||
openFirewall = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Whether to open firewall for restic server";
|
||||
};
|
||||
|
||||
dataDir = mkOption {
|
||||
type = types.str;
|
||||
default = "/var/lib/restic";
|
||||
description = "Data directory for restic server";
|
||||
};
|
||||
|
||||
listenAddress = mkOption {
|
||||
type = types.str;
|
||||
default = "0.0.0.0";
|
||||
description = "Address to bind restic server to";
|
||||
};
|
||||
|
||||
prometheus = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = "Whether to enable prometheus metrics";
|
||||
};
|
||||
|
||||
htpasswdFile = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = "Path to htpasswd file for authentication";
|
||||
};
|
||||
|
||||
extraFlags = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = "Extra flags to pass to restic server";
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user