mediocre-blog/srv/default.nix

64 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,
sqlite,
2022-05-06 02:57:17 +00:00
writeScript,
writeText,
2022-05-06 02:57:17 +00:00
stdenv,
config,
}: rec {
init = writeText "mediocre-blog-srv-init" ''
2022-05-06 02:57:17 +00:00
export MEDIOCRE_BLOG_DATA_DIR="${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}"
2022-05-20 23:24:52 +00:00
export MEDIOCRE_BLOG_ML_PUBLIC_URL="${config.publicURL}"
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
# http
2022-05-20 23:24:52 +00:00
export MEDIOCRE_BLOG_HTTP_PUBLIC_URL="${config.publicURL}"
export MEDIOCRE_BLOG_HTTP_LISTEN_PROTO="${config.httpListenProto}"
export MEDIOCRE_BLOG_HTTP_LISTEN_ADDR="${config.httpListenAddr}"
export MEDIOCRE_BLOG_HTTP_AUTH_USERS='${builtins.toJSON config.httpAuthUsers}'
2022-05-20 20:54:26 +00:00
export MEDIOCRE_BLOG_HTTP_AUTH_RATELIMIT='${config.httpAuthRatelimit}'
2022-05-06 02:57:17 +00:00
'';
build = buildGoModule {
pname = "mediocre-blog-srv";
version = "dev";
src = ./src;
2022-05-21 17:40:13 +00:00
vendorSha256 = "sha256-C3hyPDO+6oTUeoGP/ZzBn5Y4V/q1jI12BwkR9NADHn0=";
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" ''
2022-05-08 22:48:03 +00:00
#!${bash}/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 sqlite ];
shellHook = ''
source ${init}
echo "Loading test data..."
(cd srv/src/cmd/load-test-data && go run main.go)
'';
};
}