gitolite: wrap gitolite-shell
git wasn't found when used with services.fcgiwrap for http auth
This commit is contained in:
parent
0ccde691f8
commit
9314dc43b3
@ -94,6 +94,7 @@ in
|
||||
gitea = handleTest ./gitea.nix {};
|
||||
gitlab = handleTest ./gitlab.nix {};
|
||||
gitolite = handleTest ./gitolite.nix {};
|
||||
gitolite-fcgiwrap = handleTest ./gitolite-fcgiwrap.nix {};
|
||||
glusterfs = handleTest ./glusterfs.nix {};
|
||||
gnome3-xorg = handleTest ./gnome3-xorg.nix {};
|
||||
gnome3 = handleTest ./gnome3.nix {};
|
||||
|
93
nixos/tests/gitolite-fcgiwrap.nix
Normal file
93
nixos/tests/gitolite-fcgiwrap.nix
Normal file
@ -0,0 +1,93 @@
|
||||
import ./make-test-python.nix (
|
||||
{ pkgs, ... }:
|
||||
|
||||
let
|
||||
user = "gitolite-admin";
|
||||
password = "some_password";
|
||||
|
||||
# not used but needed to setup gitolite
|
||||
adminPublicKey = ''
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO7urFhAA90BTpGuEHeWWTY3W/g9PBxXNxfWhfbrm4Le root@client
|
||||
'';
|
||||
in
|
||||
{
|
||||
name = "gitolite-fcgiwrap";
|
||||
|
||||
meta = with pkgs.stdenv.lib.maintainers; {
|
||||
maintainers = [ bbigras ];
|
||||
};
|
||||
|
||||
nodes = {
|
||||
|
||||
server =
|
||||
{ ... }:
|
||||
{
|
||||
networking.firewall.allowedTCPPorts = [ 80 ];
|
||||
|
||||
services.fcgiwrap.enable = true;
|
||||
services.gitolite = {
|
||||
enable = true;
|
||||
adminPubkey = adminPublicKey;
|
||||
};
|
||||
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
recommendedProxySettings = true;
|
||||
virtualHosts."server".locations."/git".extraConfig = ''
|
||||
# turn off gzip as git objects are already well compressed
|
||||
gzip off;
|
||||
|
||||
# use file based basic authentication
|
||||
auth_basic "Git Repository Authentication";
|
||||
auth_basic_user_file /etc/gitolite/htpasswd;
|
||||
|
||||
# common FastCGI parameters are required
|
||||
include ${pkgs.nginx}/conf/fastcgi_params;
|
||||
|
||||
# strip the CGI program prefix
|
||||
fastcgi_split_path_info ^(/git)(.*)$;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
|
||||
# pass authenticated user login(mandatory) to Gitolite
|
||||
fastcgi_param REMOTE_USER $remote_user;
|
||||
|
||||
# pass git repository root directory and hosting user directory
|
||||
# these env variables can be set in a wrapper script
|
||||
fastcgi_param GIT_HTTP_EXPORT_ALL "";
|
||||
fastcgi_param GIT_PROJECT_ROOT /var/lib/gitolite/repositories;
|
||||
fastcgi_param GITOLITE_HTTP_HOME /var/lib/gitolite;
|
||||
fastcgi_param SCRIPT_FILENAME ${pkgs.gitolite}/bin/gitolite-shell;
|
||||
|
||||
# use Unix domain socket or inet socket
|
||||
fastcgi_pass unix:/run/fcgiwrap.sock;
|
||||
'';
|
||||
};
|
||||
|
||||
# WARNING: DON'T DO THIS IN PRODUCTION!
|
||||
# This puts unhashed secrets directly into the Nix store for ease of testing.
|
||||
environment.etc."gitolite/htpasswd".source = pkgs.runCommand "htpasswd" {} ''
|
||||
${pkgs.apacheHttpd}/bin/htpasswd -bc "$out" ${user} ${password}
|
||||
'';
|
||||
};
|
||||
|
||||
client =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
environment.systemPackages = [ pkgs.git ];
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
start_all()
|
||||
|
||||
server.wait_for_unit("gitolite-init.service")
|
||||
server.wait_for_unit("nginx.service")
|
||||
server.wait_for_file("/run/fcgiwrap.sock")
|
||||
|
||||
client.wait_for_unit("multi-user.target")
|
||||
client.succeed(
|
||||
"git clone http://${user}:${password}@server/git/gitolite-admin.git"
|
||||
)
|
||||
'';
|
||||
}
|
||||
)
|
@ -1,4 +1,4 @@
|
||||
{ stdenv, fetchFromGitHub, git, nettools, perl }:
|
||||
{ stdenv, fetchFromGitHub, git, lib, makeWrapper, nettools, perl }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "gitolite";
|
||||
@ -11,7 +11,9 @@ stdenv.mkDerivation rec {
|
||||
sha256 = "1rkj7gknwjlc5ij9w39zf5mr647bm45la57yjczydmvrb8c56yrh";
|
||||
};
|
||||
|
||||
buildInputs = [ git nettools perl ];
|
||||
buildInputs = [ nettools perl ];
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
propagatedBuildInputs = [ git ];
|
||||
|
||||
dontBuild = true;
|
||||
|
||||
@ -25,6 +27,11 @@ stdenv.mkDerivation rec {
|
||||
--replace hostname "${nettools}/bin/hostname"
|
||||
'';
|
||||
|
||||
postFixup = ''
|
||||
wrapProgram $out/bin/gitolite-shell \
|
||||
--prefix PATH : "${git}/bin"
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
perl ./install -to $out/bin
|
||||
|
Loading…
Reference in New Issue
Block a user