From fc7723297f36404dd0395914e53025afd90cdb27 Mon Sep 17 00:00:00 2001 From: nialov Date: Sun, 19 Jan 2025 10:48:22 +0200 Subject: [PATCH] nixos/gollum: check if stateDir is an existing bare git repository If stateDir is directed at a bare repository, git init will generate a normal repository within stateDir instead of letting gollum use the bare repository. --- nixos/modules/services/misc/gollum.nix | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/nixos/modules/services/misc/gollum.nix b/nixos/modules/services/misc/gollum.nix index 525333d80d11..7179273f07ae 100644 --- a/nixos/modules/services/misc/gollum.nix +++ b/nixos/modules/services/misc/gollum.nix @@ -145,10 +145,16 @@ in after = [ "network.target" ]; wantedBy = [ "multi-user.target" ]; path = [ pkgs.git ]; - preStart = '' - # This is safe to be run on an existing repo - git init ${cfg.stateDir} + # Check if it's a bare repository. + IS_BARE=$(git -C "${cfg.stateDir}" rev-parse --is-bare-repository 2>/dev/null || echo "false") + + if [ "$IS_BARE" = "true" ]; then + echo "Directory is a bare repository. Skipping initialization." + else + echo "Directory is not a bare repository. Initializing..." + git init "${cfg.stateDir}" + fi ''; serviceConfig = {