default.nix (1260B)
1 { 2 lib, 3 options, 4 config, 5 pkgs, 6 ... 7 }: 8 { 9 options.modules.git.daemon = { 10 enable = lib.mkOption { 11 description = "Whether to enable the Git daemon."; 12 default = false; 13 type = lib.types.bool; 14 }; 15 }; 16 17 config = 18 let 19 inherit (config.modules.git) daemon; 20 in 21 lib.mkIf (config.modules.git.enable && daemon.enable) { 22 systemd = { 23 services = { 24 git-daemon = { 25 enable = true; 26 wantedBy = [ "multi-user.target" ]; 27 after = [ "network.target" ]; 28 serviceConfig = 29 let 30 script = pkgs.writeShellScriptBin "script" '' 31 ${pkgs.git}/bin/git daemon \ 32 --verbose \ 33 --syslog \ 34 --base-path=${config.modules.git.directory} \ 35 --port=9418 \ 36 --export-all \ 37 ${config.modules.git.directory} 38 ''; 39 in 40 { 41 User = "git"; 42 Group = "git"; 43 Type = "simple"; 44 ExecStart = "${script}/bin/script"; 45 }; 46 }; 47 }; 48 }; 49 50 networking.firewall.allowedTCPPorts = [ 9418 ]; 51 }; 52 }