nixos: add gitolite module
Signed-off-by: Austin Seipp <aseipp@pobox.com>
This commit is contained in:
parent
ec4cd43ca8
commit
3eb2d1e03e
@ -134,6 +134,7 @@
|
||||
teamspeak = 124;
|
||||
influxdb = 125;
|
||||
nsd = 126;
|
||||
gitolite = 127;
|
||||
|
||||
# When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
|
||||
|
||||
|
@ -147,6 +147,7 @@
|
||||
./services/misc/felix.nix
|
||||
./services/misc/folding-at-home.nix
|
||||
./services/misc/gpsd.nix
|
||||
./services/misc/gitolite.nix
|
||||
./services/misc/nix-daemon.nix
|
||||
./services/misc/nix-gc.nix
|
||||
./services/misc/nix-ssh-serve.nix
|
||||
|
66
nixos/modules/services/misc/gitolite.nix
Normal file
66
nixos/modules/services/misc/gitolite.nix
Normal file
@ -0,0 +1,66 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.gitolite;
|
||||
pubkeyFile = pkgs.writeText "gitolite-admin.pub" cfg.adminPubkey;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
services.gitolite = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Enable gitolite management under the
|
||||
<literal>gitolite</literal> user. The Gitolite home
|
||||
directory is <literal>/var/lib/gitolite</literal>. After
|
||||
switching to a configuration with Gitolite enabled, you can
|
||||
then run <literal>git clone
|
||||
git@host:gitolite-admin.git</literal> to manage it further.
|
||||
'';
|
||||
};
|
||||
|
||||
adminPubkey = mkOption {
|
||||
type = types.str;
|
||||
description = ''
|
||||
Initial administrative public key for Gitolite. This should
|
||||
be an SSH Public Key. Note that this key will only be used
|
||||
once, upon the first initialization of the Gitolite user.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
users.extraUsers.gitolite = {
|
||||
description = "Gitolite user";
|
||||
home = "/var/lib/gitolite";
|
||||
createHome = true;
|
||||
uid = config.ids.uids.gitolite;
|
||||
useDefaultShell = true;
|
||||
};
|
||||
|
||||
systemd.services."gitolite-init" = {
|
||||
description = "Gitolite initialization";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
serviceConfig.User = "gitolite";
|
||||
serviceConfig.Type = "oneshot";
|
||||
serviceConfig.RemainAfterExit = true;
|
||||
|
||||
path = [ pkgs.gitolite pkgs.git pkgs.perl pkgs.bash pkgs.openssh ];
|
||||
script = ''
|
||||
cd /var/lib/gitolite
|
||||
mkdir -p .gitolite/logs
|
||||
if [ ! -d repositories ]; then
|
||||
gitolite setup -pk ${pubkeyFile}
|
||||
fi
|
||||
gitolite setup # Upgrade if needed
|
||||
'';
|
||||
};
|
||||
|
||||
environment.systemPackages = [ pkgs.gitolite pkgs.git ];
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user