mediocre-blog/srv/default.nix

53 lines
1.5 KiB
Nix
Raw Normal View History

{pkgs, config, staticBuild}: rec {
2021-08-08 15:07:51 +00:00
mailingListOpts = [
"-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}"
"-listen-proto=${config.listenProto}"
"-listen-addr=${config.listenAddr}"
"-redis-proto=unix"
"-redis-addr=${config.redisListenPath}"
] ++ (
if config.staticProxyURL == ""
then [ "-static-dir=${staticBuild}" ]
else [ "-static-proxy-url=${config.staticProxyURL}" ]
);
build = pkgs.buildGoModule {
pname = "mediocre-blog-srv";
version = "dev";
src = ./.;
2021-08-28 00:03:51 +00:00
vendorSha256 = "0c6j989q6r2q967gx90cl4l8skflkx2npmxd3f5l16bwj2ldw11j";
# disable tests
checkPhase = '''';
};
bin = pkgs.writeScript "mediocre-blog-srv-bin" ''
#!/bin/sh
2021-08-27 03:28:27 +00:00
mkdir -p "${config.dataDir}"
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}"
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
'';
shell = pkgs.stdenv.mkDerivation {
name = "mediocre-blog-srv-shell";
2021-08-08 15:07:51 +00:00
buildInputs = [ pkgs.go runScript runMailingListCLIScript ];
};
}