diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-01-25 23:15:08 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-01-25 23:15:08 +0100 |
commit | 01f21083a897b86bf148f1d2bb9c8edca4d3786a (patch) | |
tree | 784f04e9b6ef99a49e572c84e4b7ab40b5eb5fde /nixops/modules/websites/tools/mediagoblin/default.nix | |
parent | bfe3c9c9df0c5112bc8806483292b55ed0f7e02d (diff) | |
download | Nix-01f21083a897b86bf148f1d2bb9c8edca4d3786a.tar.gz Nix-01f21083a897b86bf148f1d2bb9c8edca4d3786a.tar.zst Nix-01f21083a897b86bf148f1d2bb9c8edca4d3786a.zip |
Rename virtual folder to nixops
Fixes https://git.immae.eu/mantisbt/view.php?id=82
Diffstat (limited to 'nixops/modules/websites/tools/mediagoblin/default.nix')
-rw-r--r-- | nixops/modules/websites/tools/mediagoblin/default.nix | 147 |
1 files changed, 147 insertions, 0 deletions
diff --git a/nixops/modules/websites/tools/mediagoblin/default.nix b/nixops/modules/websites/tools/mediagoblin/default.nix new file mode 100644 index 0000000..5f60503 --- /dev/null +++ b/nixops/modules/websites/tools/mediagoblin/default.nix | |||
@@ -0,0 +1,147 @@ | |||
1 | { lib, pkgs, config, myconfig, mylibs, ... }: | ||
2 | let | ||
3 | mediagoblin = pkgs.callPackage ./mediagoblin.nix { | ||
4 | inherit (mylibs) fetchedGit fetchedGithub; | ||
5 | env = myconfig.env.tools.mediagoblin; | ||
6 | }; | ||
7 | |||
8 | cfg = config.services.myWebsites.tools.mediagoblin; | ||
9 | in { | ||
10 | options.services.myWebsites.tools.mediagoblin = { | ||
11 | enable = lib.mkEnableOption "enable mediagoblin's website"; | ||
12 | }; | ||
13 | |||
14 | config = lib.mkIf cfg.enable { | ||
15 | ids.uids.mediagoblin = 397; | ||
16 | ids.gids.mediagoblin = 397; | ||
17 | |||
18 | users.users.mediagoblin = { | ||
19 | name = "mediagoblin"; | ||
20 | uid = config.ids.uids.mediagoblin; | ||
21 | group = "mediagoblin"; | ||
22 | description = "Mediagoblin user"; | ||
23 | home = mediagoblin.varDir; | ||
24 | useDefaultShell = true; | ||
25 | }; | ||
26 | |||
27 | users.groups.mediagoblin.gid = config.ids.gids.mediagoblin; | ||
28 | |||
29 | systemd.services.mediagoblin-web = { | ||
30 | description = "Mediagoblin service"; | ||
31 | wantedBy = [ "multi-user.target" ]; | ||
32 | after = [ "network.target" ]; | ||
33 | |||
34 | environment.SCRIPT_NAME = "/mediagoblin/"; | ||
35 | |||
36 | script = '' | ||
37 | exec ./bin/paster serve \ | ||
38 | ${mediagoblin.pythonRoot}/paste_local.ini \ | ||
39 | --pid-file=${mediagoblin.socketsDir}/mediagoblin.pid | ||
40 | ''; | ||
41 | |||
42 | preStop = '' | ||
43 | exec ./bin/paster serve \ | ||
44 | --pid-file=${mediagoblin.socketsDir}/mediagoblin.pid \ | ||
45 | ${mediagoblin.pythonRoot}/paste_local.ini stop | ||
46 | ''; | ||
47 | preStart = '' | ||
48 | ./bin/gmg dbupdate | ||
49 | ''; | ||
50 | |||
51 | serviceConfig = { | ||
52 | User = "mediagoblin"; | ||
53 | PrivateTmp = true; | ||
54 | Restart = "always"; | ||
55 | TimeoutSec = 15; | ||
56 | Type = "simple"; | ||
57 | WorkingDirectory = mediagoblin.pythonRoot; | ||
58 | PIDFile = "${mediagoblin.socketsDir}/mediagoblin.pid"; | ||
59 | }; | ||
60 | |||
61 | unitConfig.RequiresMountsFor = mediagoblin.varDir; | ||
62 | }; | ||
63 | |||
64 | systemd.services.mediagoblin-celeryd = { | ||
65 | description = "Mediagoblin service"; | ||
66 | wantedBy = [ "multi-user.target" ]; | ||
67 | after = [ "network.target" "mediagoblin-web.service" ]; | ||
68 | |||
69 | environment.MEDIAGOBLIN_CONFIG = "${mediagoblin.pythonRoot}/mediagoblin_local.ini"; | ||
70 | environment.CELERY_CONFIG_MODULE = "mediagoblin.init.celery.from_celery"; | ||
71 | |||
72 | script = '' | ||
73 | exec ./bin/celery worker \ | ||
74 | --logfile=${mediagoblin.varDir}/celery.log \ | ||
75 | --loglevel=INFO | ||
76 | ''; | ||
77 | |||
78 | serviceConfig = { | ||
79 | User = "mediagoblin"; | ||
80 | PrivateTmp = true; | ||
81 | Restart = "always"; | ||
82 | TimeoutSec = 60; | ||
83 | Type = "simple"; | ||
84 | WorkingDirectory = mediagoblin.pythonRoot; | ||
85 | PIDFile = "${mediagoblin.socketsDir}/mediagoblin-celeryd.pid"; | ||
86 | }; | ||
87 | |||
88 | unitConfig.RequiresMountsFor = mediagoblin.varDir; | ||
89 | }; | ||
90 | |||
91 | system.activationScripts.mediagoblin = { | ||
92 | deps = [ "users" ]; | ||
93 | text = '' | ||
94 | install -m 0755 -o mediagoblin -g mediagoblin -d ${mediagoblin.socketsDir} | ||
95 | install -m 0755 -o mediagoblin -g mediagoblin -d ${mediagoblin.varDir} | ||
96 | if [ -d ${mediagoblin.varDir}/plugin_static/ ]; then | ||
97 | rm ${mediagoblin.varDir}/plugin_static/coreplugin_basic_auth | ||
98 | ln -sf ${mediagoblin.pythonRoot}/mediagoblin/plugins/basic_auth/static ${mediagoblin.varDir}/plugin_static/coreplugin_basic_auth | ||
99 | fi | ||
100 | ''; | ||
101 | }; | ||
102 | |||
103 | services.myWebsites.tools.modules = [ | ||
104 | "proxy" "proxy_http" "proxy_balancer" | ||
105 | "lbmethod_byrequests" "lbmethod_bytraffic" "lbmethod_bybusyness" "lbmethod_heartbeat" | ||
106 | ]; | ||
107 | users.users.wwwrun.extraGroups = [ "mediagoblin" ]; | ||
108 | security.acme.certs."eldiron".extraDomains."mgoblin.immae.eu" = null; | ||
109 | services.myWebsites.tools.vhostConfs.mgoblin = { | ||
110 | certName = "eldiron"; | ||
111 | hosts = ["mgoblin.immae.eu" ]; | ||
112 | root = null; | ||
113 | extraConfig = [ '' | ||
114 | Alias /mgoblin_media ${mediagoblin.varDir}/media/public | ||
115 | <Directory ${mediagoblin.varDir}/media/public> | ||
116 | Options -Indexes +FollowSymLinks +MultiViews +Includes | ||
117 | Require all granted | ||
118 | </Directory> | ||
119 | |||
120 | Alias /theme_static ${mediagoblin.varDir}/theme_static | ||
121 | <Directory ${mediagoblin.varDir}/theme_static> | ||
122 | Options -Indexes +FollowSymLinks +MultiViews +Includes | ||
123 | Require all granted | ||
124 | </Directory> | ||
125 | |||
126 | Alias /plugin_static ${mediagoblin.varDir}/plugin_static | ||
127 | <Directory ${mediagoblin.varDir}/plugin_static> | ||
128 | Options -Indexes +FollowSymLinks +MultiViews +Includes | ||
129 | Require all granted | ||
130 | </Directory> | ||
131 | |||
132 | ProxyPreserveHost on | ||
133 | ProxyVia On | ||
134 | ProxyRequests Off | ||
135 | ProxyPass /mgoblin_media ! | ||
136 | ProxyPass /theme_static ! | ||
137 | ProxyPass /plugin_static ! | ||
138 | ProxyPassMatch ^/.well-known/acme-challenge ! | ||
139 | ProxyPass / balancer://paster_server/ | ||
140 | ProxyPassReverse / balancer://paster_server | ||
141 | <Proxy balancer://paster_server> | ||
142 | BalancerMember unix://${mediagoblin.socketsDir}/mediagoblin.sock|http:// | ||
143 | </Proxy> | ||
144 | '' ]; | ||
145 | }; | ||
146 | }; | ||
147 | } | ||