zammad: init at 5.0.2

Co-authored-by: Rok Garbas <rok@garbas.si>
This commit is contained in:
Ember 'n0emis' Keske 2021-11-23 21:52:25 +01:00 committed by Taeer Bar-Yam
parent 7a36369036
commit 7cf49c38a5
9 changed files with 8108 additions and 0 deletions

View file

@ -0,0 +1,15 @@
diff --git a/config/application.rb b/config/application.rb
index d85a17491..90ea5e387 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -3,6 +3,7 @@
require_relative 'boot'
require 'rails/all'
+require 'nulldb'
require_relative 'issue_2656_workaround_for_rails_issue_33600'
# DO NOT REMOVE THIS LINE - see issue #2037
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 000000000..e69de29bb

View file

@ -0,0 +1,134 @@
{ stdenv
, lib
, fetchFromGitHub
, bundlerEnv
, defaultGemConfig
, callPackage
, writeText
, procps
, ruby_2_7
, postgresql
, imlib2
, nodejs
, yarn
, yarn2nix-moretea
, v8
, cacert
}:
let
pname = "zammad";
version = "5.0.2";
sourceDir = fetchFromGitHub (builtins.fromJSON (builtins.readFile ./source.json));
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;
gemdir = sourceDir;
gemset = ./gemset.nix;
groups = [
"assets"
"unicorn" # server
"nulldb"
"test"
"mysql"
"puma"
"development"
"postgres" # database
];
gemConfig = defaultGemConfig // {
pg = attrs: {
buildFlags = [ "--with-pg-config=${postgresql}/bin/pg_config" ];
};
rszr = attrs: {
buildInputs = [ imlib2 imlib2.dev ];
};
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";
inherit version;
src = sourceDir;
yarnLock = ./yarn.lock;
yarnNix = ./yarn.nix;
packageJSON = sourceDir + "/package.json";
};
in stdenv.mkDerivation {
name = "${pname}-${version}";
inherit pname version;
src = sourceDir;
patches = [
./0001-nulldb.patch
];
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 = ''
mkdir -p $out/config
cp -R ./* $out
rm -R $out/tmp/*
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" ];
maintainers = with maintainers; [ n0emis ];
};
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,7 @@
{
"owner": "zammad",
"repo": "zammad",
"rev": "ad12ad4e01f5e6d1d58da019107b66e562ae463c",
"sha256": "i50A0/dBsdvv7L/fZiA1LvJEcO3OghjjgwS/7oFjk2o=",
"fetchSubmodules": true
}

View file

@ -0,0 +1,35 @@
{ stdenv
, lib
, makeWrapper
, bundix
, common-updater-scripts
, nix-prefetch-github
, yarn
, yarn2nix
}:
stdenv.mkDerivation rec {
name = "zammad-update-script";
installPhase = ''
mkdir -p $out/bin
cp ${./update.sh} $out/bin/update.sh
patchShebangs $out/bin/update.sh
wrapProgram $out/bin/update.sh --prefix PATH : ${lib.makeBinPath buildInputs}
'';
phases = [ "installPhase" ];
nativeBuildInputs = [ makeWrapper ];
buildInputs = [
bundix
common-updater-scripts
nix-prefetch-github
yarn
yarn2nix
];
meta = {
maintainers = with lib.maintainers; [ n0emis ];
description = "Utility to generate Nix expressions for Zammad's dependencies";
platforms = lib.platforms.unix;
};
}

View file

@ -0,0 +1,65 @@
#!/usr/bin/env bash
set -euo pipefail
if [ "$#" -gt 2 ] || [[ "$1" == -* ]]; then
echo "Regenerates packaging data for the zammad packages."
echo "Usage: $0 [package name] [zammad directory in nixpkgs]"
exit 1
fi
VERSION=$(curl -s https://ftp.zammad.com/ | grep -v latest | grep tar.gz | sed "s/<a href=\".*\">zammad-//" | sort -h | tail -n 1 | awk '{print $1}' | sed 's/.tar.gz<\/a>//')
TARGET_DIR="$2"
WORK_DIR=$(mktemp -d)
SOURCE_DIR=$WORK_DIR/zammad-$VERSION
pushd $TARGET_DIR
rm -rf \
./source.json \
./gemset.nix \
./yarn.lock \
./yarn.nix
# Check that working directory was created.
if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
echo "Could not create temporary directory."
exit 1
fi
# Delete the working directory on exit.
function cleanup {
rm -rf "$WORK_DIR"
}
trap cleanup EXIT
pushd $WORK_DIR
echo ":: Creating source.json"
nix-prefetch-github zammad zammad --rev $VERSION --json > $TARGET_DIR/source.json
echo >> $TARGET_DIR/source.json
echo ":: Fetching source"
curl -L https://github.com/zammad/zammad/archive/$VERSION.tar.gz --output source.tar.gz
tar zxf source.tar.gz
if [[ ! "$SOURCE_DIR" || ! -d "$SOURCE_DIR" ]]; then
echo "Source directory does not exists."
exit 1
fi
pushd $SOURCE_DIR
echo ":: Creating gemset.nix"
bundix --lockfile=./Gemfile.lock --gemfile=./Gemfile --gemset=$TARGET_DIR/gemset.nix
echo ":: Creating yarn.nix"
yarn install
cp yarn.lock $TARGET_DIR
yarn2nix > $TARGET_DIR/yarn.nix
popd
popd
popd

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -30129,6 +30129,8 @@ with pkgs;
zam-plugins = callPackage ../applications/audio/zam-plugins { };
zammad = callPackage ../applications/networking/misc/zammad { };
zanshin = libsForQt5.callPackage ../applications/office/zanshin { };
zathuraPkgs = callPackage ../applications/misc/zathura { };