1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-22 13:41:26 +00:00

Merge pull request #11451 from rvl/pump.io

Add Pump.io
This commit is contained in:
Arseniy Seroka 2015-12-06 21:47:42 +03:00
commit 21332223ec
9 changed files with 3302 additions and 0 deletions

View file

@ -237,6 +237,7 @@
calibre-server = 213;
heapster = 214;
bepasty = 215;
pumpio = 216;
# When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
@ -451,6 +452,7 @@
xtreemfs = 212;
calibre-server = 213;
bepasty = 215;
pumpio = 216;
# When adding a gid, make sure it doesn't match an existing
# uid. Users and groups with the same name should have equal

View file

@ -401,6 +401,7 @@
./services/ttys/agetty.nix
./services/ttys/gpm.nix
./services/ttys/kmscon.nix
./services/web-apps/pump.io.nix
./services/web-servers/apache-httpd/default.nix
./services/web-servers/fcgiwrap.nix
./services/web-servers/jboss/default.nix

View file

@ -0,0 +1,364 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.pumpio;
dataDir = "/var/lib/pump.io";
user = "pumpio";
configOptions = {
driver = if cfg.driver == "disk" then null else cfg.driver;
params = ({ } //
(if cfg.driver == "disk" then {
dir = dataDir;
} else { }) //
(if cfg.driver == "mongodb" || cfg.driver == "redis" then {
host = cfg.dbHost;
port = cfg.dbPort;
dbname = cfg.dbName;
dbuser = cfg.dbUser;
dbpass = cfg.dbPassword;
} else { }) //
(if cfg.driver == "memcached" then {
host = cfg.dbHost;
port = cfg.dbPort;
} else { }) //
cfg.driverParams);
secret = cfg.secret;
address = cfg.address;
port = cfg.port;
noweb = false;
urlPort = cfg.urlPort;
hostname = cfg.hostname;
favicon = cfg.favicon;
site = cfg.site;
owner = cfg.owner;
ownerURL = cfg.ownerURL;
key = cfg.sslKey;
cert = cfg.sslCert;
bounce = false;
spamhost = cfg.spamHost;
spamclientid = cfg.spamClientId;
spamclientsecret = cfg.spamClientSecret;
requireEmail = cfg.requireEmail;
smtpserver = cfg.smtpHost;
smtpport = cfg.smtpPort;
smtpuser = cfg.smtpUser;
smtppass = cfg.smtpPassword;
smtpusessl = cfg.smtpUseSSL;
smtpfrom = cfg.smtpFrom;
nologger = false;
uploaddir = "${dataDir}/uploads";
debugClient = false;
firehose = cfg.firehose;
disableRegistration = cfg.disableRegistration;
} //
(if cfg.port < 1024 then {
serverUser = user; # have pump.io listen then drop privileges
} else { }) //
cfg.extraConfig;
in
{
options = {
services.pumpio = {
enable = mkEnableOption "Pump.io social streams server";
secret = mkOption {
type = types.str;
example = "my dog has fleas";
description = ''
A session-generating secret, server-wide password. Warning:
this is stored in cleartext in the Nix store!
'';
};
site = mkOption {
type = types.str;
example = "Awesome Sauce";
description = "Name of the server";
};
owner = mkOption {
type = types.str;
default = "";
example = "Awesome Inc.";
description = "Name of owning entity, if you want to link to it.";
};
ownerURL = mkOption {
type = types.str;
default = "";
example = "https://pump.io";
description = "URL of owning entity, if you want to link to it.";
};
address = mkOption {
type = types.str;
default = "localhost";
description = ''
Web server listen address.
'';
};
port = mkOption {
type = types.int;
default = 31337;
description = ''
Port to listen on. Defaults to 31337, which is suitable for
running behind a reverse proxy. For a standalone server,
use 443.
'';
};
hostname = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
The hostname of the server, used for generating
URLs. Defaults to "localhost" which doesn't do much for you.
'';
};
urlPort = mkOption {
type = types.int;
default = 443;
description = ''
Port to use for generating URLs. This basically has to be
either 80 or 443 because the host-meta and Webfinger
protocols don't make any provision for HTTP/HTTPS servers
running on other ports.
'';
};
favicon = mkOption {
type = types.nullOr types.path;
default = null;
description = ''
Local filesystem path to the favicon.ico file to use. This
will be served as "/favicon.ico" by the server.
'';
};
sslKey = mkOption {
type = types.path;
example = "${dataDir}/myserver.key";
default = "";
description = ''
The path to the server certificate private key. The
certificate is required, but it can be self-signed.
'';
};
sslCert = mkOption {
type = types.path;
example = "${dataDir}/myserver.crt";
default = "";
description = ''
The path to the server certificate. The certificate is
required, but it can be self-signed.
'';
};
firehose = mkOption {
type = types.str;
default = "ofirehose.com";
description = ''
Firehose host running the ofirehose software. Defaults to
"ofirehose.com". Public notices will be ping this firehose
server and from there go out to search engines and the
world. If you want to disconnect from the public web, set
this to something falsy.
'';
};
disableRegistration = mkOption {
type = types.bool;
default = false;
description = ''
Disables registering new users on the site through the Web
or the API.
'';
};
requireEmail = mkOption {
type = types.bool;
default = false;
description = "Require an e-mail address to register.";
};
extraConfig = mkOption {
default = { };
description = ''
Extra configuration options which are serialized to json and added
to the pump.io.json config file.
'';
};
driver = mkOption {
type = types.enum [ "mongodb" "disk" "lrucache" "memcached" "redis" ];
default = "mongodb";
description = "Type of database. Corresponds to a nodejs databank driver.";
};
driverParams = mkOption {
default = { };
description = "Extra parameters for the driver.";
};
dbHost = mkOption {
type = types.str;
default = "localhost";
description = "The database host to connect to.";
};
dbPort = mkOption {
type = types.int;
default = 27017;
description = "The port that the database is listening on.";
};
dbName = mkOption {
type = types.str;
default = "pumpio";
description = "The name of the database to use.";
};
dbUser = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
The username. Defaults to null, meaning no authentication.
'';
};
dbPassword = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
The password corresponding to dbUser. Warning: this is
stored in cleartext in the Nix store!
'';
};
smtpHost = mkOption {
type = types.nullOr types.str;
default = null;
example = "localhost";
description = ''
Server to use for sending transactional email. If it's not
set up, no email is sent and features like password recovery
and email notification won't work.
'';
};
smtpPort = mkOption {
type = types.int;
default = 25;
description = ''
Port to connect to on SMTP server.
'';
};
smtpUser = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
Username to use to connect to SMTP server. Might not be
necessary for some servers.
'';
};
smtpPassword = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
Password to use to connect to SMTP server. Might not be
necessary for some servers. Warning: this is stored in
cleartext in the Nix store!
'';
};
smtpUseSSL = mkOption {
type = types.bool;
default = false;
description = ''
Only use SSL with the SMTP server. By default, a SSL
connection is negotiated using TLS. You may need to change
the smtpPort value if you set this.
'';
};
smtpFrom = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
Email address to use in the "From:" header of outgoing
notifications. Defaults to 'no-reply@' plus the site
hostname.
'';
};
spamHost = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
Host running activityspam software to use to test updates
for spam.
'';
};
spamClientId = mkOption {
type = types.nullOr types.str;
default = null;
description = "OAuth pair for spam server.";
};
spamClientSecret = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
OAuth pair for spam server. Warning: this is
stored in cleartext in the Nix store!
'';
};
};
};
config = mkIf cfg.enable {
systemd.services."pump.io" =
{ description = "pump.io social network stream server";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig.ExecStart = "${pkgs.pumpio}/bin/pump -c /etc/pump.io.json";
serviceConfig.User = if cfg.port < 1024 then "root" else user;
serviceConfig.Group = user;
};
environment.etc."pump.io.json" = {
mode = "0440";
gid = config.ids.gids.pumpio;
text = builtins.toJSON configOptions;
};
users.extraGroups.pumpio.gid = config.ids.gids.pumpio;
users.extraUsers.pumpio = {
group = "pumpio";
uid = config.ids.uids.pumpio;
description = "Pump.io user";
home = dataDir;
createHome = true;
};
};
}

