forked from
lass.pds.lassul.us/superconfig
This repository has no description
1.6 kB
52 lines
1{ pkgs, self, ... }:
2let
3 domain = "wallpaper.lassul.us";
4 port = 8477;
5 stateDir = "/var/lib/wallpaper-lassul-us";
6 server = self.packages.${pkgs.stdenv.hostPlatform.system}.realwallpaper-server;
7in
8{
9 # live world map wallpapers rendered on demand (tools/realwallpaper):
10 # https://wallpaper.lassul.us/?location=52.52,13.40&variant=lens
11 imports = [ ./default.nix ];
12
13 users.users.wallpaper-lassul-us = {
14 isSystemUser = true;
15 group = "wallpaper-lassul-us";
16 home = stateDir;
17 };
18 users.groups.wallpaper-lassul-us = { };
19
20 systemd.services.wallpaper-lassul-us = {
21 description = "realwallpaper renders for ${domain}";
22 wantedBy = [ "multi-user.target" ];
23 after = [ "network-online.target" ];
24 wants = [ "network-online.target" ];
25 # astropy wants a writable home for its config
26 environment.HOME = stateDir;
27 serviceConfig = {
28 User = "wallpaper-lassul-us";
29 Group = "wallpaper-lassul-us";
30 StateDirectory = "wallpaper-lassul-us";
31 ExecStart = "${server}/bin/realwallpaper-server --listen 127.0.0.1:${toString port} --state-dir ${stateDir}";
32 Restart = "on-failure";
33 # one 4K render peaks at a few GB; keep it from starving the host
34 MemoryHigh = "6G";
35 MemoryMax = "8G";
36 Nice = 10;
37 };
38 };
39
40 services.nginx.virtualHosts.${domain} = {
41 enableACME = true;
42 forceSSL = true;
43 locations."/" = {
44 proxyPass = "http://127.0.0.1:${toString port}";
45 recommendedProxySettings = true;
46 # a request for a new location waits for its render (a minute or two)
47 extraConfig = ''
48 proxy_read_timeout 900;
49 '';
50 };
51 };
52}