2021-11-23 20:52:25 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchFromGitHub
|
2022-02-08 14:46:18 +00:00
|
|
|
, applyPatches
|
2021-11-23 20:52:25 +00:00
|
|
|
, bundlerEnv
|
|
|
|
, defaultGemConfig
|
|
|
|
, callPackage
|
|
|
|
, writeText
|
|
|
|
, procps
|
|
|
|
, ruby_2_7
|
|
|
|
, postgresql
|
|
|
|
, imlib2
|
2022-03-21 09:27:10 +00:00
|
|
|
, jq
|
|
|
|
, moreutils
|
2021-11-23 20:52:25 +00:00
|
|
|
, nodejs
|
|
|
|
, yarn
|
|
|
|
, yarn2nix-moretea
|
|
|
|
, v8
|
|
|
|
, cacert
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
pname = "zammad";
|
2022-05-11 12:47:20 +00:00
|
|
|
version = "5.1.1";
|
2021-11-23 20:52:25 +00:00
|
|
|
|
2022-02-16 21:58:20 +00:00
|
|
|
src = applyPatches {
|
2022-02-08 14:46:18 +00:00
|
|
|
|
2022-02-22 12:38:01 +00:00
|
|
|
src = fetchFromGitHub (lib.importJSON ./source.json);
|
2022-02-08 14:46:18 +00:00
|
|
|
|
|
|
|
patches = [ ./0001-nulldb.patch ];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
sed -i -e "s|ruby '2.7.4'|ruby '${ruby_2_7.version}'|" Gemfile
|
|
|
|
sed -i -e "s|ruby 2.7.4p191|ruby ${ruby_2_7.version}|" Gemfile.lock
|
|
|
|
sed -i -e "s|2.7.4|${ruby_2_7.version}|" .ruby-version
|
2022-03-21 09:27:10 +00:00
|
|
|
${jq}/bin/jq '. += {name: "Zammad", version: "${version}"}' package.json | ${moreutils}/bin/sponge package.json
|
2022-02-08 14:46:18 +00:00
|
|
|
'';
|
|
|
|
};
|
2021-11-23 20:52:25 +00:00
|
|
|
|
|
|
|
databaseConfig = writeText "database.yml" ''
|
|
|
|
production:
|
|
|
|
url: <%= ENV['DATABASE_URL'] %>
|
|
|
|
'';
|
|
|
|
|
|
|
|
secretsConfig = writeText "secrets.yml" ''
|
|
|
|
production:
|
|
|
|
secret_key_base: <%= ENV['SECRET_KEY_BASE'] %>
|
|
|
|
'';
|
|
|
|
|
|
|
|
rubyEnv = bundlerEnv {
|
|
|
|
name = "${pname}-gems-${version}";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
# Which ruby version to select:
|
|
|
|
# https://docs.zammad.org/en/latest/prerequisites/software.html#ruby-programming-language
|
|
|
|
inherit ruby_2_7;
|
|
|
|
|
2022-02-23 03:50:33 +00:00
|
|
|
gemdir = src;
|
2021-11-23 20:52:25 +00:00
|
|
|
gemset = ./gemset.nix;
|
|
|
|
groups = [
|
|
|
|
"assets"
|
2022-02-16 21:50:22 +00:00
|
|
|
"unicorn" # server
|
2021-11-23 20:52:25 +00:00
|
|
|
"nulldb"
|
|
|
|
"test"
|
|
|
|
"mysql"
|
|
|
|
"puma"
|
|
|
|
"development"
|
2022-02-16 21:50:22 +00:00
|
|
|
"postgres" # database
|
2021-11-23 20:52:25 +00:00
|
|
|
];
|
|
|
|
gemConfig = defaultGemConfig // {
|
|
|
|
pg = attrs: {
|
|
|
|
buildFlags = [ "--with-pg-config=${postgresql}/bin/pg_config" ];
|
|
|
|
};
|
|
|
|
rszr = attrs: {
|
|
|
|
buildInputs = [ imlib2 imlib2.dev ];
|
2022-03-21 09:27:10 +00:00
|
|
|
buildFlags = [ "--without-imlib2-config" ];
|
2021-11-23 20:52:25 +00:00
|
|
|
};
|
|
|
|
mini_racer = attrs: {
|
|
|
|
buildFlags = [
|
|
|
|
"--with-v8-dir=\"${v8}\""
|
|
|
|
];
|
|
|
|
dontBuild = false;
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace ext/mini_racer_extension/extconf.rb \
|
|
|
|
--replace Libv8.configure_makefile '$CPPFLAGS += " -x c++"; Libv8.configure_makefile'
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
yarnEnv = yarn2nix-moretea.mkYarnPackage {
|
|
|
|
pname = "${pname}-node-modules";
|
2022-02-16 21:58:20 +00:00
|
|
|
inherit version src;
|
2021-11-23 20:52:25 +00:00
|
|
|
yarnLock = ./yarn.lock;
|
|
|
|
yarnNix = ./yarn.nix;
|
2022-02-23 03:50:33 +00:00
|
|
|
packageJSON = ./package.json;
|
2021-11-23 20:52:25 +00:00
|
|
|
};
|
|
|
|
|
2022-02-16 21:50:22 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
2022-02-16 21:58:20 +00:00
|
|
|
inherit pname version src;
|
2021-11-23 20:52:25 +00:00
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
rubyEnv
|
|
|
|
rubyEnv.wrappedRuby
|
|
|
|
rubyEnv.bundler
|
|
|
|
yarn
|
|
|
|
nodejs
|
|
|
|
procps
|
|
|
|
cacert
|
|
|
|
];
|
|
|
|
|
|
|
|
RAILS_ENV = "production";
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
node_modules=${yarnEnv}/libexec/Zammad/node_modules
|
|
|
|
${yarn2nix-moretea.linkNodeModulesHook}
|
|
|
|
|
|
|
|
rake DATABASE_URL="nulldb://user:pass@127.0.0.1/dbname" assets:precompile
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2022-02-22 10:37:03 +00:00
|
|
|
cp -R . $out
|
2021-11-23 20:52:25 +00:00
|
|
|
cp ${databaseConfig} $out/config/database.yml
|
|
|
|
cp ${secretsConfig} $out/config/secrets.yml
|
|
|
|
sed -i -e "s|info|debug|" $out/config/environments/production.rb
|
|
|
|
'';
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
inherit rubyEnv yarnEnv;
|
|
|
|
updateScript = [ "${callPackage ./update.nix {}}/bin/update.sh" pname (toString ./.) ];
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Zammad, a web-based, open source user support/ticketing solution.";
|
|
|
|
homepage = "https://zammad.org";
|
|
|
|
license = licenses.agpl3Plus;
|
|
|
|
platforms = [ "x86_64-linux" ];
|
2022-02-16 21:58:20 +00:00
|
|
|
maintainers = with maintainers; [ n0emis garbas taeer ];
|
2021-11-23 20:52:25 +00:00
|
|
|
};
|
|
|
|
}
|