meguca: init at git-2018-05-17

This commit is contained in:
Okina Matara 2018-05-17 18:56:58 -05:00
parent 934db656b1
commit 14a26f0153
6 changed files with 394 additions and 0 deletions

View file

@ -316,6 +316,7 @@
monetdb = 290;
restic = 291;
openvpn = 292;
meguca = 293;
# When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
@ -592,6 +593,7 @@
monetdb = 290;
restic = 291;
openvpn = 292;
meguca = 293;
# 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

@ -667,6 +667,7 @@
./services/web-servers/lighttpd/default.nix
./services/web-servers/lighttpd/gitweb.nix
./services/web-servers/lighttpd/inginious.nix
./services/web-servers/meguca.nix
./services/web-servers/mighttpd2.nix
./services/web-servers/minio.nix
./services/web-servers/nginx/default.nix

View file

@ -0,0 +1,123 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.meguca;
postgres = config.services.postgresql;
in
{
options.services.meguca = {
enable = mkEnableOption "meguca";
baseDir = mkOption {
type = types.path;
default = "/var/lib/meguca";
description = "Location where meguca stores it's database and links.";
};
password = mkOption {
type = types.str;
default = "meguca";
description = "Password for the meguca database.";
};
reverseProxy = mkOption {
type = types.nullOr types.str;
default = null;
description = "Reverse proxy IP.";
};
sslCertificate = mkOption {
type = types.nullOr types.str;
default = null;
description = "Path to the SSL certificate.";
};
listenAddress = mkOption {
type = types.nullOr types.str;
default = null;
description = "Listen on a specific IP address and port.";
};
cacheSize = mkOption {
type = types.nullOr types.str;
default = null;
description = "Cache size in MB.";
};
postgresArgs = mkOption {
type = types.nullOr types.str;
default = null;
description = "Postgresql connection arguments.";
};
compressTraffic = mkOption {
type = types.bool;
default = false;
description = "Compress all traffic with gzip.";
};
assumeReverseProxy = mkOption {
type = types.bool;
default = false;
description = "Assume the server is behind a reverse proxy, when resolving client IPs.";
};
httpsOnly = mkOption {
type = types.bool;
default = false;
description = "Serve and listen only through HTTPS.";
};
};
config = mkIf cfg.enable {
security.sudo.enable = cfg.enable == true;
services.postgresql.enable = cfg.enable == true;
systemd.services.meguca = {
description = "meguca";
after = [ "network.target" "postgresql.service" ];
wantedBy = [ "multi-user.target" ];
preStart = ''
# Ensure folder exists and links are correct or create them
mkdir -p ${cfg.baseDir}
ln -sf ${pkgs.meguca}/share/meguca/www ${cfg.baseDir}
chown -R meguca:meguca ${cfg.baseDir}
# Ensure the database is correct or create it
${pkgs.sudo}/bin/sudo -u ${postgres.superUser} ${postgres.package}/bin/createuser -SDR meguca || true
${pkgs.sudo}/bin/sudo -u ${postgres.superUser} ${postgres.package}/bin/psql -c "ALTER ROLE meguca WITH PASSWORD '${cfg.password}';" || true
${pkgs.sudo}/bin/sudo -u ${postgres.superUser} ${postgres.package}/bin/createdb -T template0 -E UTF8 -O meguca meguca || true
'';
serviceConfig = {
PermissionsStartOnly = true;
Type = "forking";
User = "meguca";
Group = "meguca";
WorkingDirectory = "${cfg.baseDir}";
ExecStart = ''${pkgs.meguca}/bin/meguca${if cfg.reverseProxy != null then " -R ${cfg.reverseProxy}" else ""}${if cfg.sslCertificate != null then " -S ${cfg.sslCertificate}" else ""}${if cfg.listenAddress != null then " -a ${cfg.listenAddress}" else ""}${if cfg.cacheSize != null then " -c ${cfg.cacheSize}" else ""}${if cfg.postgresArgs != null then " -d ${cfg.postgresArgs}" else ""}${if cfg.compressTraffic then " -g" else ""}${if cfg.assumeReverseProxy then " -r" else ""}${if cfg.httpsOnly then " -s" else ""} start'';
ExecStop = "${pkgs.meguca}/bin/meguca stop";
ExecRestart = "${pkgs.meguca}/bin/meguca restart";
};
};
users = {
extraUsers.meguca = {
description = "meguca server service user";
home = "${cfg.baseDir}";
createHome = true;
group = "meguca";
uid = config.ids.uids.meguca;
};
extraGroups.meguca = {
gid = config.ids.gids.meguca;
members = [ "meguca" ];
};
};
};
meta.maintainers = [ maintainers.chiiruno ];
}

