about summary refs log tree commit diff
path: root/modules/server/spectrum/git/default.nix
blob: beb61b78dd89f0e726f9387a216c5fd4b28faaa7 (plain) (blame)
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
{ pkgs, ... }:

{
  imports = [ ../../git ];

  declarative-git.repositories."/home/spectrum/git/crosvm.git" = {
    branch = "master";
    description = "Downstream crosvm tree for Spectrum";
    group = "spectrum";
    config.cgit.section = "obsolete";
  };

  declarative-git.repositories."/home/spectrum/git/doc.git" = {
    branch = "master";
    description = "Old manuals for Spectrum";
    hooks.post-update = [
      (pkgs.writeShellScript "post-update.sh" ''
        nix-build --tarball-ttl 0 --out-link built --cores 1 -j1 -E "
          let src = builtins.fetchGit ./.;
          in (import src).overrideAttrs ({ ... }: { inherit src; })
        "
      '')
    ];
    group = "spectrum";
    config.cgit.section = "obsolete";
  };

  declarative-git.repositories."/home/spectrum/git/nixpkgs.git" = {
    branch = "rootfs";
    description = "Downstream nixpkgs tree for Spectrum";
    group = "spectrum";
    config.cgit.defBranch = "rootfs";
    config.cgit.section = "obsolete";
    config.core.sharedrepository = "0644";
  };

  declarative-git.repositories."/home/spectrum/git/mktuntap.git" = {
    branch = "master";
    description = "Utility program for creating TUN and TAP devices on file descriptors";
    group = "spectrum";
    config.cgit.readme = ":README";
    config.core.sharedrepository = "0644";
    config.receive.denyNonFastforwards = true;
  };

  declarative-git.repositories."/home/spectrum/git/spectrum.git" = {
    description = "A compartmentalized operating system";
    group = "spectrum";
    config.cgit.defBranch = "main";
    hooks.post-receive = with pkgs; [
      (writeShellScript "send-email.sh" ''
        set -ueo pipefail
        export PATH=${lib.makeBinPath [ coreutils curl gitMinimal gnused mailutils ]}

        repo_url=https://spectrum-os.org/git/spectrum
        inbox_url=https://spectrum-os.org/lists/archives/spectrum-devel

        while read oldrev newrev refname; do
            [ "$refname" = "refs/heads/main" ] || continue

            git log --reverse --format=%H "$oldrev..$newrev" | while read commit; do
                message_id="$(git log -1 --format=%B "$commit" |
                    git interpret-trailers --parse |
                    sed -n 's/^Message-Id: <\(.*\)>$/\1/Ip' | head -n 1)"

                [ -n "$message_id" ] || continue

                url="$inbox_url/$message_id/raw"
                path="$(mktemp)"
                curl -LSfso "$path" "$url"
                mail -E "file $path" -E "reply" -E "quit" <<EOF
        This patch has been committed as $commit,
        which can be viewed online at
        $repo_url/commit/?id=$commit.

        This is an automated message.  Send comments/questions/requests to:
        Alyssa Ross <hi@alyssa.is>
        EOF
                rm "$path"
            done
        done
      '')
      (writeShellScript "build-documentation.sh" ''
        nix-build --tarball-ttl 0 --out-link /home/spectrum/Documentation -E '
          import "''${builtins.fetchGit { url = ./.; ref = "main"; }}/Documentation" {}
        '
      '')
    ];
  };

  declarative-git.repositories."/home/spectrum/git/ucspi-vsock.git" = {
    branch = "master";
    description = "UCSPI-1996 implementation for Linux AF_VSOCK sockets";
    group = "spectrum";
    config.cgit.section = "obsolete";
  };

  declarative-git.repositories."/home/spectrum/git/www.git" = {
    branch = "master";
    description = "Static source files for the Spectrum website";
    group = "spectrum";
    config.cgit.readme = ":README";
    config.core.bare = false;
    config.core.logallrefupdates = true;
    config.core.sharedrepository = 1;
    config.core.worktree = "../../www";
    config.receive.denyCurrentBranch = "updateInstead";
    config.receive.denyNonFastforwards = true;
  };
}