summaryrefslogtreecommitdiff
path: root/nodes/snorlax/git.nix
blob: 2d0110d8227ebaa81f793c3615a1ac5263508772 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
{ config, lib, pkgs, ... }:
let
  home = "/persist/var/lib/git";
  repos = {
    nixos = {
      path = "${home}/nixos.git";
      desc = "My NixOS Configurations";
      owner = "jras";
    };

    zettelkasten = {
      path = "${home}/zettelkasten.git";
      desc = "Knowledge management system";
      owner = "jras";
    };

    para = {
      path = "${home}/para.git";
      desc = "PARA note taking system";
      owner = "jras";
    };

    obsidian-wavez-theme = {
      path = "${home}/obsidian-wavez-theme.git";
      desc = "The bordeaux theme for Obsidian";
      owner = "jras";
    };

    astal-bar = {
      path = "${home}/astal-bar.git";
      desc = "A wayland bar in jsx";
      owner = "jras";
    };

    rustbook = {
      path = "${home}/rustbook.git";
      desc = "Follow along exercises of the rust book";
      owner = "jras";
    };

    genai = {
      path = "${home}/genai.git";
      desc = "Generative AI fooling around";
      owner = "jras";
    };
  };

  startScript = pkgs.writeShellScript "init-git-repos" ''
  ${lib.concatMapStrings ({ path, ... }: "${pkgs.git}/bin/git init --bare --shared ${path} && cd ${path} && ${pkgs.git}/bin/git branch -m main \n") (builtins.attrValues repos)} 
  '';
in
{
  networking.firewall.allowedTCPPorts = [ 80 8080 ];

  services.cgit.snorlax = {
    enable = true;
    group = "git";
    repos = repos;
  };

  systemd.services.init-repos = {
    description = "Initialize git repositories";
    wantedBy = [ "multi-user.target" ];
    restartTriggers = [ startScript ];

    serviceConfig = {
      Type = "oneshot";
      User = "git";
      Group = "git";
      ExecStart = startScript;
    };
  };

  users.groups.git = {};
  users.users.git = {
    isNormalUser = true;
    home = "${home}";
    homeMode = "0750";
    createHome = true;
    shell = pkgs.zsh;
    group = "git";
    openssh.authorizedKeys.keyFiles = [
      ../../public/id_tarrel.pub
      ../../public/id_work.pub
    ];
    packages = with pkgs; [ git ];
  };
  services.openssh.settings.AllowUsers = [ "git" ];

  age.secrets= {
    gitlab-init-root = {
      file = ../../secrets/gitlab-init-root.age;
      owner = "gitlab";
      group = "gitlab";
    };
    gitlab-db = {
      file = ../../secrets/gitlab-db.age;
      owner = "gitlab";
      group = "gitlab";
    };
    gitlab-jws = {
      file = ../../secrets/gitlab-jws.age;
      owner = "gitlab";
      group = "gitlab";
    };
    gitlab-otp = {
      file = ../../secrets/gitlab-otp.age;
      owner = "gitlab";
      group = "gitlab";
    };
    gitlab-secret = {
      file = ../../secrets/gitlab-secret.age;
      owner = "gitlab";
      group = "gitlab";
    };
  };


  services.gitlab = {
    enable = true;
    initialRootEmail = "jaspert.ras@gmail.com";
    initialRootPasswordFile = config.age.secrets.gitlab-init-root.path;
    secrets.dbFile = config.age.secrets.gitlab-db.path;
    secrets.jwsFile = config.age.secrets.gitlab-jws.path;
    secrets.otpFile = config.age.secrets.gitlab-otp.path;
    secrets.secretFile = config.age.secrets.gitlab-secret.path;
  };
}