]>
Commit | Line | Data |
---|---|---|
de6002a1 IB |
1 | { config, lib, pkgs, ... }: |
2 | let | |
3 | greenapid = pkgs.callPackage ./greenapid.nix {}; | |
4 | frontend = pkgs.callPackage ./frontend.nix { nodeEnv = pkgs.callPackage pkgs.mylibs.nodeEnv {}; }; | |
5 | wordlists = pkgs.runCommand "wordlists" {} '' | |
6 | mkdir -p $out | |
7 | cp -r ${./wordlists} $out/wordlists | |
8 | ''; | |
9 | cfg = config.myServices.websites.games.codenames; | |
10 | in | |
11 | { | |
12 | options.myServices.websites.games.codenames.enable = lib.mkEnableOption "Enable Codenames game"; | |
13 | config = lib.mkIf cfg.enable { | |
14 | systemd.services.codenames_api = { | |
15 | description = "Api for codenames game"; | |
16 | wantedBy = [ "multi-user.target" ]; | |
17 | script = "${greenapid}/bin/greenapid"; | |
18 | postStart = '' | |
19 | sleep 5; | |
20 | chown :wwwrun /run/codenamesgreen/socket.sock | |
21 | chmod g+w /run/codenamesgreen/socket.sock | |
22 | ''; | |
23 | serviceConfig = { | |
24 | User = "codenames"; | |
25 | DynamicUser = true; | |
26 | SupplementaryGroups = [ "wwwrun" ]; | |
27 | Type = "simple"; | |
28 | RuntimeDirectory = "codenamesgreen"; | |
29 | WorkingDirectory = builtins.toString wordlists; | |
30 | }; | |
31 | }; | |
32 | ||
33 | services.websites.env.tools.vhostConfs.games_codenames = { | |
34 | certName = "games"; | |
35 | certMainHost = "games.immae.eu"; | |
36 | hosts = [ "codenames.games.immae.eu" ]; | |
37 | root = frontend; | |
38 | extraConfig = [ | |
39 | '' | |
40 | ProxyPass /api/ unix:///run/codenamesgreen/socket.sock|http://codenames.games.immae.eu/ | |
41 | ProxyPassReverse /api/ unix:///run/codenamesgreen/socket.sock|http://codenames.games.immae.eu/ | |
42 | ||
43 | <Directory ${frontend}> | |
44 | FallbackResource index.html | |
45 | </Directory> | |
46 | '' | |
47 | ]; | |
48 | }; | |
49 | }; | |
50 | } |