aboutsummaryrefslogtreecommitdiff
path: root/virtual/modules/gitolite.nix
diff options
context:
space:
mode:
Diffstat (limited to 'virtual/modules/gitolite.nix')
-rw-r--r--virtual/modules/gitolite.nix73
1 files changed, 73 insertions, 0 deletions
diff --git a/virtual/modules/gitolite.nix b/virtual/modules/gitolite.nix
new file mode 100644
index 0000000..85c7be1
--- /dev/null
+++ b/virtual/modules/gitolite.nix
@@ -0,0 +1,73 @@
1{ lib, pkgs, config, mylibs, ... }:
2let
3 cfg = config.services.myGitolite;
4in {
5 options.services.myGitolite = {
6 enable = lib.mkEnableOption "my gitolite service";
7 };
8
9 config = lib.mkIf cfg.enable {
10 nixpkgs.config.packageOverrides = oldpkgs: rec {
11 gitolite = oldpkgs.gitolite.overrideAttrs(old: rec {
12 name = "gitolite-${version}";
13 version = "3.6.10";
14 src = pkgs.fetchFromGitHub {
15 owner = "sitaramc";
16 repo = "gitolite";
17 rev = "v${version}";
18 sha256 = "0p2697mn6rwm03ndlv7q137zczai82n41aplq1g006ii7f12xy8h";
19 };
20 });
21 };
22
23 system.activationScripts.gitolite =
24 assert mylibs.checkEnv "NIXOPS_GITOLITE_LDAP_PASSWORD";
25 let
26 gitolite_ldap_groups = mylibs.wrap {
27 name = "gitolite_ldap_groups.sh";
28 file = ./gitolite/gitolite_ldap_groups.sh;
29 vars = {
30 LDAP_PASS = builtins.getEnv "NIXOPS_GITOLITE_LDAP_PASSWORD";
31 };
32 paths = [ pkgs.openldap pkgs.stdenv.shellPackage pkgs.gnugrep pkgs.coreutils ];
33 };
34 in {
35 deps = [ "users" ];
36 text = ''
37 if [ -d /var/lib/gitolite ]; then
38 ln -sf ${gitolite_ldap_groups} /var/lib/gitolite/gitolite_ldap_groups.sh
39 chmod g+rx /var/lib/gitolite
40 fi
41 if [ -f /var/lib/gitolite/projects.list ]; then
42 chmod g+r /var/lib/gitolite/projects.list
43 fi
44 '';
45 };
46
47 users.users.wwwrun.extraGroups = [ "gitolite" ];
48
49 users.users.gitolite.packages = let
50 python-packages = python-packages: with python-packages; [
51 simplejson
52 urllib3
53 ];
54 in
55 [
56 (pkgs.python3.withPackages python-packages)
57 ];
58 # FIXME: after initial install, need to
59 # (1) copy rc file (adjust gitolite_ldap_groups.sh)
60 # (2) (mark old readonly and) sync repos except gitolite-admin
61 # rsync -av --exclude=gitolite-admin.git old:/var/lib/gitolite/repositories /var/lib/gitolite/
62 # chown -R gitolite:gitolite /var/lib/gitolite
63 # (3) push force the gitolite-admin to new location (from external point)
64 # Don't use an existing key, it will take precedence over
65 # gitolite-admin
66 # (4) su -u gitolite gitolite setup
67 services.gitolite = {
68 enable = true;
69 # FIXME: key from ./ssh
70 adminPubkey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDXqRbiHw7QoHADNIEuo4nUT9fSOIEBMdJZH0bkQAxXyJFyCM1IMz0pxsHV0wu9tdkkr36bPEUj2aV5bkYLBN6nxcV2Y49X8bjOSCPfx3n6Own1h+NeZVBj4ZByrFmqCbTxUJIZ2bZKcWOFncML39VmWdsVhNjg0X4NBBehqXRIKr2gt3E/ESAxTYJFm0BnU0baciw9cN0bsRGqvFgf5h2P48CIAfwhVcGmPQnnAwabnosYQzRWxR0OygH5Kd8mePh6FheIRIigfXsDO8f/jdxwut8buvNIf3m5EBr3tUbTsvM+eV3M5vKGt7sk8T64DVtepTSdOOWtp+47ktsnHOMh immae@immae.eu";
71 };
72 };
73}