Refactor LNBits configuration to utilize flake imports and enhance modularity

Updated the lnbits.nix configuration to import the LNBits service module from a flake, improving maintainability and alignment with deployment practices. Adjusted the shared configuration to make the 'domain' parameter accessible to all imported modules, and removed the deprecated lnbits-service.nix file to streamline the setup.
This commit is contained in:
padreug 2025-10-11 10:28:58 +02:00
parent 30209458f7
commit aa0381c42b
4 changed files with 18 additions and 131 deletions

View file

@ -1,6 +1,14 @@
{ domain, pkgs, ... }:
{ domain, pkgs, config, lib, ... }:
let
lnbitsFlake = builtins.getFlake "path:/var/src/lnbits-src";
in
{
# Import the LNBits service module directly from the flake's nix/modules directory
imports = [
/var/src/lnbits-src/nix/modules/lnbits-service.nix
];
# LNBits service configuration
services.lnbits = {
enable = true;
@ -8,9 +16,12 @@
port = 5000;
openFirewall = true;
stateDir = "/var/lib/lnbits";
# Use lnbits from deployed flake source at /var/src/lnbits-src
package = (builtins.getFlake "path:/var/src/lnbits-src").packages.${pkgs.system}.lnbits;
# Use lnbits package from the flake
package = lnbitsFlake.packages.${pkgs.system}.lnbits;
env = {
# Custom extensions path (if deployed via krops)
# Extensions from /var/src/lnbits-extensions will be symlinked to /var/lib/lnbits/extensions
# LNBITS_EXTENSIONS_PATH = "/var/lib/lnbits/extensions";
LNBITS_ADMIN_UI = "true";
AUTH_ALLOWED_METHODS = "user-id-only, username-password";
LNBITS_BACKEND_WALLET_CLASS = "FakeWallet";
@ -87,9 +98,9 @@
# This will DELETE any extensions installed via the LNBits UI.
#
# Option 1: Replace extensions directory entirely (use with caution)
# systemd.tmpfiles.rules = [
# "L+ /var/lib/lnbits/extensions - - - - /var/src/lnbits-extensions"
# ];
systemd.tmpfiles.rules = [
"L+ /var/lib/lnbits/extensions - - - - /var/src/lnbits-extensions"
];
#
# Option 2: Manually merge deployed extensions with existing ones
# Copy deployed extensions into the extensions directory without replacing it: