nixos-config/configs/workhorse/seafile.nix

51 lines
1.3 KiB
Nix
Raw Normal View History

2020-02-24 04:45:36 +01:00
{ config, lib, pkgs, ... }:
let
hostname = "seafile.gaykraft.com";
port = 3030;
home = "/home/seafile";
serviceName = "seafile-docker";
in {
2019-10-24 02:20:38 +02:00
services.nginx = {
enable = true;
statusPage = true;
virtualHosts = {
"seafile.${config.networking.hostName}.private" = {
2019-12-20 05:54:26 +01:00
serverAliases = [ ];
2019-10-24 02:20:38 +02:00
locations."/" = {
2020-02-24 04:45:36 +01:00
proxyPass =
"http://${config.networking.hostName}.private:${toString port}";
2019-10-24 02:20:38 +02:00
};
};
};
};
2020-02-24 04:45:36 +01:00
systemd.services."${serviceName}" = {
2019-10-24 02:20:38 +02:00
enable = true;
2020-02-24 04:45:36 +01:00
description = "seafile service running as docker";
after = [ "network.target" "docker.service" ];
requires = [ "docker.service" ];
wantedBy = [ "multi-user.target" ];
script = ''
# delete old instance to ensure update
${pkgs.docker}/bin/docker stop seafile || true && ${pkgs.docker}/bin/docker rm -f seafile || true
# start instance
${pkgs.docker}/bin/docker run \
--name seafile \
--env SEAFILE_SERVER_HOSTNAME=${hostname} \
--env SEAFILE_ADMIN_EMAIL="root@${hostname}" \
--env SEAFILE_ADMIN_PASSWORD="${
lib.fileContents <secrets/seafile/root>
}" \
--volume ${home}:/shared \
--publish ${toString port}:80 \
seafileltd/seafile:latest
'';
2019-10-24 02:20:38 +02:00
};
virtualisation.docker.enable = lib.mkDefault true;
}