mediocre-blog/srv/default.nix

67 lines
1.6 KiB
Nix
Raw Normal View History

2022-05-06 02:57:17 +00:00
{
bash,
go,
2022-05-06 02:57:17 +00:00
buildGoModule,
writeScript,
writeText,
2022-05-06 02:57:17 +00:00
stdenv,
config,
staticBuild,
}: rec {
init = writeText "mediocre-blog-srv-init" ''
2022-05-06 02:57:17 +00:00
export MEDIOCRE_BLOG_DATA_DIR="${config.dataDir}"
mkdir -p "${config.dataDir}"
2022-05-06 02:57:17 +00:00
# mailing list
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
export MEDIOCRE_BLOG_REDIS_ADDR="${config.redisListenPath}"
2022-05-06 02:57:17 +00:00
# pow
export MEDIOCRE_BLOG_POW_SECRET="${config.powSecret}"
2022-05-06 02:57:17 +00:00
# static proxy
if [ "${config.staticProxyURL}" == "" ]; then
export MEDIOCRE_BLOG_STATIC_DIR="${staticBuild}"
2022-05-06 02:57:17 +00:00
else
export MEDIOCRE_BLOG_STATIC_URL="${config.staticProxyURL}"
2022-05-06 02:57:17 +00:00
fi
# listening
export MEDIOCRE_BLOG_LISTEN_PROTO="${config.listenProto}"
export MEDIOCRE_BLOG_LISTEN_ADDR="${config.listenAddr}"
2022-05-06 02:57:17 +00:00
'';
build = buildGoModule {
pname = "mediocre-blog-srv";
version = "dev";
src = ./src;
vendorSha256 = "sha256-/F62WVkI50woo5J0xZOAn0g0WWkDna4wIBeVvbhAGzs=";
2021-08-28 00:03:51 +00:00
# disable tests
checkPhase = '''';
};
2022-05-06 02:57:17 +00:00
bin = writeScript "mediocre-blog-srv-bin" ''
#!${bash}
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 {
name = "mediocre-blog-srv-shell";
buildInputs = [ go build ];
2022-05-06 02:57:17 +00:00
shellHook = ''
source ${init}
cd src
2022-05-06 02:57:17 +00:00
'';
};
}