Add package and extensions options
- package: allows overriding the fava package - extensions: list of Python packages to include as fava extensions (e.g., fava-dashboards). Automatically added to fava's Python environment via overridePythonAttrs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
523019b00d
commit
1c7daeef9c
1 changed files with 21 additions and 1 deletions
22
fava.nix
22
fava.nix
|
|
@ -5,10 +5,30 @@ with lib;
|
|||
let
|
||||
cfg = config.services.fava;
|
||||
|
||||
# Build fava with extensions included in its Python environment
|
||||
favaWithExtensions = if cfg.extensions == [] then cfg.package else
|
||||
cfg.package.overridePythonAttrs (old: {
|
||||
propagatedBuildInputs = (old.propagatedBuildInputs or []) ++ cfg.extensions;
|
||||
});
|
||||
|
||||
in {
|
||||
options.services.fava = {
|
||||
enable = mkEnableOption "Fava web interface for Beancount";
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.fava;
|
||||
defaultText = literalExpression "pkgs.fava";
|
||||
description = "The fava package to use";
|
||||
};
|
||||
|
||||
extensions = mkOption {
|
||||
type = types.listOf types.package;
|
||||
default = [];
|
||||
description = "Python packages to include as fava extensions";
|
||||
example = literalExpression "[ pkgs.python3Packages.fava-dashboards ]";
|
||||
};
|
||||
|
||||
ledgerFile = mkOption {
|
||||
type = types.path;
|
||||
default = "/var/lib/fava/ledger.beancount";
|
||||
|
|
@ -103,7 +123,7 @@ in {
|
|||
Group = cfg.group;
|
||||
WorkingDirectory = cfg.dataDir;
|
||||
|
||||
ExecStart = "${pkgs.fava}/bin/fava ${cfg.ledgerFile} --host ${cfg.host} --port ${toString cfg.port} ${concatStringsSep " " cfg.extraOptions}";
|
||||
ExecStart = "${favaWithExtensions}/bin/fava ${cfg.ledgerFile} --host ${cfg.host} --port ${toString cfg.port} ${concatStringsSep " " cfg.extraOptions}";
|
||||
|
||||
Restart = "on-failure";
|
||||
RestartSec = "5s";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue