Create NixOS module

This commit is contained in:
2025-04-01 17:28:33 +02:00
parent aab323d746
commit 8359e159f4
2 changed files with 56 additions and 1 deletions

View File

@@ -20,6 +20,9 @@
};
})
// {
nixosModules = rec {};
nixosModules = rec {
actual-importer = import ./module.nix self;
default = actual-importer;
};
};
}

52
module.nix Normal file
View File

@@ -0,0 +1,52 @@
self: {
config,
pkgs,
lib,
system,
...
}: let
cfg = config.programs.actual-importer;
appConfig = (pkgs.formats.yaml {}).generate "actual-importer.config.yaml" cfg.config;
app = pkgs.writeShellApplication {
name = "actual-importer";
runtimeInputs = [self.packages.${system}.default];
text = ''
actual-importer -c "${appConfig}" "$@";
'';
};
in
with lib; {
options.programs.actual-importer = {
enable = mkEnableOption "actual-importer";
config = mkOption {
type = types.attrs;
description = "The actual-importer config which will be eventually converted to yaml";
example = {
defaultProfile = "my-bank";
profiles = {
my-bank = {
parser = "pl.ing";
};
};
defaultServer = "main-server";
servers = {
mainServer = {
url = "https://my-server.com";
budget = "db353760-33d5-4a2a-ab73-5070a6863fe5";
account = "60b953ad-ce6c-4427-b727-bf37b4b6dd1b";
password = "$__file:/etc/passwords/actual.key";
data = "/tmp/actual";
};
};
};
};
};
config = mkIf cfg.enable {
environment.systemPackages = [app];
};
}