about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorgnidorah <gnidorah@users.noreply.github.com>2018-03-29 16:42:49 +0300
committergnidorah <gnidorah@users.noreply.github.com>2018-03-29 16:45:32 +0300
commit2821d3fed74a209c8771402ce8058fd4188357ad (patch)
tree9e14502d911314ed0df2e4e90f8e2fecbc21a495 /nixos
parent69a0c9721e4cd66739971d499a67988f8412e5d7 (diff)
gitweb: use common options
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/misc/gitweb.nix50
-rw-r--r--nixos/modules/services/web-servers/lighttpd/gitweb.nix33
-rw-r--r--nixos/modules/services/web-servers/nginx/gitweb.nix33
4 files changed, 57 insertions, 60 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index b5bc8b6b9de41..1a73cef984ebe 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -325,6 +325,7 @@
   #./services/misc/gitit.nix
   ./services/misc/gitlab.nix
   ./services/misc/gitolite.nix
+  ./services/misc/gitweb.nix
   ./services/misc/gogs.nix
   ./services/misc/gollum.nix
   ./services/misc/gpsd.nix
diff --git a/nixos/modules/services/misc/gitweb.nix b/nixos/modules/services/misc/gitweb.nix
new file mode 100644
index 0000000000000..8e4d85a1e15f7
--- /dev/null
+++ b/nixos/modules/services/misc/gitweb.nix
@@ -0,0 +1,50 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.services.gitweb;
+
+in
+{
+
+  options.services.gitweb = {
+
+    projectroot = mkOption {
+      default = "/srv/git";
+      type = types.path;
+      description = ''
+        Path to git projects (bare repositories) that should be served by
+        gitweb. Must not end with a slash.
+      '';
+    };
+
+    extraConfig = mkOption {
+      default = "";
+      type = types.lines;
+      description = ''
+        Verbatim configuration text appended to the generated gitweb.conf file.
+      '';
+      example = ''
+        $feature{'highlight'}{'default'} = [1];
+        $feature{'ctags'}{'default'} = [1];
+      '';
+    };
+
+    gitwebConfigFile = mkOption {
+      default = pkgs.writeText "gitweb.conf" ''
+        # path to git projects (<project>.git)
+        $projectroot = "${cfg.projectroot}";
+        $highlight_bin = "${pkgs.highlight}/bin/highlight";
+        ${cfg.extraConfig}
+      '';
+      type = types.path;
+      readOnly = true;
+      internal = true;
+    };
+
+  };
+
+  meta.maintainers = with maintainers; [ gnidorah ];
+
+}
diff --git a/nixos/modules/services/web-servers/lighttpd/gitweb.nix b/nixos/modules/services/web-servers/lighttpd/gitweb.nix
index 2f220c9ec53dc..37128d90401d7 100644
--- a/nixos/modules/services/web-servers/lighttpd/gitweb.nix
+++ b/nixos/modules/services/web-servers/lighttpd/gitweb.nix
@@ -3,13 +3,7 @@
 with lib;
 
 let
-  cfg = config.services.lighttpd.gitweb;
-  gitwebConfigFile = pkgs.writeText "gitweb.conf" ''
-    # path to git projects (<project>.git)
-    $projectroot = "${cfg.projectroot}";
-    $highlight_bin = "${pkgs.highlight}/bin/highlight";
-    ${cfg.extraConfig}
-  '';
+  cfg = config.services.gitweb;
 
 in
 {
@@ -24,30 +18,9 @@ in
       '';
     };
 
-    projectroot = mkOption {
-      default = "/srv/git";
-      type = types.path;
-      description = ''
-        Path to git projects (bare repositories) that should be served by
-        gitweb. Must not end with a slash.
-      '';
-    };
-
-    extraConfig = mkOption {
-      default = "";
-      type = types.lines;
-      description = ''
-        Verbatim configuration text appended to the generated gitweb.conf file.
-      '';
-      example = ''
-        $feature{'highlight'}{'default'} = [1];
-        $feature{'ctags'}{'default'} = [1];
-      '';
-    };
-
   };
 
-  config = mkIf cfg.enable {
+  config = mkIf config.services.lighttpd.gitweb.enable {
 
     # declare module dependencies
     services.lighttpd.enableModules = [ "mod_cgi" "mod_redirect" "mod_alias" "mod_setenv" ];
@@ -65,7 +38,7 @@ in
               "/gitweb/"        => "${pkgs.git}/share/gitweb/gitweb.cgi"
           )
           setenv.add-environment = (
-              "GITWEB_CONFIG" => "${gitwebConfigFile}",
+              "GITWEB_CONFIG" => "${cfg.gitwebConfigFile}",
               "HOME" => "${cfg.projectroot}"
           )
       }
diff --git a/nixos/modules/services/web-servers/nginx/gitweb.nix b/nixos/modules/services/web-servers/nginx/gitweb.nix
index 315da66fab632..068bf5593e9ff 100644
--- a/nixos/modules/services/web-servers/nginx/gitweb.nix
+++ b/nixos/modules/services/web-servers/nginx/gitweb.nix
@@ -3,13 +3,7 @@
 with lib;
 
 let
-  cfg = config.services.nginx.gitweb;
-  gitwebConfigFile = pkgs.writeText "gitweb.conf" ''
-    # path to git projects (<project>.git)
-    $projectroot = "${cfg.projectroot}";
-    $highlight_bin = "${pkgs.highlight}/bin/highlight";
-    ${cfg.extraConfig}
-  '';
+  cfg = config.services.gitweb;
   gitwebPerlLibs = with pkgs.perlPackages; [ CGIFast FCGI FCGIProcManager HTMLTagCloud ];
   git = pkgs.git.overrideAttrs (oldAttrs: rec {
     postInstall = ''
@@ -34,30 +28,9 @@ in
       '';
     };
 
-    projectroot = mkOption {
-      default = "/srv/git";
-      type = types.path;
-      description = ''
-        Path to git projects (bare repositories) that should be served by
-        gitweb. Must not end with a slash.
-      '';
-    };
-
-    extraConfig = mkOption {
-      default = "";
-      type = types.lines;
-      description = ''
-        Verbatim configuration text appended to the generated gitweb.conf file.
-      '';
-      example = ''
-        $feature{'highlight'}{'default'} = [1];
-        $feature{'ctags'}{'default'} = [1];
-      '';
-    };
-
   };
 
-  config = mkIf cfg.enable {
+  config = mkIf config.services.nginx.gitweb.enable {
 
     systemd.sockets.gitweb = {
       description = "GitWeb Listen Socket";
@@ -87,7 +60,7 @@ in
           root = "${pkgs.git}/share/gitweb";
           extraConfig = ''
             include ${pkgs.nginx}/conf/fastcgi_params;
-            fastcgi_param GITWEB_CONFIG ${gitwebConfigFile};
+            fastcgi_param GITWEB_CONFIG ${cfg.gitwebConfigFile};
             fastcgi_pass unix:/run/gitweb.sock;
           '';
         };