1
1
Fork 0
nixos-configs/docstore.nix

50 lines
1.3 KiB
Nix

# Configuration for the DocStore service
{ config, pkgs, ... }:
# Set up python
with pkgs;
let docstore-requires = python-packages: with python-packages; [
flask flask_login flask_wtf gunicorn
];
python3-with-docstore-requires = python3.withPackages docstore-requires;
in
{
# Create a user for the server process to run under
users.users.docstore = {
description = "DocStore system user";
isSystemUser = true;
home = "/home/docstore";
createHome = true;
packages = [ python3-with-docstore-requires ];
};
# Create the server process systemd unit
systemd.services.docstore = {
enable = true;
description = "DocStore server";
serviceConfig = {
Type = "simple";
ExecStart = "${python3-with-docstore-requires}/bin/python -m docstore.server /srv/docstore --port 8001";
Restart = "on-failure";
User = "docstore";
WorkingDirectory = "/home/docstore/DocStore";
};
wantedBy = [ "multi-user.target" ];
};
# Configure nginx to forward to the server at the docs subdomain
services.nginx.virtualHosts."docs.alogoulogoi.com" = {
enableACME = true;
forceSSL = true;
extraConfig = ''
access_log /var/log/nginx/access.docs.log;
'';
locations."/".extraConfig = ''
proxy_buffering off;
proxy_pass http://localhost:8001/;
'';
};
}