Refactor Nix package definition and enhance README for lidarr-mb-gap

- Updated `flake.nix` to import the new Nix package definition from `nix/package.nix`, streamlining the build process for the lidarr-mb-gap application.
- Enhanced the README.md to include new features such as NixOS module support for automated deployment, detailed deployment instructions, and configuration options for SSH and output directories.
- Added sections for troubleshooting output file issues and clarified the structure of the project, including new files for deployment and web serving.
This commit is contained in:
Danilo Reyes
2025-11-11 11:11:47 -06:00
parent e6f96107aa
commit a6d2e7f7df
5 changed files with 216 additions and 21 deletions

View File

@@ -3,6 +3,17 @@
let
reportDir = "/var/lib/lidarr-mb-gap/reports";
envFile = "/var/lib/lidarr-mb-gap/.env";
# Determine which package to use
lidarrMbGapPackage = if config.services.lidarr-mb-gap.package != null
then config.services.lidarr-mb-gap.package
else if config.services.lidarr-mb-gap.src != null
then import ../nix/package.nix {
inherit pkgs;
lib = pkgs.lib;
src = config.services.lidarr-mb-gap.src;
}
else throw "services.lidarr-mb-gap: Either 'package' or 'src' must be set.";
in
{
options.services.lidarr-mb-gap = {
@@ -55,11 +66,35 @@ in
default = "/var/www/html";
description = "Path on VPS where reports should be synced";
};
sshKeyFile = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
description = "Path to SSH private key file for rsync. If null, uses default SSH key location.";
};
sshKnownHosts = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule {
options = {
hostNames = lib.mkOption {
type = lib.types.listOf lib.types.str;
description = "List of hostnames/IPs for this known host";
};
publicKey = lib.mkOption {
type = lib.types.str;
description = "SSH public key for the host";
};
};
});
default = {};
description = "SSH known hosts configuration for the VPS (same format as programs.ssh.knownHosts)";
};
};
config = lib.mkIf config.services.lidarr-mb-gap.enable {
systemd.tmpfiles.rules = [
"d ${config.services.lidarr-mb-gap.reportDir} 0755 lidarr-mb-gap lidarr-mb-gap -"
"d /var/lib/lidarr-mb-gap/.ssh 0700 lidarr-mb-gap lidarr-mb-gap -"
];
users.users.lidarr-mb-gap = {
@@ -70,6 +105,8 @@ in
};
users.groups.lidarr-mb-gap = {};
programs.ssh.knownHosts = config.services.lidarr-mb-gap.sshKnownHosts;
systemd.services.lidarr-mb-gap = {
description = "Generate Lidarr MusicBrainz Gap Report";
@@ -96,7 +133,15 @@ in
# Sync to VPS if enabled
${lib.optionalString (config.services.lidarr-mb-gap.syncToVPS && config.services.lidarr-mb-gap.vpsHost != null) ''
# Set up SSH options
SSH_OPTS=""
${lib.optionalString (config.services.lidarr-mb-gap.sshKeyFile != null) ''
SSH_OPTS="-i ${config.services.lidarr-mb-gap.sshKeyFile}"
''}
# Use SSH options with rsync
${pkgs.rsync}/bin/rsync -avz --delete \
-e "ssh $SSH_OPTS -o StrictHostKeyChecking=yes" \
${config.services.lidarr-mb-gap.reportDir}/ \
${config.services.lidarr-mb-gap.vpsHost}:${config.services.lidarr-mb-gap.vpsPath}/
''}