mediocre-blog/srv/default.nix

46 lines
1.3 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}"
] ++ (
if config.staticProxyURL == ""
then [ "-static-dir=${staticBuild}" ]
else [ "-static-proxy-url=${config.staticProxyURL}" ]
);
build = pkgs.buildGoModule {
pname = "mediocre-blog-srv";
version = "dev";
src = ./.;
vendorSha256 = "08wv94yv2wmlxzmanw551gixc8v8nl6zq2m721ig9nl3r540x46f";
};
bin = pkgs.writeScript "mediocre-blog-srv-bin" ''
#!/bin/sh
exec ${build}/bin/mediocre-blog ${toString opts}
'';
runScript = pkgs.writeScriptBin "run-mediocre-blog" ''
go run ./cmd/mediocre-blog/main.go ${toString opts}
'';
2021-08-08 15:07:51 +00:00
runMailingListCLIScript = pkgs.writeScriptBin "run-mailinglist-cli" ''
go run ./cmd/mailinglist-cli/main.go ${toString mailingListOpts} $@
'';
shell = pkgs.stdenv.mkDerivation {
name = "mediocre-blog-srv-shell";
2021-08-08 15:07:51 +00:00
buildInputs = [ pkgs.go runScript runMailingListCLIScript ];
};
}