summaryrefslogtreecommitdiff
path: root/machines/xnet/gitserver/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'machines/xnet/gitserver/default.nix')
-rw-r--r--machines/xnet/gitserver/default.nix54
1 files changed, 54 insertions, 0 deletions
diff --git a/machines/xnet/gitserver/default.nix b/machines/xnet/gitserver/default.nix
new file mode 100644
index 0000000..da83f73
--- /dev/null
+++ b/machines/xnet/gitserver/default.nix
@@ -0,0 +1,54 @@
+{ config, lib, pkgs, ... }:
+let
+ cfg = config.xnet.gitServer;
+ inherit (lib) mkOption mkIf types;
+in
+{
+ imports = [ ./gitweb.nix ];
+
+ options.xnet.gitServer = {
+ enable = mkOption {
+ type = types.bool;
+ default = false;
+ description = "Serve git repos over SSH.";
+ };
+
+ path = mkOption {
+ type = types.path;
+ default = "/persist/repo/git";
+ description = "Directory where repos will be stored.";
+ };
+
+ keys = mkOption {
+ type = types.listOf types.str;
+ description = "SSH public keys used for git operations.";
+ };
+ };
+
+ config = mkIf cfg.enable {
+ users.users.git = {
+ group = "git";
+ initialPassword = "";
+ isSystemUser = true;
+ home = cfg.path;
+ homeMode = "755";
+ createHome = true;
+ shell = "${pkgs.git}/bin/git-shell";
+ openssh.authorizedKeys.keys = cfg.keys;
+ };
+
+ users.groups.git = { };
+
+ programs.git = {
+ enable = true;
+ config = {
+ init = {
+ defaultBranch = "master";
+ };
+ safe = {
+ directory = "*";
+ };
+ };
+ };
+ };
+}