Compare commits
2 Commits
73ae1787d1
...
0b86143646
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b86143646 | ||
|
|
578b9d316a |
@@ -6,8 +6,7 @@
|
||||
}:
|
||||
|
||||
let
|
||||
reportDir = "/var/lib/lidarr-mb-gap/reports";
|
||||
envFile = "/var/lib/lidarr-mb-gap/.env";
|
||||
defaultHome = "/var/lib/lidarr-mb-gap";
|
||||
|
||||
# Determine which package to use
|
||||
lidarrMbGapPackage =
|
||||
@@ -25,6 +24,12 @@ in
|
||||
options.services.lidarr-mb-gap = {
|
||||
enable = lib.mkEnableOption "Lidarr MusicBrainz Gap Reporter";
|
||||
|
||||
home = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = defaultHome;
|
||||
description = "Home directory for the lidarr-mb-gap user";
|
||||
};
|
||||
|
||||
package = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.package;
|
||||
default = null;
|
||||
@@ -39,13 +44,15 @@ in
|
||||
|
||||
reportDir = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = reportDir;
|
||||
default = "${config.services.lidarr-mb-gap.home}/reports";
|
||||
defaultText = lib.literalExpression ''"''${home}/reports"'';
|
||||
description = "Directory where reports will be generated";
|
||||
};
|
||||
|
||||
envFile = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = envFile;
|
||||
default = "${config.services.lidarr-mb-gap.home}/.env";
|
||||
defaultText = lib.literalExpression ''"''${home}/.env"'';
|
||||
description = "Path to .env file with LIDARR_URL and LIDARR_API_KEY";
|
||||
};
|
||||
|
||||
@@ -72,11 +79,18 @@ in
|
||||
default = "/var/www/html";
|
||||
description = "Path on VPS where reports should be synced";
|
||||
};
|
||||
|
||||
|
||||
vpsPort = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
default = 22;
|
||||
description = "SSH port for VPS connection";
|
||||
};
|
||||
|
||||
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.";
|
||||
type = lib.types.str;
|
||||
default = "${config.services.lidarr-mb-gap.home}/.ssh/id_ed25519";
|
||||
defaultText = lib.literalExpression ''"''${home}/.ssh/id_ed25519"'';
|
||||
description = "Path to SSH private key file for rsync";
|
||||
};
|
||||
|
||||
sshKnownHosts = lib.mkOption {
|
||||
@@ -102,13 +116,13 @@ in
|
||||
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 -"
|
||||
"d ${config.services.lidarr-mb-gap.home}/.ssh 0700 lidarr-mb-gap lidarr-mb-gap -"
|
||||
];
|
||||
|
||||
users.users.lidarr-mb-gap = {
|
||||
isSystemUser = true;
|
||||
group = "lidarr-mb-gap";
|
||||
home = "/var/lib/lidarr-mb-gap";
|
||||
home = config.services.lidarr-mb-gap.home;
|
||||
createHome = true;
|
||||
};
|
||||
|
||||
@@ -144,14 +158,12 @@ in
|
||||
(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}"
|
||||
''}
|
||||
SSH_OPTS="-i ${config.services.lidarr-mb-gap.sshKeyFile}"
|
||||
|
||||
# Use SSH options with rsync (use full path to ssh)
|
||||
${pkgs.rsync}/bin/rsync -avz --delete \
|
||||
-e "${pkgs.openssh}/bin/ssh $SSH_OPTS -o StrictHostKeyChecking=yes" \
|
||||
-e "${pkgs.openssh}/bin/ssh $SSH_OPTS -p ${toString config.services.lidarr-mb-gap.vpsPort} -o \
|
||||
StrictHostKeyChecking=yes" \
|
||||
${config.services.lidarr-mb-gap.reportDir}/ \
|
||||
${config.services.lidarr-mb-gap.vpsHost}:${config.services.lidarr-mb-gap.vpsPath}/
|
||||
''
|
||||
|
||||
Reference in New Issue
Block a user