nixos/git-daemon: add 'user' and 'group' options

This commit is contained in:
Nikolay Amiantov 2014-11-07 15:49:45 +03:00
parent 4b2e43865a
commit af1d09879b
1 changed files with 17 additions and 6 deletions

View File

@ -3,7 +3,6 @@ with lib;
let let
cfg = config.services.gitDaemon; cfg = config.services.gitDaemon;
gitUser = "git";
in in
{ {
@ -86,6 +85,18 @@ in
description = "Extra configuration options to be passed to Git daemon."; 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.";
};
}; };
}; };
@ -93,14 +104,14 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
users.extraUsers = singleton users.extraUsers = if cfg.user != "git" then {} else singleton
{ name = gitUser; { name = "git";
uid = config.ids.uids.git; uid = config.ids.uids.git;
description = "Git daemon user"; description = "Git daemon user";
}; };
users.extraGroups = singleton users.extraGroups = if cfg.group != "git" then {} else singleton
{ name = gitUser; { name = "git";
gid = config.ids.gids.git; gid = config.ids.gids.git;
}; };
@ -110,7 +121,7 @@ in
exec = "${pkgs.git}/bin/git daemon --reuseaddr " exec = "${pkgs.git}/bin/git daemon --reuseaddr "
+ (optionalString (cfg.basePath != "") "--base-path=${cfg.basePath} ") + (optionalString (cfg.basePath != "") "--base-path=${cfg.basePath} ")
+ (optionalString (cfg.listenAddress != "") "--listen=${cfg.listenAddress} ") + (optionalString (cfg.listenAddress != "") "--listen=${cfg.listenAddress} ")
+ "--port=${toString cfg.port} --user=${gitUser} --group=${gitUser} ${cfg.options} " + "--port=${toString cfg.port} --user=${cfg.user} --group=${cfg.group} ${cfg.options} "
+ "--verbose " + (optionalString cfg.exportAll "--export-all") + concatStringsSep " " cfg.repositories; + "--verbose " + (optionalString cfg.exportAll "--export-all") + concatStringsSep " " cfg.repositories;
}; };