aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-11-07 19:05:29 -0800
committerFranck Cuny <franck@fcuny.net>2022-11-07 19:05:29 -0800
commit6fef7342b9bbbe504d0168e113d58d3d76cba1de (patch)
tree4a3579e52ccba85cf57ebfb4ed7c8ead51718b5b /modules
parentfeat(services/gitea): add robots.txt (diff)
downloadinfra-6fef7342b9bbbe504d0168e113d58d3d76cba1de.tar.gz
ref(gerrit): delete modules/docs/configs for gerrit/buildkite
Diffstat (limited to 'modules')
-rw-r--r--modules/services/buildkite/default.nix63
-rw-r--r--modules/services/cgit/default.nix131
-rw-r--r--modules/services/default.nix3
-rw-r--r--modules/services/gerrit/default.nix151
4 files changed, 0 insertions, 348 deletions
diff --git a/modules/services/buildkite/default.nix b/modules/services/buildkite/default.nix
deleted file mode 100644
index 90253bf..0000000
--- a/modules/services/buildkite/default.nix
+++ /dev/null
@@ -1,63 +0,0 @@
-{ config, pkgs, lib, ... }:
-let
- cfg = config.my.services.buildkite;
- agents = lib.range 1 5;
- secrets = config.age.secrets;
-
- my-gerrit-hook = name:
- pkgs.writeShellScript "gerrit-buildkite-hook" ''
- exec -a ${name} ${pkgs.tools.gerrit-hook}/bin/gerrit-hook "$@"
- '';
-
- buildkiteHooks = pkgs.runCommandNoCC "buildkite-hooks" { } ''
- mkdir -p $out/bin
- ln -s ${my-gerrit-hook "post-command"} $out/bin/post-command
- '';
-
-in
-{
- options.my.services.buildkite = with lib; {
- enable = mkEnableOption "buildkite agent";
- };
-
- config = lib.mkIf cfg.enable {
- # see https://buildkite.com/docs/agent/v3
- # and https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/continuous-integration/buildkite-agents.nix
- services.buildkite-agents = lib.listToAttrs (map
- (n: rec {
- name = "builder-${toString n}";
- value = {
- inherit name;
- enable = true;
- tokenPath = secrets."buildkite/agent".path;
- hooks.post-command = "${buildkiteHooks}/bin/post-command";
- runtimePackages = with pkgs; [
- bash
- coreutils
- curl
- git
- gnutar
- gzip
- jq
- nix
- ];
- };
- })
- agents);
-
- # Set up a group for all Buildkite agent users
- users = {
- groups.buildkite-agents = { };
- users = builtins.listToAttrs (map
- (n: rec {
- name = "buildkite-agent-builder-${toString n}";
- value = {
- isSystemUser = true;
- group = lib.mkForce "buildkite-agents";
- extraGroups = [ name "docker" ];
- };
- })
- agents);
- };
- };
-}
diff --git a/modules/services/cgit/default.nix b/modules/services/cgit/default.nix
deleted file mode 100644
index 2c4802f..0000000
--- a/modules/services/cgit/default.nix
+++ /dev/null
@@ -1,131 +0,0 @@
-{ config, pkgs, lib, ... }:
-let
- cfg = config.my.services.cgit;
- # there's no need for web crawlers on that site
- robots-deny = pkgs.writeText "robots.txt" ''
- User-agent: *
- Disallow: /
- '';
- cgitrc = ''
- # Global configuration
- virtual-root=/
-
- # clone will be handled by gerrit
- enable-http-clone=0
- clone-url=https://cl.fcuny.net/$CGIT_REPO_URL
-
- # I've fewer than 150 repos, all should be able to be listed on
- # the main page
- max-repo-count=150
-
- # limit to year for the stats
- max-stats=year
-
- snapshots=tar.gz
-
- source-filter=${pkgs.cgit}/lib/cgit/filters/syntax-highlighting.py
- about-filter=${pkgs.cgit}/lib/cgit/filters/about-formatting.sh
-
- enable-git-config=1
- enable-index-owner=0
-
- remove-suffix=1
-
- # sort repositories by section and branches by date
- repository-sort=age
- branch-sort=age
-
- readme=:README.md
- readme=:README.org
- readme=:readme.org
-
- # print the number of modified files
- enable-log-filecount=1
- # print the number of modified lines
- enable-log-linecount=1
- enable-follow-links=1
- enable-blame=1
-
- root-title="Franck git repositories"
- root-desc="source code of my various projects"
-
- # don't index or follow
- robots="noindex, nofollow"
-
- project-list=/var/lib/cgit/cache/projects.list
- scan-path=/var/lib/gerrit/git
- '';
-in
-{
- options.my.services.cgit = with lib; {
- enable = mkEnableOption "git web viewer";
- };
-
- config = lib.mkIf cfg.enable {
- services.fcgiwrap = {
- enable = true;
- user = "git";
- group = "git";
- };
-
- systemd = {
- timers.sync-cgit-repo = {
- description = "synchronize the list of repositories from gerrit";
- wantedBy = [ "timers.target" ];
- partOf = [ "sync-cgit-repo.service" ];
- timerConfig.OnCalendar = "*:0/10";
- };
- services.sync-cgit-repo = {
- description = "synchronize the list of repositories from gerrit";
- serviceConfig.Type = "oneshot";
- script = ''
- mkdir -p /var/lib/cgit/cache
- tmplist=$(mktemp)
-
- # as per https://gerrit-review.googlesource.com/Documentation/rest-api.html#output we need to remove `)]}' from the response
- repos=$(${pkgs.curl}/bin/curl -s -H "Content-Type: application/json" "https://cl.fcuny.net/projects/?state=ACTIVE"|sed "s/^)]}'//"|${pkgs.jq}/bin/jq -r 'to_entries | .[] | .value | .id')
-
- # list of repositories that I still want to be active in gerrit but I don't want to list here
- exclude_repos="password-store|All-Projects|All-Users|homelab"
-
- for repo in ''${repos}; do
- if [[ ! $exclude_repos =~ $repo ]]; then
- echo "''${repo}.git" >> $tmplist
- fi
- done
- mv $tmplist /var/lib/cgit/cache/projects.list
- # TODO(fcuny): this should run as the git user
- chown git:git /var/lib/cgit/cache/projects.list
- '';
- };
- };
-
- services.nginx.virtualHosts."git.fcuny.net" = {
- # make cgit the default site: if a request goes through nginx
- # without a host header, this will be the default site we serve
- # for that request.
- default = true;
- forceSSL = true;
- enableACME = true;
- locations = {
- "~* ^.+.(css|png|ico)$" = { root = "${pkgs.cgit}/cgit"; };
- # as per https://github.com/yandex/gixy/blob/master/docs/en/plugins/aliastraversal.md
- # if you want to map a single file make sure the location starts with a =, e.g =/i.gif instead of /i.gif.
- "=/robots.txt".alias = robots-deny;
- "/".extraConfig = ''
- include ${pkgs.nginx}/conf/fastcgi_params;
- fastcgi_param CGIT_CONFIG ${pkgs.writeText "cgitrc" cgitrc};
- fastcgi_param SCRIPT_FILENAME ${pkgs.cgit}/cgit/cgit.cgi;
- fastcgi_split_path_info ^(/?)(.+)$;
- fastcgi_param PATH_INFO $fastcgi_path_info;
- fastcgi_param HTTP_HOST $server_name;
- fastcgi_param QUERY_STRING $args;
- fastcgi_pass unix:${config.services.fcgiwrap.socketAddress};
- if ($http_user_agent ~* "(Blackbox Exporter)" ) {
- access_log off;
- }
- '';
- };
- };
- };
-}
diff --git a/modules/services/default.nix b/modules/services/default.nix
index 73e2e6d..538e564 100644
--- a/modules/services/default.nix
+++ b/modules/services/default.nix
@@ -4,11 +4,8 @@
imports = [
./avahi
./backup
- ./buildkite
- ./cgit
./drone
./fwupd
- ./gerrit
./gitea
./gnome
./grafana
diff --git a/modules/services/gerrit/default.nix b/modules/services/gerrit/default.nix
deleted file mode 100644
index 1592839..0000000
--- a/modules/services/gerrit/default.nix
+++ /dev/null
@@ -1,151 +0,0 @@
-{ config, pkgs, lib, ... }:
-let
- cfg = config.my.services.gerrit;
- secrets = config.age.secrets;
-
- my-gerrit-hook = name:
- pkgs.writeShellScript "my-gerrit-hook" ''
- exec -a ${name} ${pkgs.tools.gerrit-hook}/bin/gerrit-hook "$@"
- '';
-
- gerritHooks = pkgs.runCommandNoCC "gerrit-hooks" { } ''
- mkdir -p $out
- ln -s ${my-gerrit-hook "patchset-created"} $out/patchset-created
- '';
-
- oauth = pkgs.fetchurl {
- url =
- "https://github.com/davido/gerrit-oauth-provider/releases/download/v3.5.1/gerrit-oauth-provider.jar";
- sha256 = "312dc494c454ac15f89a289f95ea4c11344add26804aaa6a3b79d49fd92adc69";
- };
-in
-{
- options.my.services.gerrit = with lib; {
- enable = mkEnableOption "gerrit git server";
- vhostName = mkOption {
- type = types.str;
- example = "cl.fcuny.net";
- description = "Name for the virtual host";
- };
- };
-
- config = lib.mkIf cfg.enable {
- users.users.git = {
- description = "git";
- home = "/var/lib/gerrit";
- useDefaultShell = true;
- group = "git";
- isSystemUser = true;
- };
- users.groups.git = { };
-
- services.gerrit = {
- enable = true;
- listenAddress = "[::]:4778";
- serverId = "36bc0ffe-8f33-4045-bf8b-de5f88815fc0";
- builtinPlugins = [
- # commands to download changes
- "download-commands"
- # to run custom hooks
- "hooks"
- # stores review information for Gerrit changes in the
- # refs/notes/review branch.
- "reviewnotes"
- # delete projects via the command line
- "delete-project"
- ];
- jvmHeapLimit = "4g";
-
- plugins = [ oauth ];
-
- # The default JDK is incompatible with gerrit.
- jvmPackage = pkgs.openjdk11_headless;
-
- settings = {
- core.packedGitLimit = "100m";
- log.jsonLogging = true;
- log.textLogging = false;
- sshd.advertisedAddress = "git.fcuny.net:29418";
- hooks.path = "${gerritHooks}";
- cache.web_sessions.maxAge = "3 months";
- plugins.allowRemoteAdmin = false;
- change.enableAttentionSet = true;
- change.enableAssignee = false;
-
- gerrit = {
- canonicalWebUrl = "https://${cfg.vhostName}";
- docUrl = "/Documentation";
- };
-
- httpd.listenUrl = "proxy-https://localhost:4778";
-
- download.command = [ "checkout" "cherry_pick" "format_patch" "pull" ];
-
- # Configure for cgit.
- gitweb = {
- type = "custom";
- url = "https://git.fcuny.net";
- project = "/\${project}";
- revision = "/commit/?id=\${commit}";
- branch = "/log/?h=\${branch}";
- tag = "/tag/?h=\${tag}";
- roottree = "/tree/?h=\${commit}";
- file = "/tree/\${file}?h=\${commit}";
- filehistory = "/log/\${file}?h=\${branch}";
- linkname = "cgit";
- };
-
- auth.type = "OAUTH";
-
- # users can change their emails
- oauth.allowRegisterNewEmail = true;
-
- plugin.gerrit-oauth-provider-google-oauth = {
- client-id =
- "966881439540-5k20bis59lqs2bsi3rukfbveu8r0ta8q.apps.googleusercontent.com";
- };
-
- # use gerrit HTTP password
- auth.gitBasicAuthPolicy = "HTTP";
-
- # Receiving email is not currently supported.
- sendemail = {
- enable = true;
- html = false;
- connectTimeout = "10sec";
- from = "gerrit <gerrit@fcuny.net>";
- includeDiff = true;
- smtpEncryption = "tls";
- smtpServer = "smtp.fastmail.com";
- smtpServerPort = 587;
- };
- };
- };
-
- systemd.services.gerrit = {
- serviceConfig = {
- # Using DynamicUser fails to generate correctly the ssh keys
- # needed for the ssh server that is managed by gerrit.
- # Instead, let's re-use the git user.
- DynamicUser = lib.mkForce false;
- User = "git";
- Group = "git";
- };
- };
-
- my.services.backup = {
- paths = [ "/var/lib/gerrit" ];
- exclude = [
- "/var/lib/gerrit/tmp"
- "/var/lib/gerrit/logs"
- "/var/lib/gerrit/cache"
- ];
- };
-
- services.nginx.virtualHosts."${cfg.vhostName}" = {
- forceSSL = true;
- enableACME = true;
- locations."/" = { proxyPass = "http://127.0.0.1:4778"; };
- };
- };
-}