From 4b2e43865afe8d361dd6ed4bd7e17e2c300a0231 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Fri, 7 Nov 2014 15:49:03 +0300 Subject: [PATCH 1/3] nixos/git-daemon: add types --- nixos/modules/services/networking/git-daemon.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nixos/modules/services/networking/git-daemon.nix b/nixos/modules/services/networking/git-daemon.nix index 5864efaca51..29072ed7839 100644 --- a/nixos/modules/services/networking/git-daemon.nix +++ b/nixos/modules/services/networking/git-daemon.nix @@ -14,6 +14,7 @@ in services.gitDaemon = { enable = mkOption { + type = types.bool; default = false; description = '' Enable Git daemon, which allows public hosting of git repositories @@ -28,6 +29,7 @@ in }; basePath = mkOption { + type = types.str; default = ""; example = "/srv/git/"; description = '' @@ -38,6 +40,7 @@ in }; exportAll = mkOption { + type = types.bool; default = false; description = '' Publish all directories that look like Git repositories (have the objects @@ -52,6 +55,7 @@ in }; repositories = mkOption { + type = types.listOf types.str; default = []; example = [ "/srv/git" "/home/user/git/repo2" ]; description = '' @@ -64,17 +68,20 @@ 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."; }; From af1d09879bf3546652c00efb7129e62a94534759 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Fri, 7 Nov 2014 15:49:45 +0300 Subject: [PATCH 2/3] nixos/git-daemon: add 'user' and 'group' options --- .../services/networking/git-daemon.nix | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/nixos/modules/services/networking/git-daemon.nix b/nixos/modules/services/networking/git-daemon.nix index 29072ed7839..8c9243463ac 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 { @@ -86,6 +85,18 @@ in 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 { - 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; }; @@ -110,7 +121,7 @@ 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} " + + "--port=${toString cfg.port} --user=${cfg.user} --group=${cfg.group} ${cfg.options} " + "--verbose " + (optionalString cfg.exportAll "--export-all") + concatStringsSep " " cfg.repositories; }; From 46b866cf63d6df3f0ae5ba87ceea55fb460345a3 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Fri, 7 Nov 2014 15:50:01 +0300 Subject: [PATCH 3/3] nixos/git-daemon: fix 'exportAll' option --- nixos/modules/services/networking/git-daemon.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/networking/git-daemon.nix b/nixos/modules/services/networking/git-daemon.nix index 8c9243463ac..566936a7d0f 100644 --- a/nixos/modules/services/networking/git-daemon.nix +++ b/nixos/modules/services/networking/git-daemon.nix @@ -122,7 +122,7 @@ in + (optionalString (cfg.basePath != "") "--base-path=${cfg.basePath} ") + (optionalString (cfg.listenAddress != "") "--listen=${cfg.listenAddress} ") + "--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; }; };