git shell setup
This commit is contained in:
parent
85254cfba1
commit
7573798348
1 changed files with 51 additions and 2 deletions
|
|
@ -1,6 +1,48 @@
|
||||||
{ pkgs, var, ... }:
|
{
|
||||||
|
pkgs,
|
||||||
|
var,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
gitpath = "/git";
|
gitpath = "/git";
|
||||||
|
git-config = pkgs.writeText "git-git-config" ''
|
||||||
|
[init]
|
||||||
|
defaultBranch = main
|
||||||
|
'';
|
||||||
|
git-shell-commands = {
|
||||||
|
"create" = ''
|
||||||
|
#!/bin/sh
|
||||||
|
REPO_NAME="$1"
|
||||||
|
if [ -z "$REPO_NAME" ]; then
|
||||||
|
echo "Usage: $0 <repo-name>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
REPO_PATH="${gitpath}/$REPO_NAME.git"
|
||||||
|
if [ -d "$REPO_PATH" ]; then
|
||||||
|
echo "Repository '$REPO_NAME' already exists."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
git init --bare "$REPO_PATH"
|
||||||
|
echo "Created bare repository: $REPO_PATH"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
git-shell-commands-dir = pkgs.stdenv.mkDerivation {
|
||||||
|
name = "git-shell-commands-dir";
|
||||||
|
version = "0.0.1";
|
||||||
|
src = null;
|
||||||
|
dontUnpack = true;
|
||||||
|
buildPhase = "";
|
||||||
|
installPhase = lib.concatStringsSep "\n" (
|
||||||
|
lib.mapAttrsToList (name: script: ''
|
||||||
|
mkdir -p $out
|
||||||
|
cat <<'EOF' > $out/${name}
|
||||||
|
${script}
|
||||||
|
EOF
|
||||||
|
chmod +x $out/${name}
|
||||||
|
'') git-shell-commands
|
||||||
|
);
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
programs.git.enable = true;
|
programs.git.enable = true;
|
||||||
|
|
@ -14,8 +56,14 @@ in
|
||||||
shell = "${pkgs.git}/bin/git-shell";
|
shell = "${pkgs.git}/bin/git-shell";
|
||||||
openssh.authorizedKeys.keys = var.ssh-keys.hd;
|
openssh.authorizedKeys.keys = var.ssh-keys.hd;
|
||||||
hashedPassword = "!";
|
hashedPassword = "!";
|
||||||
|
packages = [ pkgs.git ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.tmpfiles.rules = [
|
||||||
|
"L+ ${gitpath}/git-shell-commands - - - - ${git-shell-commands-dir}"
|
||||||
|
"L+ ${gitpath}/.gitconfig - - - - ${git-config}"
|
||||||
|
];
|
||||||
|
|
||||||
services =
|
services =
|
||||||
let
|
let
|
||||||
cgit-host = "git.lan";
|
cgit-host = "git.lan";
|
||||||
|
|
@ -26,9 +74,10 @@ in
|
||||||
};
|
};
|
||||||
cgit."git" = {
|
cgit."git" = {
|
||||||
group = "git";
|
group = "git";
|
||||||
enable = false; # FIXME: find out what breaks here
|
enable = true;
|
||||||
scanPath = gitpath;
|
scanPath = gitpath;
|
||||||
nginx.virtualHost = cgit-host;
|
nginx.virtualHost = cgit-host;
|
||||||
|
gitHttpBackend.checkExportOkFiles = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue