]>
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 { | |
120bcf4d IB |
14 | myServices.chatonsProperties.services.codenames = { |
15 | file.datetime = "2022-08-27T14:08:00"; | |
16 | service = { | |
17 | name = "Codenames Green"; | |
18 | description = "Co-op codenames app"; | |
19 | website = "https://codenames.games.immae.eu/"; | |
20 | logo = "https://codenames.games.immae.eu/images/apple-touch-icon.png"; | |
21 | status.level = "OK"; | |
22 | status.description = "OK"; | |
23 | registration."" = ["NONE"]; | |
24 | registration.load = "OPEN"; | |
25 | install.type = "PACKAGE"; | |
26 | }; | |
27 | software = { | |
28 | name = "Codenames Green"; | |
29 | website = "https://www.codenamesgreen.com/"; | |
30 | license.url = "https://github.com/jbowens/codenamesgreen/blob/master/package.json"; | |
31 | license.name = "MIT"; | |
32 | version = greenapid.version; | |
33 | source.url = "https://github.com/jbowens/codenamesgreen"; | |
34 | }; | |
35 | }; | |
de6002a1 IB |
36 | systemd.services.codenames_api = { |
37 | description = "Api for codenames game"; | |
38 | wantedBy = [ "multi-user.target" ]; | |
39 | script = "${greenapid}/bin/greenapid"; | |
40 | postStart = '' | |
41 | sleep 5; | |
42 | chown :wwwrun /run/codenamesgreen/socket.sock | |
43 | chmod g+w /run/codenamesgreen/socket.sock | |
44 | ''; | |
45 | serviceConfig = { | |
46 | User = "codenames"; | |
47 | DynamicUser = true; | |
48 | SupplementaryGroups = [ "wwwrun" ]; | |
49 | Type = "simple"; | |
50 | RuntimeDirectory = "codenamesgreen"; | |
51 | WorkingDirectory = builtins.toString wordlists; | |
52 | }; | |
53 | }; | |
54 | ||
55 | services.websites.env.tools.vhostConfs.games_codenames = { | |
56 | certName = "games"; | |
57 | certMainHost = "games.immae.eu"; | |
58 | hosts = [ "codenames.games.immae.eu" ]; | |
59 | root = frontend; | |
60 | extraConfig = [ | |
61 | '' | |
62 | ProxyPass /api/ unix:///run/codenamesgreen/socket.sock|http://codenames.games.immae.eu/ | |
63 | ProxyPassReverse /api/ unix:///run/codenamesgreen/socket.sock|http://codenames.games.immae.eu/ | |
64 | ||
65 | <Directory ${frontend}> | |
66 | FallbackResource index.html | |
67 | </Directory> | |
68 | '' | |
69 | ]; | |
70 | }; | |
71 | }; | |
72 | } |