8 , gitlabEnterprise ? false
21 # gitlab-glfm-markdown
22 , buildRubyGem, cargo, rustc, rustPlatform
38 data = lib.importJSON ./data.json;
40 version = data.version;
41 src = fetchFromGitLab {
45 sha256 = data.repo_hash;
48 rubyEnv = bundlerEnv rec {
49 name = "gitlab-env-${version}";
52 gemset = import (gemdir + "/gemset.nix") src;
53 gemConfig = defaultGemConfig // {
55 nativeBuildInputs = [ pkg-config ];
57 # the openssl needs the openssl include files
59 buildInputs = [ openssl ];
62 buildInputs = [ file ];
63 buildFlags = [ "--enable-system-libraries" ];
65 gitlab-glfm-markdown = attrs: {
66 cargoDeps = rustPlatform.fetchCargoTarball {
67 src = stdenv.mkDerivation {
68 inherit (buildRubyGem { inherit (attrs) gemName version source; })
76 cp -R ext/glfm_markdown $out
80 hash = "sha256-L/URWw7NoQhi7VV8ZiKLzthbF0wl4rIUqCQdH9wmAV0=";
88 rustPlatform.cargoSetupHook
89 rustPlatform.bindgenHook
92 disallowedReferences = [
97 export CARGO_HOME="$PWD/../.cargo/"
101 mv -v $GEM_HOME/gems/${attrs.gemName}-${attrs.version}/lib/{glfm_markdown/glfm_markdown.so,}
102 find $out -type f -name .rustc_info.json -delete
106 static_holmes = attrs: {
107 nativeBuildInputs = [
115 "default" "unicorn" "ed25519" "metrics" "development" "puma" "test" "kerberos" "opentelemetry"
117 # N.B. omniauth_oauth2_generic and apollo_upload_server both provide a
118 # `console` executable.
119 ignoreCollisions = true;
121 extraConfigPaths = [ "${src}/vendor" "${src}/gems" ];
124 assets = stdenv.mkDerivation {
125 pname = "gitlab-assets";
128 yarnOfflineCache = fetchYarnDeps {
129 yarnLock = src + "/yarn.lock";
130 sha256 = data.yarn_hash;
133 nativeBuildInputs = [ rubyEnv.wrappedRuby rubyEnv.bundler nodejs yarn git cacert fixup-yarn-lock ];
136 # Since version 12.6.0, the rake tasks need the location of git,
137 # so we have to apply the location patches here too.
138 ./remove-hardcoded-locations.patch
140 # Gitlab edited the default database config since [1] and the
141 # installer now complains about valid keywords only being "main", "ci" and "embedded".
143 # [1]: https://gitlab.com/gitlab-org/gitlab/-/commit/99c0fac52b10cd9df62bbe785db799352a2d9028
144 ./Remove-unsupported-database-names.patch
146 # One of the patches uses this variable - if it's unset, execution
147 # of rake tasks fails.
148 GITLAB_LOG_PATH = "log";
149 FOSS_ONLY = !gitlabEnterprise;
151 SKIP_YARN_INSTALL = 1;
156 # Some rake tasks try to run yarn automatically, which won't work
157 rm lib/tasks/yarn.rake
159 # The rake tasks won't run without a basic configuration in place
160 mv config/database.yml.postgresql config/database.yml
161 mv config/gitlab.yml.example config/gitlab.yml
163 # Yarn and bundler wants a real home directory to write cache, config, etc to
164 export HOME=$NIX_BUILD_TOP/fake_home
166 # Make yarn install packages from our offline cache, not the registry
167 yarn config --offline set yarn-offline-mirror $yarnOfflineCache
169 # Fixup "resolved"-entries in yarn.lock to match our offline cache
170 fixup-yarn-lock yarn.lock
172 yarn install --offline --frozen-lockfile --ignore-scripts --no-progress --non-interactive
174 patchShebangs node_modules/
175 patchShebangs scripts/frontend/
177 runHook postConfigure
183 bundle exec rake gitlab:assets:compile RAILS_ENV=production NODE_ENV=production SKIP_YARN_INSTALL=true
191 mv public/assets $out
197 stdenv.mkDerivation {
198 name = "gitlab${lib.optionalString gitlabEnterprise "-ee"}-${version}";
202 nativeBuildInputs = [ makeWrapper ];
204 rubyEnv rubyEnv.wrappedRuby rubyEnv.bundler tzdata git nettools
208 # Change hardcoded paths to the NixOS equivalent
209 ./remove-hardcoded-locations.patch
213 ${lib.optionalString (!gitlabEnterprise) ''
214 # Remove all proprietary components
216 sed -i 's/-ee//' ./VERSION
219 # For reasons I don't understand "bundle exec" ignores the
220 # RAILS_ENV causing tests to be executed that fail because we're
221 # not installing development and test gems above. Deleting the
222 # tests works though.
223 rm lib/tasks/test.rake
225 rm config/initializers/gitlab_shell_secret_token.rb
227 sed -i '/ask_to_continue/d' lib/tasks/gitlab/two_factor.rake
228 sed -ri -e '/log_level/a config.logger = Logger.new(STDERR)' config/environments/production.rb
230 mv config/puma.rb.example config/puma.rb
231 # Always require lib-files and application.rb through their store
232 # path, not their relative state directory path. This gets rid of
233 # warnings and means we don't have to link back to lib from the
235 ${replace}/bin/replace-literal -f -r -e '../../lib' "$out/share/gitlab/lib" config
236 ${replace}/bin/replace-literal -f -r -e '../lib' "$out/share/gitlab/lib" config
237 ${replace}/bin/replace-literal -f -r -e "require_relative 'application'" "require_relative '$out/share/gitlab/config/application'" config
238 ${replace}/bin/replace-literal -f -r -e 'require_relative "/home/git/gitlab/lib/gitlab/puma/error_handler"' "require_relative '$out/share/gitlab/lib/gitlab/puma/error_handler'" config
242 rm -f config/secrets.yml
243 mv config config.dist
249 cp -r . $out/share/gitlab
250 ln -sf ${assets} $out/share/gitlab/public/assets
251 rm -rf $out/share/gitlab/log
252 ln -sf /run/gitlab/log $out/share/gitlab/log
253 ln -sf /run/gitlab/uploads $out/share/gitlab/public/uploads
254 ln -sf /run/gitlab/config $out/share/gitlab/config
255 ln -sf /run/gitlab/tmp $out/share/gitlab/tmp
257 # rake tasks to mitigate CVE-2017-0882
258 # see https://about.gitlab.com/2017/03/20/gitlab-8-dot-17-dot-4-security-release/
259 cp ${./reset_token.rake} $out/share/gitlab/lib/tasks/reset_token.rake
261 # manually patch the shebang line in generate-loose-foreign-key
262 wrapProgram $out/share/gitlab/scripts/decomposition/generate-loose-foreign-key --set ENABLE_SPRING 0 --add-flags 'runner -e test'
266 inherit rubyEnv assets;
267 ruby = rubyEnv.wrappedRuby;
268 GITALY_SERVER_VERSION = data.passthru.GITALY_SERVER_VERSION;
269 GITLAB_PAGES_VERSION = data.passthru.GITLAB_PAGES_VERSION;
270 GITLAB_SHELL_VERSION = data.passthru.GITLAB_SHELL_VERSION;
271 GITLAB_WORKHORSE_VERSION = data.passthru.GITLAB_WORKHORSE_VERSION;
272 gitlabEnv.FOSS_ONLY = lib.boolToString (!gitlabEnterprise);
274 nixos-test-passes = nixosTests.gitlab;
279 homepage = "http://www.gitlab.com/";
280 platforms = platforms.linux;
281 maintainers = teams.gitlab.members;
282 } // (if gitlabEnterprise then
284 license = licenses.unfreeRedistributable; # https://gitlab.com/gitlab-org/gitlab-ee/raw/master/LICENSE
285 description = "GitLab Enterprise Edition";
289 license = licenses.mit;
290 description = "GitLab Community Edition";
291 longDescription = "GitLab Community Edition (CE) is an open source end-to-end software development platform with built-in version control, issue tracking, code review, CI/CD, and more. Self-host GitLab CE on your own servers, in a container, or on a cloud provider.";