# SPDX-FileCopyrightText: V # SPDX-License-Identifier: OSL-3.0 { lib, writeTextDir, writeText, buildEnv, writeTextFile, bash, writeScript }: { path , branch ? "trunk" , description ? "Unnamed repository; edit this file 'description' to name the repository." , config ? {} , hooks ? {} , user ? "-", group ? "-" }: with lib; let # As generated by an initial `git init --bare` defaultConfig = { core = { repositoryFormatVersion = 0; fileMode = true; bare = true; }; }; hooksDir = buildEnv { name = "git-repository-hooks"; paths = mapAttrsToList (hook: scripts: writeTextFile { name = hook; text = '' #! ${bash}/bin/bash -e '' + concatMapStrings (script: '' ${script} "$@" '') scripts; destination = "/${hook}"; executable = true; }) hooks; }; in writeTextDir "lib/tmpfiles.d/git-repository${replaceStrings [ "/" ] [ "-" ] path}.conf" '' # Root directory needs the correct permissions d ${path} - ${user} ${group} # This is the smallest set of paths that Git will still recognise as a valid repository. # Everything else will be automatically filled out after a push or pull. f+ ${path}/HEAD - ${user} ${group} - ref: refs/heads/${branch} d ${path}/objects - ${user} ${group} d ${path}/refs - ${user} ${group} # Extra stuff we want to use L+ ${path}/config - - - - ${writeText "git-repository-config" (generators.toGitINI (recursiveUpdate defaultConfig config))} L+ ${path}/description - - - - ${builtins.toFile "git-repository-description" description} L+ ${path}/hooks - - - - ${hooksDir} ''