aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md30
-rw-r--r--cgit.nix100
-rw-r--r--www/html/index.html3
3 files changed, 132 insertions, 1 deletions
diff --git a/README.md b/README.md
index 018ba09..4bce6f7 100644
--- a/README.md
+++ b/README.md
@@ -29,6 +29,14 @@ Spätere Aufrufe sind viel schneller, da nur Änderungen verarbeitet werden müs
## Abläufe
+### Quellcode abrufen
+
+```bash
+git clone https://git.heimfeld.hamburg/infra
+```
+
+Weitere URLs (z.B. für SSH) sind zu finden auf <https://git.heimfeld.hamburg/infra/> unter **Clone**.
+
### SSH einrichten
Folgendes in `~/.ssh/config` eintragen:
@@ -62,6 +70,28 @@ cp ~/.ssh/foo.pub > ./keys/$USER/
cp ~/.ssh/bar.pub > ./keys/$USER/
```
+### Änderungen am Quellcode hochladen
+
+Auf dem Server muss ein [SSH Public Key für den hochlandenden Nutzer](#administrator-hinzufugen) von einem Administrator eingerichtet worden sein.
+
+[Erstmalig wurde der Quellcode über HTTPS abgerufen](#quellcode-abrufen), daher muss `remotes` angepasst werden:
+
+```bash
+git remote set-url origin ssh://heimfeld.hamburg/git/infra
+```
+
+Da mehrere Nutzer Schreibzugriff auf das Repository haben, muss jeder Nutzer explizit den eigenen Zugriff mit [`safe.directory`](https://git-scm.com/docs/git-config#Documentation/git-config.txt-safedirectory) erlauben:
+
+```bash
+ssh tharos git config --global --add safe.directory /git/infra
+```
+
+Dann wie üblich:
+
+```bash
+git push origin main
+```
+
### Tests durchführen
```bash
diff --git a/cgit.nix b/cgit.nix
new file mode 100644
index 0000000..542245f
--- /dev/null
+++ b/cgit.nix
@@ -0,0 +1,100 @@
+{ self, ... }:
+{
+
+ flake.machines.tharos =
+ let
+ path = "/git/infra";
+ in
+ {
+ nixos =
+ {
+ config,
+ pkgs,
+ lib,
+ ...
+ }:
+ let
+ cgit = config.services.cgit.infra.nginx.virtualHost;
+ nginx = lib.head config.services.nginx.virtualHosts.${cgit}.listen;
+ in
+ {
+ users.groups.git = { };
+ users.users = lib.mapAttrs (_: _': { extraGroups = [ "git" ]; }) self.keys;
+ environment.systemPackages = with pkgs; [ git ];
+
+ systemd.services.init-git-repos = {
+ wantedBy = [ "multi-user.target" ];
+ before = [ "cgit.service" ];
+
+ serviceConfig = {
+ Type = "oneshot";
+ RemainAfterExit = true;
+ };
+
+ script = ''
+ if [ ! -f ${path} ]; then
+ ${lib.getExe pkgs.git} init --shared=group --bare ${path}
+ fi
+ '';
+ };
+
+ systemd.tmpfiles.rules = [
+ "d ${path} 2775 root git -"
+ ];
+
+ services.cgit.infra = rec {
+ enable = true;
+ nginx.virtualHost = "git.${self.domain}";
+ repos.infra = {
+ desc = "Quellcode für die technische Infrastruktur des Stadtteilbeirats Heimfeld";
+ inherit path;
+ clone-url = "https://${nginx.virtualHost}/$CGIT_REPO_URL ssh://${self.domain}${path}";
+ };
+ settings = {
+ about-filter = "${pkgs.cgit}/lib/cgit/filters/about-formatting.sh";
+ readme = ":README.md";
+ enable-commit-graph = true;
+ };
+ };
+ services.nginx.virtualHosts.${cgit}.listen = [
+ {
+ addr = "127.0.0.1";
+ port = 8083;
+ }
+ ];
+ services.caddy.virtualHosts.${cgit}.extraConfig = ''
+ reverse_proxy localhost:${toString nginx.port}
+ '';
+ };
+ vm =
+ {
+ config,
+ pkgs,
+ lib,
+ ...
+ }:
+ let
+ httpPort = 700;
+ cgit = config.services.cgit.infra.nginx.virtualHost;
+ in
+ {
+ services.cgit.infra = {
+ nginx.virtualHost = lib.mkForce "git.localhost";
+
+ repos.infra.clone-url = lib.mkForce "http://${cgit}:${
+ with config.virtualisation; toString (portOffset + exposedPorts.http.port)
+ }/$CGIT_REPO_URL ssh://localhost:${
+ toString (config.virtualisation.portOffset + lib.head config.services.openssh.ports)
+ }${path}";
+ };
+
+ services.caddy.virtualHosts = {
+ "http://${cgit}:${toString config.virtualisation.exposedPorts.http.port}".extraConfig =
+ config.services.caddy.virtualHosts.${cgit}.extraConfig;
+ };
+ services.getty.helpLine = lib.mkBefore ''
+ cgit: http://${cgit}:${with config.virtualisation; toString (portOffset + exposedPorts.http.port)}
+ '';
+ };
+ };
+}
diff --git a/www/html/index.html b/www/html/index.html
index a3d4043..cdde7b1 100644
--- a/www/html/index.html
+++ b/www/html/index.html
@@ -160,7 +160,8 @@
<td <font size="3" align="center" width="11%" valign="middle">
<a href="impressum.html">Impressum</a>
</td>
- <td align="center" width="11%" valign="middle"><br>
+ <td align="center" width="11%" valign="middle">
+ <a target="_blank" href="https://git.heimfeld.hamburg/infra">Quellcode</a>
</td>
<td align="center" width="11%" valign="middle">
<font size="3"><a href="datenschutz.html">Datenschutz</a></font>