View file

@ -283,6 +283,7 @@ in rec {
tests.peerflix = callTest tests/peerflix.nix {};
tests.printing = callTest tests/printing.nix {};
tests.proxy = callTest tests/proxy.nix {};
tests.pumpio = callTest tests/pump.io.nix {};
tests.quake3 = callTest tests/quake3.nix {};
tests.runInMachine = callTest tests/run-in-machine.nix {};
tests.sddm = callTest tests/sddm.nix {};

94
nixos/tests/pump.io.nix Normal file
View file

@ -0,0 +1,94 @@
# This test runs pump.io with mongodb, listing on port 443.
import ./make-test.nix ({ pkgs, ...} : let
snakeOilKey = ''
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCqVemio78R41Tz
MnR2zFD/wFT0iScOpFkuytNmuPf28FLaa9wSBWmuAGbEi7wBIfw8/bUqFBTQp2G1
m1cmcCKxhmvvOkGs89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QsFAAOCAQEAd2w9rxi6qF9WV8L3rHnTE7uu0ldtdgJlCASx6ouj
TleOnjfEg+kH8r8UbmRV5vsTDn1Qp5JGDYxfytRUQwLb1zTLde0xotx37E3LY8Wr
sD6Al4t8sHywB/hc5dy29TgG0iyG8LKZrkwytLvDZ814W3OwpN2rpEz6pdizdHNn
jsoDEngZiDHvLjIyE0cDkFXkeYMGXOnBUeOcu4nfu4C5eKs3nXGGAcNDbDRIuLoE
BZExUBY+YSs6JBvh5tvRqLVW0Dz0akEcjb/jhwS2LmDip8Pdoxx4Q1jPKEu38zrr
Vd5WD2HJhLb9u0UxVp9vfWIUDgydopV5ZmWCQ5YvNepb1w==
-----END CERTIFICATE-----
'';
makePump = { opts ? { } }:
{
enable = true;
sslCert = pkgs.writeText "snakeoil.cert" snakeOilCert;
sslKey = pkgs.writeText "snakeoil.pem" snakeOilKey;
secret = "test";
site = "test";
} // opts;
in {
name = "pumpio";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ rvl ];
};
nodes = {
one =
{ config, pkgs, ... }:
{
services = {
pumpio = makePump { opts = {
port = 443;
}; };
mongodb.enable = true;
mongodb.extraConfig = ''
nojournal = true
'';
};
systemd.services.mongodb.unitConfig.Before = "pump.io.service";
systemd.services.mongodb.unitConfig.RequiredBy = "pump.io.service";
};
};
testScript = ''
startAll;
$one->waitForUnit("pump.io.service");
$one->waitUntilSucceeds("curl -k https://localhost");
'';
})

