Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport release-24.05] nixos/gitlab: replace git package with bundled git #329631

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 15 additions & 18 deletions nixos/modules/services/misc/gitlab.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ let
toml = pkgs.formats.toml {};
yaml = pkgs.formats.yaml {};

git = cfg.packages.gitaly.git;

postgresqlPackage = if config.services.postgresql.enable then
config.services.postgresql.package
else
Expand Down Expand Up @@ -51,7 +53,7 @@ let
prometheus_listen_addr = "localhost:9236"

[git]
bin_path = "${pkgs.git}/bin/git"
bin_path = "${git}/bin/git"

[gitlab-shell]
dir = "${cfg.packages.gitlab-shell}"
Expand Down Expand Up @@ -184,16 +186,15 @@ let
MALLOC_ARENA_MAX = "2";
} // cfg.extraEnv;

runtimeDeps = with pkgs; [
runtimeDeps = [ git ] ++ (with pkgs; [
nodejs
gzip
git
gnutar
postgresqlPackage
coreutils
procps
findutils # Needed for gitlab:cleanup:orphan_job_artifact_files
];
]);

gitlab-rake = pkgs.stdenv.mkDerivation {
name = "gitlab-rake";
Expand Down Expand Up @@ -1295,12 +1296,11 @@ in {
systemd.services.gitlab-config = {
wantedBy = [ "gitlab.target" ];
partOf = [ "gitlab.target" ];
path = with pkgs; [
path = [ git ] ++ (with pkgs; [
jq
openssl
replace-secret
git
];
]);
serviceConfig = {
Type = "oneshot";
User = cfg.user;
Expand Down Expand Up @@ -1458,9 +1458,8 @@ in {
SIDEKIQ_MEMORY_KILLER_GRACE_TIME = cfg.sidekiq.memoryKiller.graceTime;
SIDEKIQ_MEMORY_KILLER_SHUTDOWN_WAIT = cfg.sidekiq.memoryKiller.shutdownWait;
});
path = with pkgs; [
path = [ git ] ++ (with pkgs; [
postgresqlPackage
git
ruby
openssh
nodejs
Expand All @@ -1473,7 +1472,7 @@ in {
gzip

procps # Sidekiq MemoryKiller
];
]);
serviceConfig = {
Type = "simple";
User = cfg.user;
Expand All @@ -1500,12 +1499,11 @@ in {
bindsTo = [ "gitlab-config.service" ];
wantedBy = [ "gitlab.target" ];
partOf = [ "gitlab.target" ];
path = with pkgs; [
path = [ git ] ++ (with pkgs; [
openssh
git
gzip
bzip2
];
]);
serviceConfig = {
Type = "simple";
User = cfg.user;
Expand Down Expand Up @@ -1582,15 +1580,15 @@ in {
after = [ "network.target" ];
wantedBy = [ "gitlab.target" ];
partOf = [ "gitlab.target" ];
path = with pkgs; [
path = [ git ] ++ (with pkgs; [
remarshal
exiftool
git
gnutar
gzip
openssh
cfg.packages.gitlab-workhorse
];
]);
serviceConfig = {
Type = "simple";
User = cfg.user;
Expand Down Expand Up @@ -1658,15 +1656,14 @@ in {
requiredBy = [ "gitlab.target" ];
partOf = [ "gitlab.target" ];
environment = gitlabEnv;
path = with pkgs; [
path = [ git ] ++ (with pkgs; [
postgresqlPackage
git
openssh
nodejs
procps
gnupg
gzip
];
]);
serviceConfig = {
Type = "notify";
User = cfg.user;
Expand Down
2 changes: 2 additions & 0 deletions nixos/tests/gitlab.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ in {
gitlab = { ... }: {
imports = [ common/user-account.nix ];

environment.systemPackages = with pkgs; [ git ];

virtualisation.memorySize = 6144;
virtualisation.cores = 4;
virtualisation.useNixStoreImage = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ lib
, callPackage
, fetchFromGitLab
, fetchFromGitHub
, buildGoModule
Expand All @@ -10,6 +11,8 @@ let
package_version = "v${lib.versions.major version}";
gitaly_package = "gitlab.com/gitlab-org/gitaly/${package_version}";

git = callPackage ./git.nix { };

commonOpts = {
inherit version;

Expand All @@ -27,8 +30,6 @@ let

tags = [ "static" ];

nativeBuildInputs = [ pkg-config ];

doCheck = false;
};

Expand All @@ -50,6 +51,10 @@ buildGoModule ({

outputs = [ "out" ];

passthru = {
inherit git;
};

meta = with lib; {
homepage = "https://gitlab.com/gitlab-org/gitaly";
description = "A Git RPC service for handling all the git calls made by GitLab";
Expand Down
57 changes: 57 additions & 0 deletions pkgs/applications/version-management/gitlab/gitaly/git.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{ stdenv
, lib
, gitaly
, fetchFromGitLab
, curl
, pcre2
, zlib
}:

stdenv.mkDerivation rec {
pname = "gitaly-git";
version = "2.44.1.gl1";

# `src` attribute for nix-update
src = fetchFromGitLab {
owner = "gitlab-org";
repo = "git";
rev = "v${version}";
hash = "sha256-1XtzM2dYbt3nsYOm5isgHnolfziyIC9yCTkfLJ95V6Y=";
};

# we actually use the gitaly build system
unpackPhase = ''
cp -r ${gitaly.src} source
chmod -R +w source

mkdir -p source/_build/deps

cp -r ${src} source/_build/deps/git-distribution
chmod -R +w source/_build/deps/git-distribution

# FIXME? maybe just patch the makefile?
echo -n 'v${version} DEVELOPER=1 DEVOPTS=no-error USE_LIBPCRE=YesPlease NO_PERL=YesPlease NO_EXPAT=YesPlease NO_TCLTK=YesPlease NO_GETTEXT=YesPlease NO_PYTHON=YesPlease' > source/_build/deps/git-distribution.version
echo -n 'v${version}' > source/_build/deps/git-distribution/version
'';
sourceRoot = "source";

buildFlags = [ "git" ];

buildInputs = [
curl
pcre2
zlib
];

# The build phase already installs it all
GIT_PREFIX = placeholder "out";
dontInstall = true;

meta = {
homepage = "https://git-scm.com/";
description = "Distributed version control system - with Gitaly patches";
license = lib.licenses.gpl2Only;
platforms = lib.platforms.all;
maintainers = lib.teams.gitlab.members;
};
}
8 changes: 8 additions & 0 deletions pkgs/applications/version-management/gitlab/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,16 @@ def update_gitaly():
logger.info("Updating gitaly")
data = _get_data_json()
gitaly_server_version = data['passthru']['GITALY_SERVER_VERSION']
repo = GitLabRepo(repo="gitaly")
gitaly_dir = pathlib.Path(__file__).parent / 'gitaly'

makefile = repo.get_file("Makefile", f"v{gitaly_server_version}")
makefile += "\nprint-%:;@echo $($*)\n"

git_version = subprocess.run(["make", "-f", "-", "print-GIT_VERSION"], check=True, input=makefile, text=True, capture_output=True).stdout.strip()

_call_nix_update("gitaly", gitaly_server_version)
_call_nix_update("gitaly.git", git_version)


@cli.command("update-gitlab-pages")
Expand Down
Loading