FIX: Flake and Module for NixOS deployment #3363
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix LNBits NixOS Service Module for Python Virtual Environment Package
Problem
The current LNBits NixOS service module (
nix/modules/lnbits-service.nix) has several issues that prevent it from working with the flake-built Python virtual environment package:srcattribute: The module expectscfg.package.srcbut the flake builds a Python virtual environment package that doesn't have asrcattributelib.getExeresolves to the wrong binary name (lnbits-envinstead oflnbits)Solution
This PR fixes the service module to work correctly with the virtual environment package structure produced by the flake.
Changes Made
1. Removed dependency on non-existent
srcattribute- LNBITS_PATH = "${cfg.package.src}";The
LNBITS_PATHenvironment variable was removed as it references a non-existentsrcattribute.2. Fixed working directory to point to installed Python package
LNBits needs to run from the directory containing its static files and templates. In the virtual environment package, these are located in the site-packages directory.
3. Fixed binary path resolution
The
lib.getExefunction was incorrectly resolving tolnbits-env(the package name) instead of the actuallnbitsbinary. Using the explicit path ensures the correct binary is executed.4. Fixed StateDirectory to use relative path
Changed to use the relative path "lnbits" which systemd will automatically create under
/var/lib/.5. Proper data folder structure
Fixed the folder structure to properly separate data and extensions:
${stateDir}/data${stateDir}/extensions(LNBits automatically appends/extensionsto the path)LNBITS_EXTENSIONS_PATHis set to${stateDir}because LNBits internally appends/extensionsto this pathTesting
The fixed service module has been tested in a NixOS VM with the following results:
✅ Service starts successfully
✅ Web interface accessible at configured port
✅ Database migrations run correctly
✅ Static files and templates load properly
Test Configuration Used
Verification Commands
Impact
This fix enables users to:
Backwards Compatibility
These changes maintain backwards compatibility with existing configurations. The service interface remains unchanged - only the internal implementation is fixed to work with the virtual environment package structure.
Related Issues
This fixes the error encountered when using the flake's NixOS module:
Additional Notes
The Python version (3.12) is currently hardcoded in the working directory path. A future improvement could make this dynamic based on the Python version used by the package.