]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Move dav packages to pkgs
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 3 May 2019 22:27:59 +0000 (00:27 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 3 May 2019 22:27:59 +0000 (00:27 +0200)
nixops/modules/websites/tools/dav/davical.nix
nixops/modules/websites/tools/dav/default.nix
nixops/modules/websites/tools/dav/infcloud.nix [deleted file]
pkgs/default.nix
pkgs/webapps/awl/default.nix [new file with mode: 0644]
pkgs/webapps/davical/davical_19eb79ebf9250e5f339675319902458c40ed1755.patch [moved from nixops/modules/websites/tools/dav/davical_19eb79ebf9250e5f339675319902458c40ed1755.patch with 100% similarity]
pkgs/webapps/davical/default.nix [new file with mode: 0644]
pkgs/webapps/default.nix [new file with mode: 0644]
pkgs/webapps/infcloud/default.nix [new file with mode: 0644]
pkgs/webapps/infcloud/infcloud_config.js [moved from nixops/modules/websites/tools/dav/infcloud_config.js with 100% similarity]

index 1e3893fea3ad1a3dcc41903479aef06a5174bcff..6b37f11b3505d206b9101e1210842b31cab3459a 100644 (file)
-{ stdenv, fetchurl, gettext, writeText, env }:
-let
-  awl = stdenv.mkDerivation rec {
-    version = "0.59";
-    name = "awl-${version}";
-    src = fetchurl {
-      url = "https://www.davical.org/downloads/awl_${version}.orig.tar.xz";
-      sha256 = "01b7km7ga3ggbpp8axkc55nizgk5c35fl2z93iydb3hwbxmsvnjp";
-    };
-    unpackCmd = ''
-      tar --one-top-level -xf $curSrc
-    '';
-    installPhase = ''
-      mkdir -p $out
-      cp -ra dba docs inc scripts tests $out
-    '';
-  };
-  davical = rec {
-    keys = [{
-      dest = "webapps/dav-davical";
-      user = apache.user;
-      group = apache.group;
-      permissions = "0400";
-      text = ''
-        <?php
-        $c->pg_connect[] = "dbname=${env.postgresql.database} user=${env.postgresql.user} host=${env.postgresql.socket} password=${env.postgresql.password}";
+{ stdenv, fetchurl, gettext, writeText, env, awl, davical }:
+rec {
+  keys = [{
+    dest = "webapps/dav-davical";
+    user = apache.user;
+    group = apache.group;
+    permissions = "0400";
+    text = ''
+      <?php
+      $c->pg_connect[] = "dbname=${env.postgresql.database} user=${env.postgresql.user} host=${env.postgresql.socket} password=${env.postgresql.password}";
 
-        $c->readonly_webdav_collections = false;
+      $c->readonly_webdav_collections = false;
 
-        $c->admin_email ='davical@tools.immae.eu';
+      $c->admin_email ='davical@tools.immae.eu';
 
-        $c->restrict_setup_to_admin = true;
+      $c->restrict_setup_to_admin = true;
 
-        $c->collections_always_exist = false;
+      $c->collections_always_exist = false;
 
-        $c->external_refresh = 60;
+      $c->external_refresh = 60;
 
-        $c->enable_scheduling = true;
+      $c->enable_scheduling = true;
 
-        $c->iMIP = (object) array("send_email" => true);
+      $c->iMIP = (object) array("send_email" => true);
 
-        $c->authenticate_hook['optional'] = false;
-        $c->authenticate_hook['call'] = 'LDAP_check';
-        $c->authenticate_hook['config'] = array(
-            'host' => 'ldap.immae.eu',
-            'port' => '389',
-            'startTLS' => 'yes',
-            'bindDN'=> 'cn=davical,ou=services,dc=immae,dc=eu',
-            'passDN'=> '${env.ldap.password}',
-            'protocolVersion' => '3',
-            'baseDNUsers'=> array('ou=users,dc=immae,dc=eu', 'ou=group_users,dc=immae,dc=eu'),
-            'filterUsers' => 'memberOf=cn=users,cn=davical,ou=services,dc=immae,dc=eu',
-            'baseDNGroups' => 'ou=groups,dc=immae,dc=eu',
-            'filterGroups' => 'memberOf=cn=groups,cn=davical,ou=services,dc=immae,dc=eu',
-            'mapping_field' => array(
-              "username" => "uid",
-              "fullname" => "cn",
-              "email"    => "mail",
-              "modified" => "modifyTimestamp",
-            ),
-            'format_updated'=> array('Y' => array(0,4),'m' => array(4,2),'d'=> array(6,2),'H' => array(8,2),'M'=>array(10,2),'S' => array(12,2)),
-              /** used to set default value for all users, will be overcharged by ldap if defined also in mapping_field **/
-        //    'default_value' => array("date_format_type" => "E","locale" => "fr_FR"),
-            'group_mapping_field' => array(
-              "username"    => "cn",
-              "updated"     => "modifyTimestamp",
-              "fullname"    => "givenName",
-              "displayname" => "givenName",
-              "members"     => "memberUid",
-              "email"       => "mail",
-            ),
-          );
+      $c->authenticate_hook['optional'] = false;
+      $c->authenticate_hook['call'] = 'LDAP_check';
+      $c->authenticate_hook['config'] = array(
+          'host' => 'ldap.immae.eu',
+          'port' => '389',
+          'startTLS' => 'yes',
+          'bindDN'=> 'cn=davical,ou=services,dc=immae,dc=eu',
+          'passDN'=> '${env.ldap.password}',
+          'protocolVersion' => '3',
+          'baseDNUsers'=> array('ou=users,dc=immae,dc=eu', 'ou=group_users,dc=immae,dc=eu'),
+          'filterUsers' => 'memberOf=cn=users,cn=davical,ou=services,dc=immae,dc=eu',
+          'baseDNGroups' => 'ou=groups,dc=immae,dc=eu',
+          'filterGroups' => 'memberOf=cn=groups,cn=davical,ou=services,dc=immae,dc=eu',
+          'mapping_field' => array(
+            "username" => "uid",
+            "fullname" => "cn",
+            "email"    => "mail",
+            "modified" => "modifyTimestamp",
+          ),
+          'format_updated'=> array('Y' => array(0,4),'m' => array(4,2),'d'=> array(6,2),'H' => array(8,2),'M'=>array(10,2),'S' => array(12,2)),
+            /** used to set default value for all users, will be overcharged by ldap if defined also in mapping_field **/
+      //    'default_value' => array("date_format_type" => "E","locale" => "fr_FR"),
+          'group_mapping_field' => array(
+            "username"    => "cn",
+            "updated"     => "modifyTimestamp",
+            "fullname"    => "givenName",
+            "displayname" => "givenName",
+            "members"     => "memberUid",
+            "email"       => "mail",
+          ),
+        );
 
-        $c->do_not_sync_from_ldap = array('admin' => true);
-        include('drivers_ldap.php');
-      '';
-    }];
-    webapp = stdenv.mkDerivation rec {
-      version = "1.1.7";
-      name = "davical-${version}";
-      src = fetchurl {
-        url = "https://www.davical.org/downloads/davical_${version}.orig.tar.xz";
-        sha256 = "1ar5m2dxr92b204wkdi8z33ir9vz2jbh5k1p74icpv9ywifvjjp9";
-      };
-      unpackCmd = ''
-        tar --one-top-level -xf $curSrc
-      '';
-      makeFlags = "all";
-      patches = [ ./davical_19eb79ebf9250e5f339675319902458c40ed1755.patch ];
-      installPhase = ''
-        mkdir -p $out
-        cp -ra config dba docs htdocs inc locale po scripts testing zonedb $out
-        ln -s /var/secrets/webapps/dav-davical $out/config/config.php
-      '';
-      buildInputs = [ gettext ];
-    };
-    webRoot = "${webapp}/htdocs";
-    apache = rec {
-      user = "wwwrun";
-      group = "wwwrun";
-      modules = [ "proxy_fcgi" ];
-      webappName = "tools_davical";
-      root = "/run/current-system/webapps/${webappName}";
-      vhostConf = ''
-        Alias /davical "${root}"
-        Alias /caldav.php  "${root}/caldav.php"
-        <Directory "${root}">
-          DirectoryIndex index.php index.html
-          AcceptPathInfo On
-          AllowOverride None
-          Require all granted
+      $c->do_not_sync_from_ldap = array('admin' => true);
+      include('drivers_ldap.php');
+    '';
+  }];
+  webapp = davical.override { config = "/var/secrets/webapps/dav-davical"; };
+  webRoot = "${webapp}/htdocs";
+  apache = rec {
+    user = "wwwrun";
+    group = "wwwrun";
+    modules = [ "proxy_fcgi" ];
+    webappName = "tools_davical";
+    root = "/run/current-system/webapps/${webappName}";
+    vhostConf = ''
+      Alias /davical "${root}"
+      Alias /caldav.php  "${root}/caldav.php"
+      <Directory "${root}">
+        DirectoryIndex index.php index.html
+        AcceptPathInfo On
+        AllowOverride None
+        Require all granted
 
-          <FilesMatch "\.php$">
-            CGIPassAuth on
-            SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
-          </FilesMatch>
+        <FilesMatch "\.php$">
+          CGIPassAuth on
+          SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
+        </FilesMatch>
 
-          RewriteEngine On
-          <IfModule mod_headers.c>
-                  Header unset Access-Control-Allow-Origin
-                  Header unset Access-Control-Allow-Methods
-                  Header unset Access-Control-Allow-Headers
-                  Header unset Access-Control-Allow-Credentials
-                  Header unset Access-Control-Expose-Headers
+        RewriteEngine On
+        <IfModule mod_headers.c>
+                Header unset Access-Control-Allow-Origin
+                Header unset Access-Control-Allow-Methods
+                Header unset Access-Control-Allow-Headers
+                Header unset Access-Control-Allow-Credentials
+                Header unset Access-Control-Expose-Headers
 
-                  Header always set Access-Control-Allow-Origin "*"
-                  Header always set Access-Control-Allow-Methods "GET,POST,OPTIONS,PROPFIND,PROPPATCH,REPORT,PUT,MOVE,DELETE,LOCK,UNLOCK"
-                  Header always set Access-Control-Allow-Headers "User-Agent,Authorization,Content-type,Depth,If-match,If-None-Match,Lock-Token,Timeout,Destination,Overwrite,Prefer,X-client,X-Requested-With"
-                  Header always set Access-Control-Allow-Credentials false
-                  Header always set Access-Control-Expose-Headers "Etag,Preference-Applied"
+                Header always set Access-Control-Allow-Origin "*"
+                Header always set Access-Control-Allow-Methods "GET,POST,OPTIONS,PROPFIND,PROPPATCH,REPORT,PUT,MOVE,DELETE,LOCK,UNLOCK"
+                Header always set Access-Control-Allow-Headers "User-Agent,Authorization,Content-type,Depth,If-match,If-None-Match,Lock-Token,Timeout,Destination,Overwrite,Prefer,X-client,X-Requested-With"
+                Header always set Access-Control-Allow-Credentials false
+                Header always set Access-Control-Expose-Headers "Etag,Preference-Applied"
 
-                  RewriteCond %{HTTP:Access-Control-Request-Method} !^$
-                  RewriteCond %{REQUEST_METHOD} OPTIONS
-                  RewriteRule ^(.*)$ $1 [R=200,L]
-          </IfModule>
-        </Directory>
-        '';
-    };
-    phpFpm = rec {
-      serviceDeps = [ "postgresql.service" "openldap.service" ];
-      basedir = builtins.concatStringsSep ":" [ webapp "/var/secrets/webapps/dav-davical" awl ];
-      socket = "/var/run/phpfpm/davical.sock";
-      pool = ''
-        listen = ${socket}
-        user = ${apache.user}
-        group = ${apache.group}
-        listen.owner = ${apache.user}
-        listen.group = ${apache.group}
-        pm = dynamic
-        pm.max_children = 60
-        pm.start_servers = 2
-        pm.min_spare_servers = 1
-        pm.max_spare_servers = 10
+                RewriteCond %{HTTP:Access-Control-Request-Method} !^$
+                RewriteCond %{REQUEST_METHOD} OPTIONS
+                RewriteRule ^(.*)$ $1 [R=200,L]
+        </IfModule>
+      </Directory>
+      '';
+  };
+  phpFpm = rec {
+    serviceDeps = [ "postgresql.service" "openldap.service" ];
+    basedir = builtins.concatStringsSep ":" [ webapp "/var/secrets/webapps/dav-davical" awl ];
+    socket = "/var/run/phpfpm/davical.sock";
+    pool = ''
+      listen = ${socket}
+      user = ${apache.user}
+      group = ${apache.group}
+      listen.owner = ${apache.user}
+      listen.group = ${apache.group}
+      pm = dynamic
+      pm.max_children = 60
+      pm.start_servers = 2
+      pm.min_spare_servers = 1
+      pm.max_spare_servers = 10
 
-        ; Needed to avoid clashes in browser cookies (same domain)
-        php_value[session.name] = DavicalPHPSESSID
-        php_admin_value[open_basedir] = "${basedir}:/tmp:/var/lib/php/sessions/davical"
-        php_admin_value[include_path] = "${awl}/inc:${webapp}/inc"
-        php_admin_value[session.save_path] = "/var/lib/php/sessions/davical"
-        php_flag[magic_quotes_gpc] = Off
-        php_flag[register_globals] = Off
-        php_admin_value[error_reporting] = "E_ALL & ~E_NOTICE"
-        php_admin_value[default_charset] = "utf-8"
-        php_flag[magic_quotes_runtime] = Off
-        '';
-    };
+      ; Needed to avoid clashes in browser cookies (same domain)
+      php_value[session.name] = DavicalPHPSESSID
+      php_admin_value[open_basedir] = "${basedir}:/tmp:/var/lib/php/sessions/davical"
+      php_admin_value[include_path] = "${awl}/inc:${webapp}/inc"
+      php_admin_value[session.save_path] = "/var/lib/php/sessions/davical"
+      php_flag[magic_quotes_gpc] = Off
+      php_flag[register_globals] = Off
+      php_admin_value[error_reporting] = "E_ALL & ~E_NOTICE"
+      php_admin_value[default_charset] = "utf-8"
+      php_flag[magic_quotes_runtime] = Off
+      '';
   };
-in
-  davical
+}
index 2a82a1d79fb8d522a502c0d757e772992f8fa589..c24f8db45a00b0b95e8d8614d113491f2028cf0e 100644 (file)
@@ -1,8 +1,23 @@
 { lib, pkgs, config, myconfig, mylibs, ... }:
 let
-    infcloud = pkgs.callPackage ./infcloud.nix {};
+    infcloud = rec {
+      webappName = "tools_infcloud";
+      root = "/run/current-system/webapps/${webappName}";
+      vhostConf = ''
+          Alias /carddavmate ${root}
+          Alias /caldavzap ${root}
+          Alias /infcloud ${root}
+          <Directory ${root}>
+            AllowOverride All
+            Options FollowSymlinks
+            Require all granted
+            DirectoryIndex index.html
+          </Directory>
+      '';
+    };
     davical = pkgs.callPackage ./davical.nix {
       env = myconfig.env.tools.davical;
+      inherit (pkgs.webapps) davical awl;
     };
 
     cfg = config.services.myWebsites.tools.dav;
@@ -22,7 +37,7 @@ in {
       hosts       = ["dav.immae.eu" ];
       root        = null;
       extraConfig = [
-        infcloud.apache.vhostConf
+        infcloud.vhostConf
         davical.apache.vhostConf
       ];
     };
@@ -34,7 +49,7 @@ in {
     system.extraSystemBuilderCmds = ''
       mkdir -p $out/webapps
       ln -s ${davical.webRoot} $out/webapps/${davical.apache.webappName}
-      ln -s ${infcloud.webRoot} $out/webapps/${infcloud.apache.webappName}
+      ln -s ${pkgs.webapps.infcloud} $out/webapps/${infcloud.webappName}
       '';
   };
 }
diff --git a/nixops/modules/websites/tools/dav/infcloud.nix b/nixops/modules/websites/tools/dav/infcloud.nix
deleted file mode 100644 (file)
index f1204ab..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-{ stdenv, fetchzip, ed }:
-let
-  infcloud = rec {
-    webRoot = stdenv.mkDerivation rec {
-      version = "0.13.1";
-      name = "InfCloud-${version}";
-      src = fetchzip {
-        url = "https://www.inf-it.com/InfCloud_${version}.zip";
-        sha256 = "1fjhs0cj0b9fhf5ysfz281mknmmg1z551bas143sxfcqlpa5aiiq";
-      };
-      buildPhase = ''
-        ./cache_update.sh
-        rm config.js
-      '';
-      installPhase = ''
-        cp -a . $out
-        ln -s ${./infcloud_config.js} $out/config.js
-      '';
-      buildInputs = [ ed ];
-    };
-    apache = rec {
-      user = "wwwrun";
-      group = "wwwrun";
-      webappName = "tools_infcloud";
-      root = "/run/current-system/webapps/${webappName}";
-      vhostConf = ''
-        Alias /carddavmate ${root}
-        Alias /caldavzap ${root}
-        Alias /infcloud ${root}
-        <Directory ${root}>
-          AllowOverride All
-          Options FollowSymlinks
-          Require all granted
-          DirectoryIndex index.html
-        </Directory>
-        '';
-    };
-  };
-in
-  infcloud
index d1d8fa497bcaa69e96879a0240d9c064ab03cf6a..0833cc22bdb43f3296f42c45a409d3b817cdc6f6 100644 (file)
@@ -34,7 +34,5 @@ in
   mpd = (callPackage ../pkgs/mpd_0_21 {}).mpd;
   mpd-small = (callPackage ../pkgs/mpd_0_21 {}).mpd-small;
 
-  webapps = {
-    mastodon = (callPackage ./webapps/mastodon { inherit mylibs; });
-  };
+  webapps = callPackage ./webapps { inherit mylibs; };
 }
