about summary refs log tree commit diff
path: root/pkgs/applications/version-management/gitlab/default.nix
diff options
context:
space:
mode:
authortalyz <kim.lindberger@gmail.com>2019-10-19 16:36:24 +0200
committertalyz <kim.lindberger@gmail.com>2019-10-19 19:30:28 +0200
commited4a09c6f362bdbb1a25d16078dde7580c933663 (patch)
tree838c61f0e9fd964fbeb0ac1a8c036cb3717ea863 /pkgs/applications/version-management/gitlab/default.nix
parent5617886b16ccf0b5e9bf6c7f93d79162cc14fad3 (diff)
downloadnixlib-ed4a09c6f362bdbb1a25d16078dde7580c933663.tar
nixlib-ed4a09c6f362bdbb1a25d16078dde7580c933663.tar.gz
nixlib-ed4a09c6f362bdbb1a25d16078dde7580c933663.tar.bz2
nixlib-ed4a09c6f362bdbb1a25d16078dde7580c933663.tar.lz
nixlib-ed4a09c6f362bdbb1a25d16078dde7580c933663.tar.xz
nixlib-ed4a09c6f362bdbb1a25d16078dde7580c933663.tar.zst
nixlib-ed4a09c6f362bdbb1a25d16078dde7580c933663.zip
gitlab: Get rid of most 'already initialized constant'-warnings
On start, unicorn, sidekiq and other parts running ruby code emits
quite a few warnings similar to

/var/gitlab/state/config/application.rb:202: warning: already initialized constant Gitlab::Application::LOOSE_EE_APP_ASSETS
/nix/store/ysb0lgbzxp7a9y4yl8d4f9wrrzy9kafc-gitlab-ee-12.3.5/share/gitlab/config/application.rb:202: warning: previous definition of LOOSE_EE_APP_ASSETS was here
/var/gitlab/state/lib/gitlab.rb:38: warning: already initialized constant Gitlab::COM_URL
/nix/store/ysb0lgbzxp7a9y4yl8d4f9wrrzy9kafc-gitlab-ee-12.3.5/share/gitlab/lib/gitlab.rb:38: warning: previous definition of COM_URL was here

This seems to be caused by the same ruby files being evaluated
multiple times due to the paths being different - sometimes they're
loaded using the direct path and sometimes through a symlink, due to
our split between config and package data. To fix this, we make sure
that the offending files in the state directory always reference the
store path, regardless of that being the real file or a symlink.
Diffstat (limited to 'pkgs/applications/version-management/gitlab/default.nix')
-rw-r--r--pkgs/applications/version-management/gitlab/default.nix9
1 files changed, 8 insertions, 1 deletions
diff --git a/pkgs/applications/version-management/gitlab/default.nix b/pkgs/applications/version-management/gitlab/default.nix
index 99b408bcef32..e6ed0ef53a22 100644
--- a/pkgs/applications/version-management/gitlab/default.nix
+++ b/pkgs/applications/version-management/gitlab/default.nix
@@ -1,7 +1,7 @@
 { stdenv, lib, fetchurl, fetchFromGitLab, bundlerEnv
 , ruby, tzdata, git, nettools, nixosTests, nodejs
 , gitlabEnterprise ? false, callPackage, yarn
-, yarn2nix-moretea
+, yarn2nix-moretea, replace
 }:
 
 let
@@ -118,6 +118,13 @@ stdenv.mkDerivation {
 
     sed -i '/ask_to_continue/d' lib/tasks/gitlab/two_factor.rake
     sed -ri -e '/log_level/a config.logger = Logger.new(STDERR)' config/environments/production.rb
+
+    # Always require lib-files and application.rb through their store
+    # path, not their relative state directory path. This gets rid of
+    # warnings and means we don't have to link back to lib from the
+    # state directory.
+    ${replace}/bin/replace-literal -f -r -e '../lib' "$out/share/gitlab/lib" config
+    ${replace}/bin/replace-literal -f -r -e "require_relative 'application'" "require_relative '$out/share/gitlab/config/application'" config
   '';
 
   buildPhase = ''