diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-05-22 20:01:33 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-05-22 20:01:33 +0200 |
commit | 4288c2f2431fb782b0d512b1b3749187f2374b6a (patch) | |
tree | aaf812414f91d6b695a7507265e7572de8dc477c /modules/private/websites/tools/git | |
parent | f40f5b235b890f46770a22f005f8a0f664cf0562 (diff) | |
download | Nix-4288c2f2431fb782b0d512b1b3749187f2374b6a.tar.gz Nix-4288c2f2431fb782b0d512b1b3749187f2374b6a.tar.zst Nix-4288c2f2431fb782b0d512b1b3749187f2374b6a.zip |
Move websites/tools to modules
Diffstat (limited to 'modules/private/websites/tools/git')
-rw-r--r-- | modules/private/websites/tools/git/default.nix | 43 | ||||
-rw-r--r-- | modules/private/websites/tools/git/gitweb.nix | 64 | ||||
-rw-r--r-- | modules/private/websites/tools/git/mantisbt.nix | 96 |
3 files changed, 203 insertions, 0 deletions
diff --git a/modules/private/websites/tools/git/default.nix b/modules/private/websites/tools/git/default.nix new file mode 100644 index 0000000..3e8b605 --- /dev/null +++ b/modules/private/websites/tools/git/default.nix | |||
@@ -0,0 +1,43 @@ | |||
1 | { lib, pkgs, config, myconfig, ... }: | ||
2 | let | ||
3 | mantisbt = pkgs.callPackage ./mantisbt.nix { | ||
4 | inherit (pkgs.webapps) mantisbt_2 mantisbt_2-plugins; | ||
5 | env = myconfig.env.tools.mantisbt; | ||
6 | }; | ||
7 | gitweb = pkgs.callPackage ./gitweb.nix { gitoliteDir = config.services.myGitolite.gitoliteDir; }; | ||
8 | |||
9 | cfg = config.myServices.websites.tools.git; | ||
10 | in { | ||
11 | options.myServices.websites.tools.git = { | ||
12 | enable = lib.mkEnableOption "enable git's website"; | ||
13 | }; | ||
14 | |||
15 | config = lib.mkIf cfg.enable { | ||
16 | secrets.keys = mantisbt.keys; | ||
17 | services.websites.tools.modules = | ||
18 | gitweb.apache.modules ++ | ||
19 | mantisbt.apache.modules; | ||
20 | myServices.websites.webappDirs."${gitweb.apache.webappName}" = gitweb.webRoot; | ||
21 | myServices.websites.webappDirs."${mantisbt.apache.webappName}" = mantisbt.webRoot; | ||
22 | |||
23 | system.activationScripts.mantisbt = mantisbt.activationScript; | ||
24 | services.websites.tools.vhostConfs.git = { | ||
25 | certName = "eldiron"; | ||
26 | addToCerts = true; | ||
27 | hosts = ["git.immae.eu" ]; | ||
28 | root = gitweb.apache.root; | ||
29 | extraConfig = [ | ||
30 | gitweb.apache.vhostConf | ||
31 | mantisbt.apache.vhostConf | ||
32 | '' | ||
33 | RewriteEngine on | ||
34 | RewriteCond %{REQUEST_URI} ^/releases | ||
35 | RewriteRule /releases(.*) https://release.immae.eu$1 [P,L] | ||
36 | '' | ||
37 | ]; | ||
38 | }; | ||
39 | services.phpfpm.poolConfigs = { | ||
40 | mantisbt = mantisbt.phpFpm.pool; | ||
41 | }; | ||
42 | }; | ||
43 | } | ||
diff --git a/modules/private/websites/tools/git/gitweb.nix b/modules/private/websites/tools/git/gitweb.nix new file mode 100644 index 0000000..2ee7a63 --- /dev/null +++ b/modules/private/websites/tools/git/gitweb.nix | |||
@@ -0,0 +1,64 @@ | |||
1 | { gitweb, writeText, gitolite, git, gitoliteDir, highlight }: | ||
2 | rec { | ||
3 | varDir = gitoliteDir; | ||
4 | webRoot = gitweb; | ||
5 | config = writeText "gitweb.conf" '' | ||
6 | $git_temp = "/tmp"; | ||
7 | |||
8 | # The directories where your projects are. Must not end with a | ||
9 | # slash. | ||
10 | $projectroot = "${varDir}/repositories"; | ||
11 | |||
12 | $projects_list = "${varDir}/projects.list"; | ||
13 | $strict_export = "true"; | ||
14 | |||
15 | # Base URLs for links displayed in the web interface. | ||
16 | our @git_base_url_list = qw(ssh://gitolite@git.immae.eu https://git.immae.eu); | ||
17 | |||
18 | $feature{'blame'}{'default'} = [1]; | ||
19 | $feature{'avatar'}{'default'} = ['gravatar']; | ||
20 | $feature{'highlight'}{'default'} = [1]; | ||
21 | |||
22 | @stylesheets = ("gitweb-theme/gitweb.css"); | ||
23 | $logo = "gitweb-theme/git-logo.png"; | ||
24 | $favicon = "gitweb-theme/git-favicon.png"; | ||
25 | $javascript = "gitweb-theme/gitweb.js"; | ||
26 | $logo_url = "https://git.immae.eu/"; | ||
27 | $projects_list_group_categories = "true"; | ||
28 | $projects_list_description_width = 60; | ||
29 | $project_list_default_category = "__Others__"; | ||
30 | $highlight_bin = "${highlight}/bin/highlight"; | ||
31 | ''; | ||
32 | apache = rec { | ||
33 | user = "wwwrun"; | ||
34 | group = "wwwrun"; | ||
35 | modules = [ "cgid" ]; | ||
36 | webappName = "tools_gitweb"; | ||
37 | root = "/run/current-system/webapps/${webappName}"; | ||
38 | vhostConf = '' | ||
39 | SetEnv GIT_PROJECT_ROOT ${varDir}/repositories/ | ||
40 | ScriptAliasMatch \ | ||
41 | "(?x)^/(.*/(HEAD | \ | ||
42 | info/refs | \ | ||
43 | objects/(info/[^/]+ | \ | ||
44 | [0-9a-f]{2}/[0-9a-f]{38} | \ | ||
45 | pack/pack-[0-9a-f]{40}\.(pack|idx)) | \ | ||
46 | git-(upload|receive)-pack))$" \ | ||
47 | ${git}/libexec/git-core/git-http-backend/$1 | ||
48 | |||
49 | <Directory "${git}/libexec/git-core"> | ||
50 | Require all granted | ||
51 | </Directory> | ||
52 | <Directory "${root}"> | ||
53 | DirectoryIndex gitweb.cgi | ||
54 | Require all granted | ||
55 | AllowOverride None | ||
56 | Options ExecCGI FollowSymLinks | ||
57 | <Files gitweb.cgi> | ||
58 | SetHandler cgi-script | ||
59 | SetEnv GITWEB_CONFIG "${config}" | ||
60 | </Files> | ||
61 | </Directory> | ||
62 | ''; | ||
63 | }; | ||
64 | } | ||
diff --git a/modules/private/websites/tools/git/mantisbt.nix b/modules/private/websites/tools/git/mantisbt.nix new file mode 100644 index 0000000..a1b830e --- /dev/null +++ b/modules/private/websites/tools/git/mantisbt.nix | |||
@@ -0,0 +1,96 @@ | |||
1 | { env, mantisbt_2, mantisbt_2-plugins }: | ||
2 | rec { | ||
3 | activationScript = { | ||
4 | deps = [ "httpd" ]; | ||
5 | text = '' | ||
6 | install -m 0755 -o ${apache.user} -g ${apache.group} -d /var/lib/php/sessions/mantisbt | ||
7 | ''; | ||
8 | }; | ||
9 | keys = [{ | ||
10 | dest = "webapps/tools-mantisbt"; | ||
11 | user = apache.user; | ||
12 | group = apache.group; | ||
13 | permissions = "0400"; | ||
14 | text = '' | ||
15 | <?php | ||
16 | $g_hostname = '${env.postgresql.socket}'; | ||
17 | $g_db_username = '${env.postgresql.user}'; | ||
18 | $g_db_password = '${env.postgresql.password}'; | ||
19 | $g_database_name = '${env.postgresql.database}'; | ||
20 | $g_db_type = 'pgsql'; | ||
21 | $g_crypto_master_salt = '${env.master_salt}'; | ||
22 | $g_allow_signup = OFF; | ||
23 | $g_allow_anonymous_login = ON; | ||
24 | $g_anonymous_account = 'anonymous'; | ||
25 | |||
26 | $g_phpMailer_method = PHPMAILER_METHOD_SENDMAIL; | ||
27 | $g_smtp_host = 'localhost'; | ||
28 | $g_smtp_username = '''; | ||
29 | $g_smtp_password = '''; | ||
30 | $g_webmaster_email = 'mantisbt@tools.immae.eu'; | ||
31 | $g_from_email = 'mantisbt@tools.immae.eu'; | ||
32 | $g_return_path_email = 'mantisbt@tools.immae.eu'; | ||
33 | $g_from_name = 'Mantis Bug Tracker at git.immae.eu'; | ||
34 | $g_email_receive_own = OFF; | ||
35 | # --- LDAP --- | ||
36 | $g_login_method = LDAP; | ||
37 | $g_ldap_protocol_version = 3; | ||
38 | $g_ldap_server = 'ldaps://ldap.immae.eu:636'; | ||
39 | $g_ldap_root_dn = 'ou=users,dc=immae,dc=eu'; | ||
40 | $g_ldap_bind_dn = 'cn=mantisbt,ou=services,dc=immae,dc=eu'; | ||
41 | $g_ldap_bind_passwd = '${env.ldap.password}'; | ||
42 | $g_use_ldap_email = ON; | ||
43 | $g_use_ldap_realname = ON; | ||
44 | $g_ldap_uid_field = 'uid'; | ||
45 | $g_ldap_realname_field = 'cn'; | ||
46 | $g_ldap_organization = '(memberOf=cn=users,cn=mantisbt,ou=services,dc=immae,dc=eu)'; | ||
47 | ''; | ||
48 | }]; | ||
49 | webRoot = (mantisbt_2.override { mantis_config = "/var/secrets/webapps/tools-mantisbt"; }).withPlugins (builtins.attrValues mantisbt_2-plugins); | ||
50 | apache = rec { | ||
51 | user = "wwwrun"; | ||
52 | group = "wwwrun"; | ||
53 | modules = [ "proxy_fcgi" ]; | ||
54 | webappName = "tools_mantisbt"; | ||
55 | root = "/run/current-system/webapps/${webappName}"; | ||
56 | vhostConf = '' | ||
57 | Alias /mantisbt "${root}" | ||
58 | <Directory "${root}"> | ||
59 | DirectoryIndex index.php | ||
60 | <FilesMatch "\.php$"> | ||
61 | SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" | ||
62 | </FilesMatch> | ||
63 | |||
64 | AllowOverride All | ||
65 | Options FollowSymlinks | ||
66 | Require all granted | ||
67 | </Directory> | ||
68 | <Directory "${root}/admin"> | ||
69 | #Reenable during upgrade | ||
70 | Require all denied | ||
71 | </Directory> | ||
72 | ''; | ||
73 | }; | ||
74 | phpFpm = rec { | ||
75 | serviceDeps = [ "postgresql.service" "openldap.service" ]; | ||
76 | basedir = builtins.concatStringsSep ":" ( | ||
77 | [ webRoot "/var/secrets/webapps/tools-mantisbt" ] | ||
78 | ++ webRoot.plugins); | ||
79 | socket = "/var/run/phpfpm/mantisbt.sock"; | ||
80 | pool = '' | ||
81 | listen = ${socket} | ||
82 | user = ${apache.user} | ||
83 | group = ${apache.group} | ||
84 | listen.owner = ${apache.user} | ||
85 | listen.group = ${apache.group} | ||
86 | pm = ondemand | ||
87 | pm.max_children = 60 | ||
88 | pm.process_idle_timeout = 60 | ||
89 | |||
90 | php_admin_value[upload_max_filesize] = 5000000 | ||
91 | |||
92 | php_admin_value[open_basedir] = "${basedir}:/tmp:/var/lib/php/sessions/mantisbt" | ||
93 | php_admin_value[session.save_path] = "/var/lib/php/sessions/mantisbt" | ||
94 | ''; | ||
95 | }; | ||
96 | } | ||