stockholm/krebs/2configs/repo-sync.nix

122 lines
2.7 KiB
Nix
Raw Normal View History

2016-02-15 13:03:47 +00:00
{ config, lib, pkgs, ... }:
2023-06-10 10:50:53 +00:00
with import ../../lib/pure.nix { inherit lib; };
let
konsens-user = {
name = "konsens";
pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIKKozGNGBAzHnyj6xUlsjGxxknyChXvuyrddkWVVnz7";
};
mirror = "git@${config.networking.hostName}:";
2018-08-24 17:34:29 +00:00
defineRepo = {
name, desc, section
}:
let
repo = {
public = true;
name = mkDefault "${name}";
2018-08-24 17:34:29 +00:00
cgit.desc = desc;
cgit.section = section;
hooks = mkDefault {
post-receive = pkgs.git-hooks.irc-announce {
2017-10-01 12:26:12 +00:00
channel = "#xxx";
refs = [
"refs/heads/newest"
2018-09-06 21:04:24 +00:00
"refs/tags/*"
2018-09-06 20:34:33 +00:00
];
nick = config.networking.hostName;
server = "irc.r";
verbose = false;
2017-03-07 23:52:31 +00:00
};
2018-08-24 17:34:29 +00:00
};
};
in {
2018-08-24 17:34:29 +00:00
rules = with git; [
{
user = with config.krebs.users; [
config.krebs.users."${config.networking.hostName}-repo-sync"
lass
makefu
tv
2018-08-24 17:34:29 +00:00
];
repo = [ repo ];
perm = push ''refs/*'' [ non-fast-forward create delete merge ];
}
{
user = [
konsens-user
];
repo = [ repo ];
perm = push "refs/heads/common" [ create merge ];
}
2018-08-24 17:34:29 +00:00
{
user = attrValues config.krebs.users;
repo = [ repo ];
perm = fetch;
}
];
repos."${name}" = repo;
};
sync-repo = {
2018-08-24 17:34:29 +00:00
name,
remotes,
2018-08-24 17:34:29 +00:00
desc ? "mirror for ${name}",
section ? "mirror"
}:
{
krebs.repo-sync.repos.${name} = {
branches = (lib.mapAttrs' (user: url: lib.nameValuePair user {
origin.url = url;
mirror.url = "${mirror}${name}";
}) remotes);
latest = {
url = "${mirror}${name}";
2018-08-24 17:34:29 +00:00
ref = "heads/newest";
};
};
krebs.git = defineRepo { inherit name desc section; };
};
in {
2017-07-22 18:37:20 +00:00
krebs.git = {
2018-08-24 17:34:29 +00:00
enable = true;
cgit.settings = {
root-title = "krebs repos";
root-desc = "keep calm and engage";
2017-07-22 18:37:20 +00:00
};
};
2018-08-24 17:34:29 +00:00
krebs.repo-sync = {
enable = true;
};
krebs.konsens = {
enable = true;
repos = {
stockholm = {};
};
};
krebs.secret.files.konsens = {
path = "/var/lib/konsens/.ssh/id_ed25519";
owner = konsens-user;
source-path = "${config.krebs.secret.directory}/konsens.id_ed25519>";
};
imports = [
(sync-repo {
name = "stockholm";
desc = "take all computers hostage, they love it";
section = "configuration";
remotes = {
makefu = "http://cgit.gum.r/stockholm";
tv = "http://cgit.ni.r/stockholm";
lassulus = "http://cgit.orange.r/stockholm";
};
})
({ krebs.git = defineRepo {
name = "krops";
desc = "deployment tools";
section = "deployment";
};})
];
2016-02-15 13:03:47 +00:00
}