diff --git a/flake.nix b/flake.nix index a386a18..6c2a55f 100644 --- a/flake.nix +++ b/flake.nix @@ -20,6 +20,9 @@ }; }) // { - nixosModules = rec {}; + nixosModules = rec { + actual-importer = import ./module.nix self; + default = actual-importer; + }; }; } diff --git a/module.nix b/module.nix new file mode 100644 index 0000000..1762414 --- /dev/null +++ b/module.nix @@ -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]; + }; + }