View file

@ -0,0 +1,68 @@
{ stdenv, fetchFromGitHub, makeWrapper, callPackage, nodejs, python, utillinux, graphicsmagick }:
with stdenv.lib;
let
nodePackages = callPackage (import ../../../top-level/node-packages.nix) {
inherit stdenv nodejs fetchurl fetchgit;
neededNatives = [ python ] ++ optional stdenv.isLinux utillinux;
self = nodePackages;
generated = ./node-packages.nix;
};
in nodePackages.buildNodePackage rec {
version = "git-2015-11-09";
name = "pump.io-${version}";
src = fetchFromGitHub {
owner = "e14n";
repo = "pump.io";
rev = "2f8d6b3518607ed02b594aee0db6ccacbe631b2d";
sha256 = "1xym3jzpxlni1n2i0ixwrnpkx5fbnd1p6sm1hf9n3w5m2lx6gdw5";
};
deps = (filter (v: nixType v == "derivation") (attrValues nodePackages));
buildInputs = [ makeWrapper ];
postInstall = ''
for prog in pump pump-authorize pump-follow pump-post-note pump-register-app pump-register-user pump-stop-following; do
wrapProgram "$out/bin/$prog" \
--set NODE_PATH "$out/lib/node_modules/pump.io/node_modules/" \
--prefix PATH : ${graphicsmagick}/bin:$out/bin
done
'';
passthru.names = ["pump.io"];
meta = {
description = "Social server with an ActivityStreams API";
homepage = http://pump.io/;
license = licenses.asl20;
platforms = platforms.unix;
maintainers = [ maintainers.rvl ];
longDescription = ''
This is pump.io. It's a stream server that does most of what
people really want from a social network.
What's it for?
I post something and my followers see it. That's the rough idea
behind the pump.
There's an API defined in the API.md file. It uses
activitystrea.ms JSON as the main data and command format.
You can post almost anything that can be represented with
activity streams -- short or long text, bookmarks, images,
video, audio, events, geo checkins. You can follow friends,
create lists of people, and so on.
The software is useful for at least these scenarios:
* Mobile-first social networking
* Activity stream functionality for an existing app
* Experimenting with social software
'';
};
}

View file

@ -0,0 +1,36 @@
{
"name": "pump.io",
"dependencies": {
"bcrypt": "0.8.x",
"bunyan": "0.16.x",
"connect": "1.x",
"connect-auth": "0.5.3",
"connect-databank": "0.13.x",
"crypto-cacerts": "0.1.x",
"databank": "0.19.x",
"databank-lrucache": "^0.1.2",
"databank-memcached": "^0.15.0",
"databank-mongodb": "^0.18.10",
"databank-redis": "^0.19.6",
"dateformat": "1.x",
"dialback-client": "~0.1.5",
"emailjs": "0.3.x",
"express": "2.5.x",
"gm": "1.9.x",
"jankyqueue": "0.1.x",
"mkdirp": "0.3.x",
"node-uuid": "1.3.x",
"oauth-evanp": "~0.9.10-evanp.2",
"optimist": "0.3.x",
"schlock": "~0.2.1",
"set-immediate": "0.1.x",
"showdown": "0.3.x",
"sockjs": "0.3.x",
"step": "0.0.x",
"underscore": "1.4.x",
"underscore-contrib": "0.1.x",
"utml": "0.2.x",
"validator": "0.4.x",
"webfinger": "~0.4.2"
}
}

File diff suppressed because it is too large Load diff

View file

@ -9451,6 +9451,8 @@ let
psqlodbc = callPackage ../servers/sql/postgresql/psqlodbc { };
pumpio = callPackage ../servers/web-apps/pump.io { };
pyIRCt = builderDefsPackage (callPackage ../servers/xmpp/pyIRCt) {};
pyMAILt = builderDefsPackage (callPackage ../servers/xmpp/pyMAILt) {};