summary refs log tree commit diff
diff options
context:
space:
mode:
authorAristid Breitkreuz <aristidb@gmail.com>2014-11-08 19:33:24 +0100
committerAristid Breitkreuz <aristidb@gmail.com>2014-11-08 19:33:24 +0100
commit8b50383c451556e1eb16543021bc2f2bb94b6425 (patch)
tree84bd1bc14a91bc90816230c0fee74d8108a92872
parent9ea81152ccdbdcd001a6652fb334d443bb2764ef (diff)
parent46b866cf63d6df3f0ae5ba87ceea55fb460345a3 (diff)
downloadnixlib-8b50383c451556e1eb16543021bc2f2bb94b6425.tar
nixlib-8b50383c451556e1eb16543021bc2f2bb94b6425.tar.gz
nixlib-8b50383c451556e1eb16543021bc2f2bb94b6425.tar.bz2
nixlib-8b50383c451556e1eb16543021bc2f2bb94b6425.tar.lz
nixlib-8b50383c451556e1eb16543021bc2f2bb94b6425.tar.xz
nixlib-8b50383c451556e1eb16543021bc2f2bb94b6425.tar.zst
nixlib-8b50383c451556e1eb16543021bc2f2bb94b6425.zip
Merge pull request #4859 from abbradar/git-daemon
nixos/git-daemon: fix a bug and add 'user' and 'group' options
-rw-r--r--nixos/modules/services/networking/git-daemon.nix32
1 files changed, 25 insertions, 7 deletions
diff --git a/nixos/modules/services/networking/git-daemon.nix b/nixos/modules/services/networking/git-daemon.nix
index 5864efaca51f..566936a7d0fa 100644
--- a/nixos/modules/services/networking/git-daemon.nix
+++ b/nixos/modules/services/networking/git-daemon.nix
@@ -3,7 +3,6 @@ with lib;
 let
 
   cfg = config.services.gitDaemon;
-  gitUser = "git";
 
 in
 {
@@ -14,6 +13,7 @@ in
     services.gitDaemon = {
 
       enable = mkOption {
+        type = types.bool;
         default = false;
         description = ''
           Enable Git daemon, which allows public hosting  of git repositories
@@ -28,6 +28,7 @@ in
       };
 
       basePath = mkOption {
+        type = types.str;
         default = "";
         example = "/srv/git/";
         description = ''
@@ -38,6 +39,7 @@ in
       };
 
       exportAll = mkOption {
+        type = types.bool;
         default = false;
         description = ''
           Publish all directories that look like Git repositories (have the objects
@@ -52,6 +54,7 @@ in
       };
 
       repositories = mkOption {
+        type = types.listOf types.str;
         default = [];
         example = [ "/srv/git" "/home/user/git/repo2" ];
         description = ''
@@ -64,21 +67,36 @@ in
       };
 
       listenAddress = mkOption {
+        type = types.str;
         default = "";
         example = "example.com";
         description = "Listen on a specific IP address or hostname.";
       };
 
       port = mkOption {
+        type = types.int;
         default = 9418;
         description = "Port to listen on.";
       };
 
       options = mkOption {
+        type = types.str;
         default = "";
         description = "Extra configuration options to be passed to Git daemon.";
       };
 
+      user = mkOption {
+        type = types.str;
+        default = "git";
+        description = "User under which Git daemon would be running.";
+      };
+
+      group = mkOption {
+        type = types.str;
+        default = "git";
+        description = "Group under which Git daemon would be running.";
+      };
+
     };
   };
 
@@ -86,14 +104,14 @@ in
 
   config = mkIf cfg.enable {
 
-    users.extraUsers = singleton
-      { name = gitUser;
+    users.extraUsers = if cfg.user != "git" then {} else singleton
+      { name = "git";
         uid = config.ids.uids.git;
         description = "Git daemon user";
       };
 
-    users.extraGroups = singleton
-      { name = gitUser;
+    users.extraGroups = if cfg.group != "git" then {} else singleton
+      { name = "git";
         gid = config.ids.gids.git;
       };
 
@@ -103,8 +121,8 @@ in
       exec = "${pkgs.git}/bin/git daemon --reuseaddr "
         + (optionalString (cfg.basePath != "") "--base-path=${cfg.basePath} ")
         + (optionalString (cfg.listenAddress != "") "--listen=${cfg.listenAddress} ")
-        + "--port=${toString cfg.port} --user=${gitUser} --group=${gitUser} ${cfg.options} "
-        + "--verbose " + (optionalString cfg.exportAll "--export-all")  + concatStringsSep " " cfg.repositories;
+        + "--port=${toString cfg.port} --user=${cfg.user} --group=${cfg.group} ${cfg.options} "
+        + "--verbose " + (optionalString cfg.exportAll "--export-all ")  + concatStringsSep " " cfg.repositories;
     };
 
   };