forked from mirrors/nixpkgs
Merge pull request #6940 from offlinehacker/pkgs/ripple-data-api/add
Add ripple data api package and nixos service
This commit is contained in:
commit
d3c6d4175a
|
@ -211,6 +211,7 @@
|
|||
unifi = 183;
|
||||
uptimed = 184;
|
||||
zope2 = 185;
|
||||
ripple-data-api = 186;
|
||||
|
||||
# When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
|
||||
|
||||
|
@ -399,6 +400,7 @@
|
|||
#unifi = 183; # unused
|
||||
#uptimed = 184; # unused
|
||||
#zope2 = 185; # unused
|
||||
#ripple-data-api = 186; #unused
|
||||
|
||||
# When adding a gid, make sure it doesn't match an existing
|
||||
# uid. Users and groups with the same name should have equal
|
||||
|
|
|
@ -201,6 +201,7 @@
|
|||
./services/misc/phd.nix
|
||||
./services/misc/redmine.nix
|
||||
./services/misc/rippled.nix
|
||||
./services/misc/ripple-data-api.nix
|
||||
./services/misc/rogue.nix
|
||||
./services/misc/siproxd.nix
|
||||
./services/misc/svnserve.nix
|
||||
|
|
168
nixos/modules/services/misc/ripple-data-api.nix
Normal file
168
nixos/modules/services/misc/ripple-data-api.nix
Normal file
|
@ -0,0 +1,168 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.rippleDataApi;
|
||||
|
||||
deployment_env_config = builtins.toJSON {
|
||||
production = {
|
||||
port = toString cfg.port;
|
||||
maxSockets = 150;
|
||||
batchSize = 100;
|
||||
startIndex = 32570;
|
||||
rippleds = cfg.rippleds;
|
||||
redis = {
|
||||
enable = cfg.redis.enable;
|
||||
host = cfg.redis.host;
|
||||
port = cfg.redis.port;
|
||||
options.auth_pass = null;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
db_config = builtins.toJSON {
|
||||
production = {
|
||||
username = optional (cfg.couchdb.pass != "") cfg.couchdb.user;
|
||||
password = optional (cfg.couchdb.pass != "") cfg.couchdb.pass;
|
||||
host = cfg.couchdb.host;
|
||||
port = cfg.couchdb.port;
|
||||
database = cfg.couchdb.db;
|
||||
protocol = "http";
|
||||
};
|
||||
};
|
||||
|
||||
in {
|
||||
options = {
|
||||
services.rippleDataApi = {
|
||||
enable = mkEnableOption "Whether to enable ripple data api.";
|
||||
|
||||
port = mkOption {
|
||||
description = "Ripple data api port";
|
||||
default = 5993;
|
||||
type = types.int;
|
||||
};
|
||||
|
||||
redis = {
|
||||
enable = mkOption {
|
||||
description = "Whether to enable caching of ripple data to redis.";
|
||||
default = true;
|
||||
type = types.bool;
|
||||
};
|
||||
|
||||
host = mkOption {
|
||||
description = "Ripple data api redis host.";
|
||||
default = "localhost";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
description = "Ripple data api redis port.";
|
||||
default = 5984;
|
||||
type = types.int;
|
||||
};
|
||||
};
|
||||
|
||||
couchdb = {
|
||||
host = mkOption {
|
||||
description = "Ripple data api couchdb host.";
|
||||
default = "localhost";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
description = "Ripple data api couchdb port.";
|
||||
default = 5984;
|
||||
type = types.int;
|
||||
};
|
||||
|
||||
db = mkOption {
|
||||
description = "Ripple data api couchdb database.";
|
||||
default = "rippled";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
user = mkOption {
|
||||
description = "Ripple data api couchdb username.";
|
||||
default = "rippled";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
pass = mkOption {
|
||||
description = "Ripple data api couchdb password.";
|
||||
default = "";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
create = mkOption {
|
||||
description = "Whether to create couchdb database needed by ripple data api.";
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
};
|
||||
|
||||
rippleds = mkOption {
|
||||
description = "List of rippleds to be used by ripple data api.";
|
||||
default = [
|
||||
"http://s_east.ripple.com:51234"
|
||||
"http://s_west.ripple.com:51234"
|
||||
];
|
||||
type = types.listOf types.str;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf (cfg.enable) {
|
||||
services.couchdb.enable = mkDefault true;
|
||||
services.couchdb.bindAddress = mkDefault "0.0.0.0";
|
||||
services.redis.enable = mkDefault true;
|
||||
|
||||
systemd.services.ripple-data-api = {
|
||||
after = [ "couchdb.service" "redis.service" "ripple-data-api-importer.service" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
environment = {
|
||||
NODE_ENV = "production";
|
||||
DEPLOYMENT_ENVS_CONFIG = pkgs.writeText "deployment.environment.json" deployment_env_config;
|
||||
DB_CONFIG = pkgs.writeText "db.config.json" db_config;
|
||||
};
|
||||
|
||||
serviceConfig = {
|
||||
ExecStart = "${pkgs.ripple-data-api}/bin/api";
|
||||
User = "ripple-data-api";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.ripple-data-importer = {
|
||||
after = [ "couchdb.service" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
path = [ pkgs.curl ];
|
||||
|
||||
environment = {
|
||||
NODE_ENV = "production";
|
||||
DEPLOYMENT_ENVS_CONFIG = pkgs.writeText "deployment.environment.json" deployment_env_config;
|
||||
DB_CONFIG = pkgs.writeText "db.config.json" db_config;
|
||||
LOG_FILE = "/dev/null";
|
||||
};
|
||||
|
||||
serviceConfig = {
|
||||
ExecStart = "${pkgs.ripple-data-api}/bin/importer live debug2";
|
||||
User = "ripple-data-api";
|
||||
};
|
||||
|
||||
preStart = mkMerge [
|
||||
(mkIf (cfg.couchdb.create) ''
|
||||
HOST="http://${optionalString (cfg.couchdb.pass != "") "${cfg.couchdb.user}:${cfg.couchdb.pass}@"}${cfg.couchdb.host}:${toString cfg.couchdb.port}"
|
||||
curl -X PUT $HOST/${cfg.couchdb.db} || true
|
||||
'')
|
||||
"${pkgs.ripple-data-api}/bin/update-views"
|
||||
];
|
||||
};
|
||||
|
||||
users.extraUsers = singleton
|
||||
{ name = "ripple-data-api";
|
||||
description = "Ripple data api user";
|
||||
uid = config.ids.uids.ripple-data-api;
|
||||
};
|
||||
};
|
||||
}
|
25
pkgs/servers/rippled/data-api.nix
Normal file
25
pkgs/servers/rippled/data-api.nix
Normal file
|
@ -0,0 +1,25 @@
|
|||
{ lib, fetchgit, fetchurl, nodePackages }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
np = nodePackages.override { generated = ./package.nix; self = np; };
|
||||
in nodePackages.buildNodePackage rec {
|
||||
name = "ripple-data-api-${version}";
|
||||
version = lib.strings.substring 0 7 rev;
|
||||
rev = "c56b860105f36c1c44ae011189d495272648c589";
|
||||
|
||||
src = fetchgit {
|
||||
url = https://github.com/ripple/ripple-data-api.git;
|
||||
inherit rev;
|
||||
sha256 = "1iygp26ilradxj268g1l2y93cgrpchqwn71qdag67lv273dbq48m";
|
||||
};
|
||||
|
||||
deps = (filter (v: nixType v == "derivation") (attrValues np));
|
||||
|
||||
meta = {
|
||||
description = "Historical ripple data";
|
||||
homepage = https://github.com/ripple/ripple-data-api;
|
||||
maintainers = with maintainers; [ offline ];
|
||||
};
|
||||
}
|
3909
pkgs/servers/rippled/package.nix
Normal file
3909
pkgs/servers/rippled/package.nix
Normal file
File diff suppressed because it is too large
Load diff
|
@ -8453,6 +8453,8 @@ let
|
|||
boost = boost155;
|
||||
};
|
||||
|
||||
ripple-data-api = callPackage ../servers/rippled/data-api.nix { };
|
||||
|
||||
s6 = callPackage ../servers/s6 { };
|
||||
|
||||
spamassassin = callPackage ../servers/mail/spamassassin {
|
||||
|
|
Loading…
Reference in a new issue