From f08f3812f40322b6098d75573413ed83f358871f Mon Sep 17 00:00:00 2001 From: Kleidi Bujari Date: Sun, 1 Dec 2024 22:30:26 -0500 Subject: Cleanup xnet module and add baseline modules With these changes, the xnet module is useable as a system builder. At this point, it is still undecided whether all configuration will be generalized into this module, rather than keeping mini-modules local to the machine they will run on. --- modules/xnet/gitserver/default.nix | 53 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 modules/xnet/gitserver/default.nix (limited to 'modules/xnet/gitserver/default.nix') diff --git a/modules/xnet/gitserver/default.nix b/modules/xnet/gitserver/default.nix new file mode 100644 index 0000000..5e04398 --- /dev/null +++ b/modules/xnet/gitserver/default.nix @@ -0,0 +1,53 @@ +{ 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; + 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 = "*"; + }; + }; + }; + }; +} -- cgit v1.3.1