2021-08-08 13:57:45 +00:00
|
|
|
{pkgs, config, staticBuild}: rec {
|
2021-07-31 22:45:49 +00:00
|
|
|
|
2021-08-08 15:07:51 +00:00
|
|
|
mailingListOpts = [
|
2021-08-08 13:57:45 +00:00
|
|
|
"-ml-smtp-addr=${config.mlSMTPAddr}"
|
|
|
|
"-ml-smtp-auth='${config.mlSMTPAuth}'"
|
|
|
|
"-data-dir=${config.dataDir}"
|
|
|
|
"-public-url=${config.publicURL}"
|
2021-08-08 15:07:51 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
opts = mailingListOpts ++ [
|
|
|
|
"-pow-secret=${config.powSecret}"
|
2021-08-08 13:57:45 +00:00
|
|
|
"-listen-proto=${config.listenProto}"
|
|
|
|
"-listen-addr=${config.listenAddr}"
|
2021-08-31 02:08:51 +00:00
|
|
|
"-redis-proto=unix"
|
2021-08-31 03:38:09 +00:00
|
|
|
"-redis-addr=${config.redisListenPath}"
|
2021-08-08 13:57:45 +00:00
|
|
|
] ++ (
|
|
|
|
if config.staticProxyURL == ""
|
|
|
|
then [ "-static-dir=${staticBuild}" ]
|
|
|
|
else [ "-static-proxy-url=${config.staticProxyURL}" ]
|
|
|
|
);
|
2021-07-31 22:45:49 +00:00
|
|
|
|
2021-08-08 13:57:45 +00:00
|
|
|
build = pkgs.buildGoModule {
|
|
|
|
pname = "mediocre-blog-srv";
|
|
|
|
version = "dev";
|
|
|
|
src = ./.;
|
2021-08-28 00:03:51 +00:00
|
|
|
vendorSha256 = "0c6j989q6r2q967gx90cl4l8skflkx2npmxd3f5l16bwj2ldw11j";
|
|
|
|
|
|
|
|
# disable tests
|
|
|
|
checkPhase = '''';
|
2021-08-08 13:57:45 +00:00
|
|
|
};
|
2021-07-31 22:45:49 +00:00
|
|
|
|
2021-08-08 13:57:45 +00:00
|
|
|
bin = pkgs.writeScript "mediocre-blog-srv-bin" ''
|
|
|
|
#!/bin/sh
|
2021-08-27 03:28:27 +00:00
|
|
|
mkdir -p "${config.dataDir}"
|
2021-08-08 13:57:45 +00:00
|
|
|
exec ${build}/bin/mediocre-blog ${toString opts}
|
|
|
|
'';
|
|
|
|
|
|
|
|
runScript = pkgs.writeScriptBin "run-mediocre-blog" ''
|
2021-08-27 03:28:27 +00:00
|
|
|
mkdir -p "${config.dataDir}"
|
2021-08-08 13:57:45 +00:00
|
|
|
go run ./cmd/mediocre-blog/main.go ${toString opts}
|
|
|
|
'';
|
|
|
|
|
2021-08-08 15:07:51 +00:00
|
|
|
runMailingListCLIScript = pkgs.writeScriptBin "run-mailinglist-cli" ''
|
2021-08-28 00:03:51 +00:00
|
|
|
go run ./cmd/mailinglist-cli/main.go ${toString mailingListOpts} "$@"
|
2021-08-08 15:07:51 +00:00
|
|
|
'';
|
|
|
|
|
2021-08-08 13:57:45 +00:00
|
|
|
shell = pkgs.stdenv.mkDerivation {
|
|
|
|
name = "mediocre-blog-srv-shell";
|
2021-08-08 15:07:51 +00:00
|
|
|
buildInputs = [ pkgs.go runScript runMailingListCLIScript ];
|
2021-08-08 13:57:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|