mkModule various + fixes

This commit is contained in:
mjallen18
2025-12-18 17:20:21 -06:00
parent e0b1e72431
commit 05486efb75
14 changed files with 200 additions and 398 deletions

View File

@@ -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 ];
}