diff --git a/pkgs/webapps/awl/default.nix b/pkgs/webapps/awl/default.nix
new file mode 100644 (file)
index 0000000..8564fc3
--- /dev/null
@@ -0,0 +1,16 @@
+{ stdenv, fetchurl }:
+stdenv.mkDerivation rec {
+  version = "0.59";
+  name = "awl-${version}";
+  src = fetchurl {
+    url = "https://www.davical.org/downloads/awl_${version}.orig.tar.xz";
+    sha256 = "01b7km7ga3ggbpp8axkc55nizgk5c35fl2z93iydb3hwbxmsvnjp";
+  };
+  unpackCmd = ''
+    tar --one-top-level -xf $curSrc
+  '';
+  installPhase = ''
+    mkdir -p $out
+    cp -ra dba docs inc scripts tests $out
+  '';
+}
diff --git a/pkgs/webapps/davical/default.nix b/pkgs/webapps/davical/default.nix
new file mode 100644 (file)
index 0000000..fefc00f
--- /dev/null
@@ -0,0 +1,20 @@
+{ config ? "/etc/davical/config.php", stdenv, fetchurl, gettext }:
+stdenv.mkDerivation rec {
+  version = "1.1.7";
+  name = "davical-${version}";
+  src = fetchurl {
+    url = "https://www.davical.org/downloads/davical_${version}.orig.tar.xz";
+    sha256 = "1ar5m2dxr92b204wkdi8z33ir9vz2jbh5k1p74icpv9ywifvjjp9";
+  };
+  unpackCmd = ''
+    tar --one-top-level -xf $curSrc
+  '';
+  makeFlags = "all";
+  patches = [ ./davical_19eb79ebf9250e5f339675319902458c40ed1755.patch ];
+  installPhase = ''
+    mkdir -p $out
+    cp -ra config dba docs htdocs inc locale po scripts testing zonedb $out
+    ln -s ${config} $out/config/config.php
+  '';
+  buildInputs = [ gettext ];
+}
diff --git a/pkgs/webapps/default.nix b/pkgs/webapps/default.nix
new file mode 100644 (file)
index 0000000..94d2157
--- /dev/null
@@ -0,0 +1,7 @@
+{ callPackage, mylibs }:
+{
+  mastodon = callPackage ./mastodon { inherit mylibs; };
+  awl = callPackage ./awl {};
+  davical = callPackage ./davical {};
+  infcloud = callPackage ./infcloud {};
+}
diff --git a/pkgs/webapps/infcloud/default.nix b/pkgs/webapps/infcloud/default.nix
new file mode 100644 (file)
index 0000000..0d73f52
--- /dev/null
@@ -0,0 +1,18 @@
+{ infcloud_config ? ./infcloud_config.js, stdenv, fetchzip, ed }:
+stdenv.mkDerivation rec {
+  version = "0.13.1";
+  name = "InfCloud-${version}";
+  src = fetchzip {
+    url = "https://www.inf-it.com/InfCloud_${version}.zip";
+    sha256 = "1fjhs0cj0b9fhf5ysfz281mknmmg1z551bas143sxfcqlpa5aiiq";
+  };
+  buildPhase = ''
+    ./cache_update.sh
+    rm config.js
+    '';
+  installPhase = ''
+    cp -a . $out
+    ln -s ${infcloud_config} $out/config.js
+    '';
+  buildInputs = [ ed ];
+}