diff options
author | Jaka Hudoklin <jakahudoklin@gmail.com> | 2015-06-08 12:58:33 +0200 |
---|---|---|
committer | Jaka Hudoklin <jakahudoklin@gmail.com> | 2015-06-08 13:48:23 +0200 |
commit | 2e5dbc474637e092392b376be0c64a37dfc1cc99 (patch) | |
tree | e4437151a3593973381e694a739e59319f0bde26 /nixos/modules/services/misc/ripple-rest.nix | |
parent | cc96e474d3d21969b999865c817a41c44aab3dc3 (diff) | |
download | nixlib-2e5dbc474637e092392b376be0c64a37dfc1cc99.tar nixlib-2e5dbc474637e092392b376be0c64a37dfc1cc99.tar.gz nixlib-2e5dbc474637e092392b376be0c64a37dfc1cc99.tar.bz2 nixlib-2e5dbc474637e092392b376be0c64a37dfc1cc99.tar.lz nixlib-2e5dbc474637e092392b376be0c64a37dfc1cc99.tar.xz nixlib-2e5dbc474637e092392b376be0c64a37dfc1cc99.tar.zst nixlib-2e5dbc474637e092392b376be0c64a37dfc1cc99.zip |
Add ripple rest module
Diffstat (limited to 'nixos/modules/services/misc/ripple-rest.nix')
-rw-r--r-- | nixos/modules/services/misc/ripple-rest.nix | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/nixos/modules/services/misc/ripple-rest.nix b/nixos/modules/services/misc/ripple-rest.nix new file mode 100644 index 000000000000..dc07ee132fa6 --- /dev/null +++ b/nixos/modules/services/misc/ripple-rest.nix @@ -0,0 +1,110 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.services.rippleRest; + + configFile = pkgs.writeText "ripple-rest-config.json" (builtins.toJSON { + config_version = "2.0.3"; + debug = cfg.debug; + port = cfg.port; + host = cfg.host; + ssl_enabled = cfg.ssl.enable; + ssl = { + key_path = cfg.ssl.keyPath; + cert_path = cfg.ssl.certPath; + reject_unathorized = cfg.ssl.rejectUnathorized; + }; + db_path = cfg.dbPath; + max_transaction_fee = cfg.maxTransactionFee; + rippled_servers = cfg.rippleds; + }); + +in { + options.services.rippleRest = { + enable = mkEnableOption "Whether to enable ripple rest."; + + debug = mkEnableOption "Wheter to enable debug for ripple-rest."; + + host = mkOption { + description = "Ripple rest host."; + default = "localhost"; + type = types.str; + }; + + port = mkOption { + description = "Ripple rest port."; + default = 5990; + type = types.int; + }; + + ssl = { + enable = mkEnableOption "Whether to enable ssl."; + + keyPath = mkOption { + description = "Path to the ripple rest key file."; + default = null; + type = types.nullOr types.path; + }; + + + certPath = mkOption { + description = "Path to the ripple rest cert file."; + default = null; + type = types.nullOr types.path; + }; + + rejectUnathorized = mkOption { + description = "Whether to reject unatohroized."; + default = true; + type = types.bool; + }; + }; + + dbPath = mkOption { + description = "Ripple rest database path."; + default = "${cfg.dataDir}/ripple-rest.db"; + type = types.path; + }; + + maxTransactionFee = mkOption { + description = "Ripple rest max transaction fee."; + default = 1000000; + type = types.int; + }; + + rippleds = mkOption { + description = "List of rippled servers."; + default = [ + "wss://s1.ripple.com:443" + ]; + type = types.listOf types.str; + }; + + dataDir = mkOption { + description = "Ripple rest data directory."; + default = "/var/lib/ripple-rest"; + type = types.path; + }; + }; + + config = mkIf (cfg.enable) { + systemd.services.ripple-rest = { + wantedBy = [ "multi-user.target"]; + after = ["network.target" ]; + environment.NODE_PATH="${pkgs.ripple-rest}/lib/node_modules/ripple-rest/node_modules"; + serviceConfig = { + ExecStart = "${pkgs.nodejs}/bin/node ${pkgs.ripple-rest}/lib/node_modules/ripple-rest/server/server.js --config ${configFile}"; + User = "ripple-rest"; + }; + }; + + users.extraUsers.postgres = { + name = "ripple-rest"; + uid = config.ids.uids.ripple-rest; + createHome = true; + home = cfg.dataDir; + }; + }; +} |