2022-05-06 02:57:17 +00:00
|
|
|
{
|
2022-05-06 03:20:22 +00:00
|
|
|
bash,
|
|
|
|
go,
|
2022-05-06 02:57:17 +00:00
|
|
|
buildGoModule,
|
|
|
|
writeScript,
|
2022-05-06 03:20:22 +00:00
|
|
|
writeText,
|
2022-05-06 02:57:17 +00:00
|
|
|
stdenv,
|
|
|
|
|
|
|
|
config,
|
|
|
|
staticBuild,
|
|
|
|
}: rec {
|
|
|
|
|
2022-05-06 03:20:22 +00:00
|
|
|
init = writeText "mediocre-blog-srv-init" ''
|
2022-05-06 02:57:17 +00:00
|
|
|
|
2022-05-06 03:20:22 +00:00
|
|
|
export MEDIOCRE_BLOG_DATA_DIR="${config.dataDir}"
|
2022-05-06 02:57:17 +00:00
|
|
|
|
|
|
|
# mailing list
|
2022-05-06 03:20:22 +00:00
|
|
|
export MEDIOCRE_BLOG_ML_SMTP_ADDR="${config.mlSMTPAddr}"
|
|
|
|
export MEDIOCRE_BLOG_ML_SMTP_AUTH="${config.mlSMTPAuth}"
|
|
|
|
export MEDIOCRE_BLOG_ML_PUBLIC_URL="${config.mlPublicURL}"
|
2022-05-06 02:57:17 +00:00
|
|
|
|
|
|
|
# redis
|
|
|
|
export MEDIOCRE_BLOG_REDIS_PROTO=unix
|
2022-05-06 03:20:22 +00:00
|
|
|
export MEDIOCRE_BLOG_REDIS_ADDR="${config.redisListenPath}"
|
2022-05-06 02:57:17 +00:00
|
|
|
|
|
|
|
# pow
|
2022-05-06 03:20:22 +00:00
|
|
|
export MEDIOCRE_BLOG_POW_SECRET="${config.powSecret}"
|
2022-05-06 02:57:17 +00:00
|
|
|
|
|
|
|
# static proxy
|
2022-05-08 22:48:03 +00:00
|
|
|
export MEDIOCRE_BLOG_STATIC_DIR="${staticBuild}"
|
2022-05-06 02:57:17 +00:00
|
|
|
|
|
|
|
# listening
|
2022-05-06 03:20:22 +00:00
|
|
|
export MEDIOCRE_BLOG_LISTEN_PROTO="${config.listenProto}"
|
|
|
|
export MEDIOCRE_BLOG_LISTEN_ADDR="${config.listenAddr}"
|
2022-05-20 04:44:33 +00:00
|
|
|
|
|
|
|
# api
|
2022-05-20 17:17:31 +00:00
|
|
|
export MEDIOCRE_BLOG_API_AUTH_USERS='${builtins.toJSON config.httpAuthUsers}'
|
2022-05-06 02:57:17 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
build = buildGoModule {
|
2021-08-08 13:57:45 +00:00
|
|
|
pname = "mediocre-blog-srv";
|
|
|
|
version = "dev";
|
2022-05-06 03:20:22 +00:00
|
|
|
src = ./src;
|
2022-05-13 17:47:29 +00:00
|
|
|
vendorSha256 = "1s5jhis1a2y7m50k29ap7kd0h4bgc3dzy1f9dqf5jrz8n27f3i87";
|
2021-08-28 00:03:51 +00:00
|
|
|
|
|
|
|
# disable tests
|
|
|
|
checkPhase = '''';
|
2021-08-08 13:57:45 +00:00
|
|
|
};
|
2021-07-31 22:45:49 +00:00
|
|
|
|
2022-05-06 02:57:17 +00:00
|
|
|
bin = writeScript "mediocre-blog-srv-bin" ''
|
2022-05-08 22:48:03 +00:00
|
|
|
#!${bash}/bin/bash
|
2022-05-06 03:20:22 +00:00
|
|
|
source ${init}
|
2022-05-06 02:57:17 +00:00
|
|
|
exec ${build}/bin/mediocre-blog
|
2021-08-08 15:07:51 +00:00
|
|
|
'';
|
|
|
|
|
2022-05-06 02:57:17 +00:00
|
|
|
shell = stdenv.mkDerivation {
|
2021-08-08 13:57:45 +00:00
|
|
|
name = "mediocre-blog-srv-shell";
|
2022-05-14 21:21:52 +00:00
|
|
|
buildInputs = [ go ];
|
|
|
|
shellHook = ''source ${init}'';
|
2021-08-08 13:57:45 +00:00
|
|
|
};
|
2022-05-08 22:36:28 +00:00
|
|
|
|
2022-05-14 21:21:52 +00:00
|
|
|
shellWithBuild = stdenv.mkDerivation {
|
|
|
|
name = "mediocre-blog-srv-shell-with-build";
|
|
|
|
buildInputs = [ go build ];
|
|
|
|
shellHook = ''source ${init}'';
|
2022-05-08 22:36:28 +00:00
|
|
|
};
|
2021-08-08 13:57:45 +00:00
|
|
|
}
|