View file

@ -0,0 +1,47 @@
{ stdenv, buildGoPackage, fetchgit, pkgconfig, ffmpeg-full, graphicsmagick, ghostscript, quicktemplate, go-bindata, easyjson, nodePackages, cmake, emscripten }:
buildGoPackage rec {
name = "meguca-unstable-${version}";
version = "2018-05-17";
rev = "3107c78d95de3b64556f761d3b6dcfd5c590e0ec";
goPackagePath = "github.com/bakape/meguca";
goDeps = ./server_deps.nix;
enableParallelBuilding = true;
nativeBuildInputs = [ pkgconfig cmake ];
buildInputs = [ ffmpeg-full graphicsmagick ghostscript quicktemplate go-bindata easyjson emscripten ];
src = fetchgit {
inherit rev;
url = "https://github.com/bakape/meguca";
sha256 = "1rvkr5af5d4rlyxylynnpn76hvxq9xd7j8q6mffn6qj6j5p4qg4p";
fetchSubmodules = true;
};
configurePhase = ''
export HOME=$PWD
export GOPATH=$GOPATH:$HOME/go
ln -sf ${nodePackages.meguca}/lib/node_modules/meguca/node_modules
sed -i "/npm install --progress false --depth 0/d" Makefile
make generate_clean
go generate meguca/...
'';
buildPhase = ''
go build -p $NIX_BUILD_CORES meguca
make -j $NIX_BUILD_CORES client wasm
'';
installPhase = ''
mkdir -p $bin/bin $bin/share/meguca
cp meguca $bin/bin
cp -r www $bin/share/meguca
'';
meta = with stdenv.lib; {
homepage = "https://github.com/bakape/meguca";
description = "Anonymous realtime imageboard focused on high performance, free speech and transparent moderation";
license = licenses.agpl3Plus;
maintainers = with maintainers; [ chiiruno ];
platforms = platforms.all;
};
}

View file

