]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Add exported values in mediagoblin module
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 10 May 2019 17:13:59 +0000 (19:13 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 10 May 2019 17:14:36 +0000 (19:14 +0200)
modules/webapps/mediagoblin.nix
nixops/modules/websites/tools/mediagoblin.nix

index 6808c8267b3313693f197a508bd8fa93e2aeeea1..0232aab2efa0e510ecc3c8b71ae9e5845cf979ea 100644 (file)
@@ -6,7 +6,6 @@ let
   uid = config.ids.uids.mediagoblin;
   gid = config.ids.gids.mediagoblin;
 
-  fullPackage = cfg.package.withPlugins cfg.plugins;
   paste_local = pkgs.writeText "paste_local.ini" ''
     [DEFAULT]
     debug = false
@@ -16,8 +15,8 @@ let
 
     [app:mediagoblin]
     use = egg:mediagoblin#app
-    config = ${cfg.configFile} ${fullPackage}/mediagoblin.ini
-    /mgoblin_static = ${fullPackage}/mediagoblin/static
+    config = ${cfg.configFile} ${cfg.workdir}/mediagoblin.ini
+    /mgoblin_static = ${cfg.workdir}/mediagoblin/static
 
     [loggers]
     keys = root
@@ -47,7 +46,7 @@ let
 
     [server:main]
     use = egg:waitress#main
-    unix_socket = ${cfg.socketsDir}/mediagoblin.sock
+    unix_socket = ${cfg.sockets.paster}
     unix_socket_perms = 777
     url_scheme = https
     '';
@@ -99,6 +98,36 @@ in
         Mediagoblin plugins to use.
         '';
     };
+    # Output variables
+    workdir = lib.mkOption {
+      type = lib.types.package;
+      default = cfg.package.withPlugins cfg.plugins;
+      description = ''
+      Adjusted Mediagoblin package with plugins
+      '';
+      readOnly = true;
+    };
+    sockets = lib.mkOption {
+      type = lib.types.attrsOf lib.types.path;
+      default = {
+        paster = "${cfg.socketsDir}/mediagoblin.sock";
+      };
+      readOnly = true;
+      description = ''
+        Mediagoblin sockets
+        '';
+    };
+    pids = lib.mkOption {
+      type = lib.types.attrsOf lib.types.path;
+      default = {
+        paster = "${cfg.socketsDir}/mediagoblin.pid";
+        celery = "${cfg.socketsDir}/mediagoblin-celeryd.pid";
+      };
+      readOnly = true;
+      description = ''
+        Mediagoblin pid files
+        '';
+    };
   };
 
   config = lib.mkIf cfg.enable {
@@ -126,11 +155,11 @@ in
       script = ''
         exec ./bin/paster serve \
           ${paste_local} \
-          --pid-file=${cfg.socketsDir}/mediagoblin.pid
+          --pid-file=${cfg.pids.paster}
         '';
       preStop = ''
         exec ./bin/paster serve \
-          --pid-file=${cfg.socketsDir}/mediagoblin.pid \
+          --pid-file=${cfg.pids.paster} \
           ${paste_local} stop
         '';
       preStart = ''
@@ -143,8 +172,8 @@ in
         Restart = "always";
         TimeoutSec = 15;
         Type = "simple";
-        WorkingDirectory = fullPackage;
-        PIDFile = "${cfg.socketsDir}/mediagoblin.pid";
+        WorkingDirectory = cfg.workdir;
+        PIDFile = cfg.pids.paster;
       };
 
       unitConfig.RequiresMountsFor = cfg.dataDir;
@@ -170,8 +199,8 @@ in
         Restart = "always";
         TimeoutSec = 60;
         Type = "simple";
-        WorkingDirectory = fullPackage;
-        PIDFile = "${cfg.socketsDir}/mediagoblin-celeryd.pid";
+        WorkingDirectory = cfg.workdir;
+        PIDFile = cfg.pids.celery;
       };
 
       unitConfig.RequiresMountsFor = cfg.dataDir;
@@ -184,7 +213,7 @@ in
       install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir}
       if [ -d ${cfg.dataDir}/plugin_static/ ]; then
         rm ${cfg.dataDir}/plugin_static/coreplugin_basic_auth
-        ln -sf ${fullPackage}/mediagoblin/plugins/basic_auth/static ${cfg.dataDir}/plugin_static/coreplugin_basic_auth
+        ln -sf ${cfg.workdir}/mediagoblin/plugins/basic_auth/static ${cfg.dataDir}/plugin_static/coreplugin_basic_auth
       fi
       '';
     };
index bf45e8efddbf065db705c9949eaa11f9202e0bb1..cdc45ae991417a4fdab42b9342280345bcb79620 100644 (file)
@@ -114,8 +114,8 @@ in {
         ProxyPass /theme_static !
         ProxyPass /plugin_static !
         ProxyPassMatch ^/.well-known/acme-challenge !
-        ProxyPass / unix://${mcfg.socketsDir}/mediagoblin.sock|http://mgoblin.immae.eu/
-        ProxyPassReverse / unix://${mcfg.socketsDir}/mediagoblin.sock|http://mgoblin.immae.eu/
+        ProxyPass / unix://${mcfg.sockets.paster}|http://mgoblin.immae.eu/
+        ProxyPassReverse / unix://${mcfg.sockets.paster}|http://mgoblin.immae.eu/
       '' ];
     };
   };