+/config
my dotfiles and nix configuration
git clone https://git.julia.blue/+/config
8dbea4b
main
1{ config , lib , pkgs , ...} @inputs :let 2cfg = config . services . sorcery ; 3types = lib . types ; 4cache = "/var/cache/sorcery" ; 5socket = "/run/sorcery/sock" ; 6control_socket = "/run/sorcery/control" ; 7pkg = inputs . inputs . sorcery . packages . x86_64-linux ; 8# TODO: remove when char fixes this upstream 9sorcery-ssh = pkg . sorcery-ssh . overrideAttrs ( old :{ 10nativeBuildInputs = 11( lib . filter ( p :p != pkgs . zig ) ( old . nativeBuildInputs or [])) 12++ [ pkgs . zig_0_16 ]; 13}); 14in { 15options . services . sorcery = { 16enable = lib . mkEnableOption ( lib . mdDoc "git repo viewer" ); 17repositories = lib . mkOption { 18type = types . path ; 19description = "Directory where your git repos reside" ; 20}; 21name = lib . mkOption { 22type = types . str ; 23description = "Name of your instance" ; 24}; 25url_base = lib . mkOption { 26type = types . str ; 27description = "Where your git repos will be accessed from" ; 28}; 29keys = lib . mkOption { 30type = types . listOf types . str ; 31description = "ssh keys that have write access to your repositories" ; 32}; 33}; 34 35config = lib . mkIf cfg . enable { 36environment . systemPackages = [ pkg . default sorcery-ssh pkg . sorcery-ssh-tui ]; 37systemd . services . sorcery = { 38description = "Sorcery Git forge" ; 39wantedBy = [ "multi-user.target" ]; 40after = [ "network-online.target" ]; 41wants = [ "network-online.target" ]; 42path = [ pkgs . gitMinimal ]; 43serviceConfig = { 44ExecStart = [ " ${ lib . getExe pkg . default } " ]; 45Type = "simple" ; 46User = "git" ; 47Group = "git" ; 48RuntimeDirectory = "sorcery" ; 49CacheDirectory = "sorcery" ; 50ConfigurationDirectory = "sorcery" ; 51Restart = "on-failure" ; 52RestartSec = 2 ; 53UMask = "0007" ; 54}; 55environment = { 56SORCERY_REPOSITORIES = " ${ cfg . repositories } " ; 57SORCERY_INSTANCE_NAME = " ${ cfg . name } " ; 58SORCERY_CLONE_URL_BASE = " ${ cfg . url_base } " ; 59SORCERY_CACHE = " ${ cache } " ; 60SORCERY_SOCKET = " ${ socket } " ; 61SORCERY_CONTROL_SOCKET = " ${ control_socket } " ; 62}; 63}; 64services . openssh . extraConfig = '' 65Match User git 66SetEnv SORCERY_CONTROL_SOCKET= ${ control_socket } SORCERY_INSTANCE_NAME= ${ cfg . name } SORCERY_SSH_TUI= ${ lib . getExe pkg . sorcery-ssh-tui } SORCERY_REPOSITORIES= ${ cfg . repositories } SORCERY_CLONE_URL_BASE= ${ cfg . url_base } 67ForceCommand ${ lib . getExe sorcery-ssh } 68'' ; 69 70users = { 71groups . git . gid = config . ids . gids . git ; 72users . git = { 73description = "git user" ; 74home = cfg . repositories ; 75group = "git" ; 76uid = config . ids . uids . git ; 77shell = pkgs . bashInteractive ; 78openssh . authorizedKeys . keys = cfg . keys ; 79}; 80}; 81}; 82}