@ -0,0 +1,219 @@
# This file was generated by https://github.com/kamilchm/go2nix v1.2.1
[
{
goPackagePath = "github.com/Masterminds/squirrel";
fetch = {
type = "git";
url = "https://github.com/Masterminds/squirrel";
rev = "40ef4f86bf59a996c348a9f56ddb4c4d3d49a6df";
sha256 = "1zdv8hds2skqz9xrybf1pw5hfxzd27c35fsrfq11ryif1wxwbkyp";
};
}
{
goPackagePath = "github.com/Soreil/apngdetector";
fetch = {
type = "git";
url = "https://github.com/Soreil/apngdetector";
rev = "e412c29dbc998dfcffe266b12587b29096ac4d46";
sha256 = "0ci71nk6jijspzbgcfrgi4in9lmd2c39f6xzcf9k3z9ixwv8c79j";
};
}
{
goPackagePath = "github.com/aquilax/tripcode";
fetch = {
type = "git";
url = "https://github.com/aquilax/tripcode";
rev = "db58da84bb12e26032493b73eb3b58ba884590ef";
sha256 = "0maqk0rwp39kcc64w4mfkgcvn2q76hqwziwc3g7ckc1qpwxql5z3";
};
}
{
goPackagePath = "github.com/bakape/mnemonics";
fetch = {
type = "git";
url = "https://github.com/bakape/mnemonics";
rev = "056d8d3259923b93bb0449a45b0c56ac20c77f1b";
sha256 = "137dl4bkpszj7pm4dyj222xdvy9lmwsgmm0l6bxni0msc3jdrqkl";
};
}
{
goPackagePath = "github.com/bakape/thumbnailer";
fetch = {
type = "git";
url = "https://github.com/bakape/thumbnailer";
rev = "5b92eb4c4500fd8e004e4cc9eeb2038961e2004f";
sha256 = "0z9myzp6rjyylh91ibd1nfpz7za1gxg4n3pnn7sw54i9zyws1l4x";
};
}
{
goPackagePath = "github.com/boltdb/bolt";
fetch = {
type = "git";
url = "https://github.com/boltdb/bolt";
rev = "fd01fc79c553a8e99d512a07e8e0c63d4a3ccfc5";
sha256 = "12f5swiwzcamk87r9j73nn7rmyyday7jkgzfh7x5wdg9blzhrir2";
};
}
{
goPackagePath = "github.com/dchest/captcha";
fetch = {
type = "git";
url = "https://github.com/dchest/captcha";
rev = "6a29415a8364ec2971fdc62d9e415ed53fc20410";
sha256 = "0j0yspx5rlyx7fdfcx74viqc8jlq3nwyd62bdx4gvbd56cppldcm";
};
}
{
goPackagePath = "github.com/dimfeld/httptreemux";
fetch = {
type = "git";
url = "https://github.com/dimfeld/httptreemux";
rev = "7f532489e7739b3d49df5c602bf63549881fe753";
sha256 = "0hkw04rsvljvx8ynqjgz9cb743x09fd2xiiycrgz5vbsa8q9iyyk";
};
}
{
goPackagePath = "github.com/gorilla/handlers";
fetch = {
type = "git";
url = "https://github.com/gorilla/handlers";
rev = "13a38d26174b16d5b4bf6f1094c1389ec9879572";
sha256 = "0zg43blpyyy667y0kpiifk5a2w35jh8qkk4zwlabb365c0lzrv6v";
};
}
{
goPackagePath = "github.com/gorilla/websocket";
fetch = {
type = "git";
url = "https://github.com/gorilla/websocket";
rev = "21ab95fa12b9bdd8fecf5fa3586aad941cc98785";
sha256 = "1ygg6cr84461d6k3nzbja0dxhcgf5zvry2w10f6i7291ghrcwhyy";
};
}
{
goPackagePath = "github.com/kardianos/osext";
fetch = {
type = "git";
url = "https://github.com/kardianos/osext";
rev = "ae77be60afb1dcacde03767a8c37337fad28ac14";
sha256 = "056dkgxrqjj5r18bnc3knlpgdz5p3yvp12y4y978hnsfhwaqvbjz";
};
}
{
goPackagePath = "github.com/lann/builder";
fetch = {
type = "git";
url = "https://github.com/lann/builder";
rev = "1b87b36280d04fe7882d1512bf038ea2967ad534";
sha256 = "015q46awbyp47vld07yi7d27i0lkd82r7qn5230bb9qxl4mcfiqc";
};
}
{
goPackagePath = "github.com/lann/ps";
fetch = {
type = "git";
url = "https://github.com/lann/ps";
rev = "62de8c46ede02a7675c4c79c84883eb164cb71e3";
sha256 = "10yhcyymypvdiiipchsp80jbglk8c4r7lq7h54v9f4mxmvz6xgf7";
};
}
{
goPackagePath = "github.com/lib/pq";
fetch = {
type = "git";
url = "https://github.com/lib/pq";
rev = "d34b9ff171c21ad295489235aec8b6626023cd04";
sha256 = "1gmdpp7wxlkk0szgq96rf06dj2ifjl0zbvbmg2g4bgxandh552jv";
};
}
{
goPackagePath = "github.com/mailru/easyjson";
fetch = {
type = "git";
url = "https://github.com/mailru/easyjson";
rev = "8b799c424f57fa123fc63a99d6383bc6e4c02578";
sha256 = "15ba6drfmw98lzw5qjh3ijcxh9iz9rcp3hid169yfd08l06z05w0";
};
}
{
goPackagePath = "github.com/nyarlabo/go-crypt";
fetch = {
type = "git";
url = "https://github.com/nyarlabo/go-crypt";
rev = "d9a5dc2b789bc330075d4b805d9b7c971f2865a1";
sha256 = "0249hbwvhy0xywi9b5k8964km27pvfkr3jvliy3azri6vnyvkkx1";
};
}
{
goPackagePath = "github.com/oschwald/maxminddb-golang";
fetch = {
type = "git";
url = "https://github.com/oschwald/maxminddb-golang";
rev = "c5bec84d1963260297932a1b7a1753c8420717a7";
sha256 = "0n8vhinm2x0prbn0vhxw38c24iiaizwk1b76s4srg30gk3dfdd39";
};
}
{
goPackagePath = "github.com/sevlyar/go-daemon";
fetch = {
type = "git";
url = "https://github.com/sevlyar/go-daemon";
rev = "45a2ba1b7c6710a044163fa109bf08d060bc3afa";
sha256 = "1fd8cwljgbxsm3w38pii0n02zg8s53x7j08w784csj3sfzq7rbv4";
};
}
{
goPackagePath = "github.com/ulikunitz/xz";
fetch = {
type = "git";
url = "https://github.com/ulikunitz/xz";
rev = "0c6b41e72360850ca4f98dc341fd999726ea007f";
sha256 = "0a6l7sp67ipxim093qh6fvw8knbxj24l7bj5lykcddi5gwfi78n3";
};
}
{
goPackagePath = "github.com/valyala/bytebufferpool";
fetch = {
type = "git";
url = "https://github.com/valyala/bytebufferpool";
rev = "e746df99fe4a3986f4d4f79e13c1e0117ce9c2f7";
sha256 = "01lqzjddq6kz9v41nkky7wbgk7f1cw036sa7ldz10d82g5klzl93";
};
}
{
goPackagePath = "github.com/valyala/quicktemplate";
fetch = {
type = "git";
url = "https://github.com/valyala/quicktemplate";
rev = "a91e0946457b6583004fbfc159339b8171423aed";
sha256 = "1z89ang5pkq5qs5b2nwhzyrw0zjlsas539l9kix374fhka49n8yc";
};
}
{
goPackagePath = "golang.org/x/crypto";
fetch = {
type = "git";
url = "https://go.googlesource.com/crypto";
rev = "21052ae46654ecf18dfdba0f7c12701a1e2b3164";
sha256 = "0wzi1knv181h6y8k3k7wlr7sw492pgxir4gyg2riavrk8c23y2s2";
};
}
{
goPackagePath = "golang.org/x/sys";
fetch = {
type = "git";
url = "https://go.googlesource.com/sys";
rev = "7db1c3b1a98089d0071c84f646ff5c96aad43682";
sha256 = "0z20mhdy3wiy53xch0fp49gv574qrs77fps5wxi12n57840s2jfr";
};
}
{
goPackagePath = "golang.org/x/text";
fetch = {
type = "git";
url = "https://go.googlesource.com/text";
rev = "7922cc490dd5a7dbaa7fd5d6196b49db59ac042f";
sha256 = "06sicjc24hv7v9p1l6psaq87w4lycx3mjixd6gsd1wnd4jhqvlnr";
};
}
]

View file

@ -12607,6 +12607,8 @@ with pkgs;
mediatomb = callPackage ../servers/mediatomb { };
meguca = callPackage ../servers/meguca/default.nix { };
memcached = callPackage ../servers/memcached {};
meteor = callPackage ../servers/meteor/default.nix { };