Refactor flake.nix and NixOS module for lidarr-mb-gap
- Updated `flake.nix` to simplify package and app definitions by using `inherit` for better readability. - Removed the `EXAMPLE_CONFIG.nix` file to streamline the project structure, as it was no longer needed. - Enhanced `nixos/lidarr-mb-gap.nix` to improve the import process for the source configuration, ensuring clarity and maintainability.
This commit is contained in:
@@ -1,145 +0,0 @@
|
||||
# ============================================================================
|
||||
# Example NixOS Configuration for lidarr-mb-gap
|
||||
# ============================================================================
|
||||
#
|
||||
# Choose one of the examples below based on your setup:
|
||||
# - Example 1: Using flake input (recommended)
|
||||
# - Example 2: Using source path directly
|
||||
# - Example 3: Minimal configuration
|
||||
#
|
||||
# ============================================================================
|
||||
|
||||
# ============================================================================
|
||||
# EXAMPLE 1: Using Flake Input (Recommended)
|
||||
# ============================================================================
|
||||
#
|
||||
# First, add to your flake.nix inputs:
|
||||
# inputs.lidarr-mb-gap.url = "path:/path/to/lidarr-musicbrainz";
|
||||
# # or
|
||||
# inputs.lidarr-mb-gap.url = "github:yourusername/lidarr-musicbrainz";
|
||||
#
|
||||
# Then in your NixOS configuration:
|
||||
|
||||
{ pkgs, inputs, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
inputs.lidarr-mb-gap.nixosModules.lidarr-mb-gap
|
||||
];
|
||||
|
||||
services.lidarr-mb-gap = {
|
||||
enable = true;
|
||||
|
||||
# Reference the package from the flake
|
||||
package = inputs.lidarr-mb-gap.packages.${pkgs.system}.lidarr-mb-gap;
|
||||
|
||||
# Report settings
|
||||
reportDir = "/var/lib/lidarr-mb-gap/reports";
|
||||
envFile = "/var/lib/lidarr-mb-gap/.env";
|
||||
runInterval = "daily"; # Options: "daily", "hourly", "*-*-* 02:00:00"
|
||||
|
||||
# Optional: Auto-sync to VPS
|
||||
syncToVPS = true;
|
||||
vpsHost = "user@vps"; # Your SSH host alias or "user@vps.example.com"
|
||||
vpsPath = "/var/www/html";
|
||||
|
||||
# SSH configuration for VPS sync
|
||||
sshKeyFile = "/var/lib/lidarr-mb-gap/.ssh/id_ed25519";
|
||||
sshKnownHosts = {
|
||||
vps = {
|
||||
hostNames = [ "vps" "vps.example.com" "1.2.3.4" ]; # All possible hostnames/IPs
|
||||
# Get this with: ssh-keyscan -t ed25519 vps.example.com
|
||||
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI...";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# EXAMPLE 2: Using Source Path (Non-Flake)
|
||||
# ============================================================================
|
||||
#
|
||||
# If you're not using flakes, import the module directly:
|
||||
|
||||
{ ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
/path/to/lidarr-musicbrainz/nixos/lidarr-mb-gap.nix
|
||||
];
|
||||
|
||||
services.lidarr-mb-gap = {
|
||||
enable = true;
|
||||
|
||||
# Build from source
|
||||
src = /path/to/lidarr-musicbrainz/src;
|
||||
|
||||
# Report settings
|
||||
reportDir = "/var/lib/lidarr-mb-gap/reports";
|
||||
envFile = "/var/lib/lidarr-mb-gap/.env";
|
||||
runInterval = "daily";
|
||||
|
||||
# Optional: Auto-sync to VPS
|
||||
syncToVPS = true;
|
||||
vpsHost = "user@vps";
|
||||
vpsPath = "/var/www/html";
|
||||
sshKeyFile = "/var/lib/lidarr-mb-gap/.ssh/id_ed25519";
|
||||
sshKnownHosts = {
|
||||
vps = {
|
||||
hostNames = [ "vps" "vps.example.com" ];
|
||||
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI...";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# EXAMPLE 3: Minimal Configuration (No VPS Sync)
|
||||
# ============================================================================
|
||||
|
||||
{ pkgs, inputs, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
inputs.lidarr-mb-gap.nixosModules.lidarr-mb-gap
|
||||
];
|
||||
|
||||
services.lidarr-mb-gap = {
|
||||
enable = true;
|
||||
package = inputs.lidarr-mb-gap.packages.${pkgs.system}.lidarr-mb-gap;
|
||||
# All other options use defaults
|
||||
};
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# SETUP STEPS AFTER ADDING CONFIGURATION
|
||||
# ============================================================================
|
||||
#
|
||||
# 1. Create the .env file:
|
||||
# sudo mkdir -p /var/lib/lidarr-mb-gap
|
||||
# sudo nano /var/lib/lidarr-mb-gap/.env
|
||||
#
|
||||
# Add:
|
||||
# LIDARR_URL=http://your-lidarr-instance:8686
|
||||
# LIDARR_API_KEY=your-api-key-here
|
||||
# SAMBL_URL=https://sambl.lioncat6.com
|
||||
# MAX_ARTISTS=0
|
||||
#
|
||||
# 2. Set permissions:
|
||||
# sudo chown -R lidarr-mb-gap:lidarr-mb-gap /var/lib/lidarr-mb-gap
|
||||
# sudo chmod 600 /var/lib/lidarr-mb-gap/.env
|
||||
#
|
||||
# 3. If using VPS sync, set up SSH keys:
|
||||
# sudo -u lidarr-mb-gap ssh-keygen -t ed25519 -f /var/lib/lidarr-mb-gap/.ssh/id_ed25519 -N ""
|
||||
# sudo -u lidarr-mb-gap cat /var/lib/lidarr-mb-gap/.ssh/id_ed25519.pub | ssh user@vps "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
|
||||
# ssh-keyscan -t ed25519 vps.example.com # Use output in sshKnownHosts
|
||||
#
|
||||
# 4. Rebuild:
|
||||
# sudo nixos-rebuild switch
|
||||
#
|
||||
# 5. Test:
|
||||
# sudo systemctl start lidarr-mb-gap
|
||||
# sudo journalctl -u lidarr-mb-gap -f
|
||||
#
|
||||
# ============================================================================
|
||||
|
||||
@@ -16,7 +16,7 @@ let
|
||||
else if config.services.lidarr-mb-gap.src != null then
|
||||
import ../nix/package.nix {
|
||||
inherit pkgs;
|
||||
src = config.services.lidarr-mb-gap.src;
|
||||
inherit (config.services.lidarr-mb-gap) src;
|
||||
}
|
||||
else
|
||||
throw "services.lidarr-mb-gap: Either 'package' or 'src' must be set.";
|
||||
|
||||
Reference in New Issue
Block a user