2014-10-07 09:53:01 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
2020-08-25 16:33:25 +01:00
|
|
|
inherit (lib) mkBefore mkDefault mkEnableOption mkIf mkOption mkRemovedOptionModule types;
|
2021-10-03 17:06:03 +01:00
|
|
|
inherit (lib) concatStringsSep literalExpression mapAttrsToList;
|
2020-08-25 16:27:30 +01:00
|
|
|
inherit (lib) optional optionalAttrs optionalString;
|
2019-06-22 21:16:24 +01:00
|
|
|
|
2014-10-07 09:53:01 +01:00
|
|
|
cfg = config.services.redmine;
|
2020-08-25 16:27:30 +01:00
|
|
|
format = pkgs.formats.yaml {};
|
2018-10-11 02:04:08 +01:00
|
|
|
bundle = "${cfg.package}/share/redmine/bin/bundle";
|
2018-08-19 21:29:44 +01:00
|
|
|
|
|
|
|
databaseYml = pkgs.writeText "database.yml" ''
|
2014-10-07 09:53:01 +01:00
|
|
|
production:
|
2018-08-19 21:29:44 +01:00
|
|
|
adapter: ${cfg.database.type}
|
|
|
|
database: ${cfg.database.name}
|
2019-06-22 21:03:42 +01:00
|
|
|
host: ${if (cfg.database.type == "postgresql" && cfg.database.socket != null) then cfg.database.socket else cfg.database.host}
|
2018-08-19 21:29:44 +01:00
|
|
|
port: ${toString cfg.database.port}
|
|
|
|
username: ${cfg.database.user}
|
|
|
|
password: #dbpass#
|
2019-06-22 21:03:42 +01:00
|
|
|
${optionalString (cfg.database.type == "mysql2" && cfg.database.socket != null) "socket: ${cfg.database.socket}"}
|
2014-10-07 09:53:01 +01:00
|
|
|
'';
|
|
|
|
|
2020-08-25 16:27:30 +01:00
|
|
|
configurationYml = format.generate "configuration.yml" cfg.settings;
|
2020-08-25 16:33:25 +01:00
|
|
|
additionalEnvironment = pkgs.writeText "additional_environment.rb" cfg.extraEnv;
|
2019-02-01 14:17:05 +00:00
|
|
|
|
2018-10-11 02:04:08 +01:00
|
|
|
unpackTheme = unpack "theme";
|
|
|
|
unpackPlugin = unpack "plugin";
|
|
|
|
unpack = id: (name: source:
|
|
|
|
pkgs.stdenv.mkDerivation {
|
|
|
|
name = "redmine-${id}-${name}";
|
2021-03-05 18:11:00 +00:00
|
|
|
nativeBuildInputs = [ pkgs.unzip ];
|
2018-10-11 02:04:08 +01:00
|
|
|
buildCommand = ''
|
|
|
|
mkdir -p $out
|
|
|
|
cd $out
|
|
|
|
unpackFile ${source}
|
|
|
|
'';
|
|
|
|
});
|
|
|
|
|
2019-06-22 21:03:42 +01:00
|
|
|
mysqlLocal = cfg.database.createLocally && cfg.database.type == "mysql2";
|
|
|
|
pgsqlLocal = cfg.database.createLocally && cfg.database.type == "postgresql";
|
|
|
|
|
2018-08-19 21:29:44 +01:00
|
|
|
in
|
|
|
|
{
|
2020-08-25 16:27:30 +01:00
|
|
|
imports = [
|
|
|
|
(mkRemovedOptionModule [ "services" "redmine" "extraConfig" ] "Use services.redmine.settings instead.")
|
2020-08-25 16:55:06 +01:00
|
|
|
(mkRemovedOptionModule [ "services" "redmine" "database" "password" ] "Use services.redmine.database.passwordFile instead.")
|
2020-08-25 16:27:30 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
# interface
|
2014-10-07 09:53:01 +01:00
|
|
|
options = {
|
|
|
|
services.redmine = {
|
2022-08-28 20:18:44 +01:00
|
|
|
enable = mkEnableOption (lib.mdDoc "Redmine");
|
2014-10-07 09:53:01 +01:00
|
|
|
|
2018-10-11 02:04:08 +01:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
2019-10-22 02:09:56 +01:00
|
|
|
default = pkgs.redmine;
|
2021-10-03 17:06:03 +01:00
|
|
|
defaultText = literalExpression "pkgs.redmine";
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Which Redmine package to use.";
|
2021-10-03 17:06:03 +01:00
|
|
|
example = literalExpression "pkgs.redmine.override { ruby = pkgs.ruby_2_7; }";
|
2018-10-11 02:04:08 +01:00
|
|
|
};
|
|
|
|
|
2018-08-19 21:29:44 +01:00
|
|
|
user = mkOption {
|
2014-10-07 09:53:01 +01:00
|
|
|
type = types.str;
|
2018-08-19 21:29:44 +01:00
|
|
|
default = "redmine";
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "User under which Redmine is ran.";
|
2014-10-07 09:53:01 +01:00
|
|
|
};
|
|
|
|
|
2018-08-19 21:29:44 +01:00
|
|
|
group = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "redmine";
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Group under which Redmine is ran.";
|
2014-10-07 09:53:01 +01:00
|
|
|
};
|
|
|
|
|
2018-10-11 02:04:08 +01:00
|
|
|
port = mkOption {
|
2021-06-18 16:29:05 +01:00
|
|
|
type = types.port;
|
2018-10-11 02:04:08 +01:00
|
|
|
default = 3000;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Port on which Redmine is ran.";
|
2018-10-11 02:04:08 +01:00
|
|
|
};
|
|
|
|
|
2018-08-19 21:29:44 +01:00
|
|
|
stateDir = mkOption {
|
2014-10-07 09:53:01 +01:00
|
|
|
type = types.str;
|
2018-08-19 21:29:44 +01:00
|
|
|
default = "/var/lib/redmine";
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "The state directory, logs and plugins are stored here.";
|
2014-10-07 09:53:01 +01:00
|
|
|
};
|
|
|
|
|
2020-08-25 16:27:30 +01:00
|
|
|
settings = mkOption {
|
|
|
|
type = format.type;
|
|
|
|
default = {};
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc ''
|
|
|
|
Redmine configuration ({file}`configuration.yml`). Refer to
|
|
|
|
<https://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration>
|
2019-06-22 21:16:24 +01:00
|
|
|
for details.
|
2018-08-19 21:29:44 +01:00
|
|
|
'';
|
2021-10-03 17:06:03 +01:00
|
|
|
example = literalExpression ''
|
2020-08-25 16:27:30 +01:00
|
|
|
{
|
|
|
|
email_delivery = {
|
|
|
|
delivery_method = "smtp";
|
|
|
|
smtp_settings = {
|
|
|
|
address = "mail.example.com";
|
|
|
|
port = 25;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
2018-10-11 02:04:08 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2019-02-01 14:17:05 +00:00
|
|
|
extraEnv = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc ''
|
2019-02-01 14:17:05 +00:00
|
|
|
Extra configuration in additional_environment.rb.
|
|
|
|
|
2022-07-28 22:19:15 +01:00
|
|
|
See <https://svn.redmine.org/redmine/trunk/config/additional_environment.rb.example>
|
2019-06-22 21:16:24 +01:00
|
|
|
for details.
|
2019-02-01 14:17:05 +00:00
|
|
|
'';
|
2021-10-03 17:06:03 +01:00
|
|
|
example = ''
|
2019-02-01 14:17:05 +00:00
|
|
|
config.logger.level = Logger::DEBUG
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2018-10-11 02:04:08 +01:00
|
|
|
themes = mkOption {
|
|
|
|
type = types.attrsOf types.path;
|
|
|
|
default = {};
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Set of themes.";
|
2021-10-03 17:06:03 +01:00
|
|
|
example = literalExpression ''
|
2018-10-11 02:04:08 +01:00
|
|
|
{
|
|
|
|
dkuk-redmine_alex_skin = builtins.fetchurl {
|
2020-04-18 12:43:47 +01:00
|
|
|
url = "https://bitbucket.org/dkuk/redmine_alex_skin/get/1842ef675ef3.zip";
|
2018-10-11 02:04:08 +01:00
|
|
|
sha256 = "0hrin9lzyi50k4w2bd2b30vrf1i4fi1c0gyas5801wn8i7kpm9yl";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
plugins = mkOption {
|
|
|
|
type = types.attrsOf types.path;
|
|
|
|
default = {};
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Set of plugins.";
|
2021-10-03 17:06:03 +01:00
|
|
|
example = literalExpression ''
|
2018-10-11 02:04:08 +01:00
|
|
|
{
|
|
|
|
redmine_env_auth = builtins.fetchurl {
|
2020-04-18 12:43:47 +01:00
|
|
|
url = "https://github.com/Intera/redmine_env_auth/archive/0.6.zip";
|
2018-10-11 02:04:08 +01:00
|
|
|
sha256 = "0yyr1yjd8gvvh832wdc8m3xfnhhxzk2pk3gm2psg5w9jdvd6skak";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
'';
|
2014-10-07 09:53:01 +01:00
|
|
|
};
|
|
|
|
|
2018-08-19 21:29:44 +01:00
|
|
|
database = {
|
|
|
|
type = mkOption {
|
|
|
|
type = types.enum [ "mysql2" "postgresql" ];
|
|
|
|
example = "postgresql";
|
|
|
|
default = "mysql2";
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Database engine to use.";
|
2018-08-19 21:29:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
host = mkOption {
|
|
|
|
type = types.str;
|
2019-06-22 21:03:42 +01:00
|
|
|
default = "localhost";
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Database host address.";
|
2018-08-19 21:29:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
type = types.int;
|
2019-06-22 21:03:42 +01:00
|
|
|
default = if cfg.database.type == "postgresql" then 5432 else 3306;
|
2021-10-03 17:06:03 +01:00
|
|
|
defaultText = literalExpression "3306";
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Database host port.";
|
2018-08-19 21:29:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
name = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "redmine";
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Database name.";
|
2018-08-19 21:29:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "redmine";
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Database user.";
|
2018-08-19 21:29:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
passwordFile = mkOption {
|
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
|
|
|
example = "/run/keys/redmine-dbpassword";
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc ''
|
2018-08-19 21:29:44 +01:00
|
|
|
A file containing the password corresponding to
|
2022-07-28 22:19:15 +01:00
|
|
|
{option}`database.user`.
|
2018-08-19 21:29:44 +01:00
|
|
|
'';
|
|
|
|
};
|
2018-10-11 02:04:08 +01:00
|
|
|
|
|
|
|
socket = mkOption {
|
|
|
|
type = types.nullOr types.path;
|
2019-06-22 21:03:42 +01:00
|
|
|
default =
|
|
|
|
if mysqlLocal then "/run/mysqld/mysqld.sock"
|
|
|
|
else if pgsqlLocal then "/run/postgresql"
|
|
|
|
else null;
|
2021-10-03 17:06:03 +01:00
|
|
|
defaultText = literalExpression "/run/mysqld/mysqld.sock";
|
2018-10-11 02:04:08 +01:00
|
|
|
example = "/run/mysqld/mysqld.sock";
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Path to the unix socket file to use for authentication.";
|
2018-10-11 02:04:08 +01:00
|
|
|
};
|
2019-06-22 21:03:42 +01:00
|
|
|
|
|
|
|
createLocally = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Create the database and database user locally.";
|
2019-06-22 21:03:42 +01:00
|
|
|
};
|
2014-10-07 09:53:01 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-08-25 16:27:30 +01:00
|
|
|
# implementation
|
2014-10-07 09:53:01 +01:00
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
assertions = [
|
2020-08-25 16:55:06 +01:00
|
|
|
{ assertion = cfg.database.passwordFile != null || cfg.database.socket != null;
|
|
|
|
message = "one of services.redmine.database.socket or services.redmine.database.passwordFile must be set";
|
2018-10-11 02:04:08 +01:00
|
|
|
}
|
2019-06-22 21:03:42 +01:00
|
|
|
{ assertion = cfg.database.createLocally -> cfg.database.user == cfg.user;
|
|
|
|
message = "services.redmine.database.user must be set to ${cfg.user} if services.redmine.database.createLocally is set true";
|
|
|
|
}
|
|
|
|
{ assertion = cfg.database.createLocally -> cfg.database.socket != null;
|
|
|
|
message = "services.redmine.database.socket must be set if services.redmine.database.createLocally is set to true";
|
|
|
|
}
|
|
|
|
{ assertion = cfg.database.createLocally -> cfg.database.host == "localhost";
|
|
|
|
message = "services.redmine.database.host must be set to localhost if services.redmine.database.createLocally is set to true";
|
2014-10-07 09:53:01 +01:00
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2020-08-25 16:27:30 +01:00
|
|
|
services.redmine.settings = {
|
|
|
|
production = {
|
|
|
|
scm_subversion_command = "${pkgs.subversion}/bin/svn";
|
|
|
|
scm_mercurial_command = "${pkgs.mercurial}/bin/hg";
|
gitAndTools: move everything to the top level
The comment at the top of git-and-tools/default.nix said:
/* All git-relates tools live here, in a separate attribute set so that users
* can get a fast overview over what's available.
but unfortunately that hasn't actually held up in practice.
Git-related packages have continued to be added to the top level, or
into gitAndTools, or sometimes both, basically at random, so having
gitAndTools is just confusing. In fact, until I looked as part of
working on getting rid of gitAndTools, one program (ydiff) was
packaged twice independently, once in gitAndTools and once at the top
level (I fixed this in 98c34901969).
So I think it's for the best if we move away from gitAndTools, and
just put all the packages it previously contained at the top level.
I've implemented this here by just making gitAndTools an alias for the
top level -- this saves having loads of lines in aliases.nix. This
means that people can keep referring to gitAndTools in their
configuration, but it won't be allowed to be used within Nixpkgs, and
it won't be presented to new users by e.g. nix search.
The only other change here that I'm aware of is that
appendToName "minimal" is not longer called on the default git
package, because doing that would have necessitated having a private
gitBase variable like before. I think it makes more sense not to do
that anyway, and reserve the "minimal" suffix only for gitMinimal.
2021-01-14 17:49:32 +00:00
|
|
|
scm_git_command = "${pkgs.git}/bin/git";
|
2020-08-25 16:27:30 +01:00
|
|
|
scm_cvs_command = "${pkgs.cvs}/bin/cvs";
|
|
|
|
scm_bazaar_command = "${pkgs.breezy}/bin/bzr";
|
|
|
|
scm_darcs_command = "${pkgs.darcs}/bin/darcs";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-08-25 16:33:25 +01:00
|
|
|
services.redmine.extraEnv = mkBefore ''
|
|
|
|
config.logger = Logger.new("${cfg.stateDir}/log/production.log", 14, 1048576)
|
|
|
|
config.logger.level = Logger::INFO
|
|
|
|
'';
|
|
|
|
|
2019-06-22 21:03:42 +01:00
|
|
|
services.mysql = mkIf mysqlLocal {
|
|
|
|
enable = true;
|
|
|
|
package = mkDefault pkgs.mariadb;
|
|
|
|
ensureDatabases = [ cfg.database.name ];
|
|
|
|
ensureUsers = [
|
|
|
|
{ name = cfg.database.user;
|
|
|
|
ensurePermissions = { "${cfg.database.name}.*" = "ALL PRIVILEGES"; };
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
services.postgresql = mkIf pgsqlLocal {
|
|
|
|
enable = true;
|
|
|
|
ensureDatabases = [ cfg.database.name ];
|
|
|
|
ensureUsers = [
|
|
|
|
{ name = cfg.database.user;
|
|
|
|
ensurePermissions = { "DATABASE ${cfg.database.name}" = "ALL PRIVILEGES"; };
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2019-02-23 03:55:21 +00:00
|
|
|
# create symlinks for the basic directory layout the redmine package expects
|
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d '${cfg.stateDir}' 0750 ${cfg.user} ${cfg.group} - -"
|
|
|
|
"d '${cfg.stateDir}/cache' 0750 ${cfg.user} ${cfg.group} - -"
|
|
|
|
"d '${cfg.stateDir}/config' 0750 ${cfg.user} ${cfg.group} - -"
|
|
|
|
"d '${cfg.stateDir}/files' 0750 ${cfg.user} ${cfg.group} - -"
|
|
|
|
"d '${cfg.stateDir}/log' 0750 ${cfg.user} ${cfg.group} - -"
|
|
|
|
"d '${cfg.stateDir}/plugins' 0750 ${cfg.user} ${cfg.group} - -"
|
|
|
|
"d '${cfg.stateDir}/public' 0750 ${cfg.user} ${cfg.group} - -"
|
|
|
|
"d '${cfg.stateDir}/public/plugin_assets' 0750 ${cfg.user} ${cfg.group} - -"
|
|
|
|
"d '${cfg.stateDir}/public/themes' 0750 ${cfg.user} ${cfg.group} - -"
|
|
|
|
"d '${cfg.stateDir}/tmp' 0750 ${cfg.user} ${cfg.group} - -"
|
|
|
|
|
|
|
|
"d /run/redmine - - - - -"
|
|
|
|
"d /run/redmine/public - - - - -"
|
|
|
|
"L+ /run/redmine/config - - - - ${cfg.stateDir}/config"
|
|
|
|
"L+ /run/redmine/files - - - - ${cfg.stateDir}/files"
|
|
|
|
"L+ /run/redmine/log - - - - ${cfg.stateDir}/log"
|
|
|
|
"L+ /run/redmine/plugins - - - - ${cfg.stateDir}/plugins"
|
|
|
|
"L+ /run/redmine/public/plugin_assets - - - - ${cfg.stateDir}/public/plugin_assets"
|
|
|
|
"L+ /run/redmine/public/themes - - - - ${cfg.stateDir}/public/themes"
|
|
|
|
"L+ /run/redmine/tmp - - - - ${cfg.stateDir}/tmp"
|
|
|
|
];
|
|
|
|
|
2014-10-07 09:53:01 +01:00
|
|
|
systemd.services.redmine = {
|
2019-06-22 21:03:42 +01:00
|
|
|
after = [ "network.target" ] ++ optional mysqlLocal "mysql.service" ++ optional pgsqlLocal "postgresql.service";
|
2014-10-07 09:53:01 +01:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
environment.RAILS_ENV = "production";
|
|
|
|
environment.RAILS_CACHE = "${cfg.stateDir}/cache";
|
|
|
|
environment.REDMINE_LANG = "en";
|
2018-08-19 21:29:44 +01:00
|
|
|
environment.SCHEMA = "${cfg.stateDir}/cache/schema.db";
|
2014-10-07 09:53:01 +01:00
|
|
|
path = with pkgs; [
|
2019-03-08 22:47:11 +00:00
|
|
|
imagemagick
|
2020-04-19 09:48:42 +01:00
|
|
|
breezy
|
2018-08-19 21:29:44 +01:00
|
|
|
cvs
|
2018-08-19 13:09:38 +01:00
|
|
|
darcs
|
gitAndTools: move everything to the top level
The comment at the top of git-and-tools/default.nix said:
/* All git-relates tools live here, in a separate attribute set so that users
* can get a fast overview over what's available.
but unfortunately that hasn't actually held up in practice.
Git-related packages have continued to be added to the top level, or
into gitAndTools, or sometimes both, basically at random, so having
gitAndTools is just confusing. In fact, until I looked as part of
working on getting rid of gitAndTools, one program (ydiff) was
packaged twice independently, once in gitAndTools and once at the top
level (I fixed this in 98c34901969).
So I think it's for the best if we move away from gitAndTools, and
just put all the packages it previously contained at the top level.
I've implemented this here by just making gitAndTools an alias for the
top level -- this saves having loads of lines in aliases.nix. This
means that people can keep referring to gitAndTools in their
configuration, but it won't be allowed to be used within Nixpkgs, and
it won't be presented to new users by e.g. nix search.
The only other change here that I'm aware of is that
appendToName "minimal" is not longer called on the default git
package, because doing that would have necessitated having a private
gitBase variable like before. I think it makes more sense not to do
that anyway, and reserve the "minimal" suffix only for gitMinimal.
2021-01-14 17:49:32 +00:00
|
|
|
git
|
2018-08-19 21:29:44 +01:00
|
|
|
mercurial
|
|
|
|
subversion
|
2014-10-07 09:53:01 +01:00
|
|
|
];
|
|
|
|
preStart = ''
|
2019-02-23 03:55:21 +00:00
|
|
|
rm -rf "${cfg.stateDir}/plugins/"*
|
|
|
|
rm -rf "${cfg.stateDir}/public/themes/"*
|
2018-10-11 02:04:08 +01:00
|
|
|
|
|
|
|
# start with a fresh config directory
|
|
|
|
# the config directory is copied instead of linked as some mutable data is stored in there
|
2019-02-23 03:55:21 +00:00
|
|
|
find "${cfg.stateDir}/config" ! -name "secret_token.rb" -type f -exec rm -f {} +
|
2018-10-11 13:04:47 +01:00
|
|
|
cp -r ${cfg.package}/share/redmine/config.dist/* "${cfg.stateDir}/config/"
|
2018-08-19 21:29:44 +01:00
|
|
|
|
2019-02-23 03:55:21 +00:00
|
|
|
chmod -R u+w "${cfg.stateDir}/config"
|
|
|
|
|
2018-08-19 21:29:44 +01:00
|
|
|
# link in the application configuration
|
2018-10-11 13:04:47 +01:00
|
|
|
ln -fs ${configurationYml} "${cfg.stateDir}/config/configuration.yml"
|
2018-08-19 13:09:38 +01:00
|
|
|
|
2019-02-01 14:17:05 +00:00
|
|
|
# link in the additional environment configuration
|
|
|
|
ln -fs ${additionalEnvironment} "${cfg.stateDir}/config/additional_environment.rb"
|
|
|
|
|
2018-10-11 02:04:08 +01:00
|
|
|
|
|
|
|
# link in all user specified themes
|
|
|
|
for theme in ${concatStringsSep " " (mapAttrsToList unpackTheme cfg.themes)}; do
|
2018-10-11 13:04:47 +01:00
|
|
|
ln -fs $theme/* "${cfg.stateDir}/public/themes"
|
2018-10-11 02:04:08 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
# link in redmine provided themes
|
2018-10-11 13:04:47 +01:00
|
|
|
ln -sf ${cfg.package}/share/redmine/public/themes.dist/* "${cfg.stateDir}/public/themes/"
|
2018-10-11 02:04:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
# link in all user specified plugins
|
|
|
|
for plugin in ${concatStringsSep " " (mapAttrsToList unpackPlugin cfg.plugins)}; do
|
2018-10-11 13:04:47 +01:00
|
|
|
ln -fs $plugin/* "${cfg.stateDir}/plugins/''${plugin##*-redmine-plugin-}"
|
2018-10-11 02:04:08 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
# handle database.passwordFile & permissions
|
2020-08-25 16:55:06 +01:00
|
|
|
DBPASS=${optionalString (cfg.database.passwordFile != null) "$(head -n1 ${cfg.database.passwordFile})"}
|
2018-10-11 13:04:47 +01:00
|
|
|
cp -f ${databaseYml} "${cfg.stateDir}/config/database.yml"
|
|
|
|
sed -e "s,#dbpass#,$DBPASS,g" -i "${cfg.stateDir}/config/database.yml"
|
|
|
|
chmod 440 "${cfg.stateDir}/config/database.yml"
|
2018-08-19 21:29:44 +01:00
|
|
|
|
2018-10-11 02:04:08 +01:00
|
|
|
|
2018-08-19 21:29:44 +01:00
|
|
|
# generate a secret token if required
|
|
|
|
if ! test -e "${cfg.stateDir}/config/initializers/secret_token.rb"; then
|
|
|
|
${bundle} exec rake generate_secret_token
|
2018-10-11 13:04:47 +01:00
|
|
|
chmod 440 "${cfg.stateDir}/config/initializers/secret_token.rb"
|
2018-08-19 21:29:44 +01:00
|
|
|
fi
|
|
|
|
|
2018-10-11 02:04:08 +01:00
|
|
|
# execute redmine required commands prior to starting the application
|
2019-02-23 03:55:21 +00:00
|
|
|
${bundle} exec rake db:migrate
|
|
|
|
${bundle} exec rake redmine:plugins:migrate
|
|
|
|
${bundle} exec rake redmine:load_default_data
|
2014-10-07 09:53:01 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "simple";
|
2018-08-19 21:29:44 +01:00
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
2014-10-07 09:53:01 +01:00
|
|
|
TimeoutSec = "300";
|
2018-10-11 02:04:08 +01:00
|
|
|
WorkingDirectory = "${cfg.package}/share/redmine";
|
2018-10-11 13:04:47 +01:00
|
|
|
ExecStart="${bundle} exec rails server webrick -e production -p ${toString cfg.port} -P '${cfg.stateDir}/redmine.pid'";
|
2014-10-07 09:53:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-09-14 18:51:29 +01:00
|
|
|
users.users = optionalAttrs (cfg.user == "redmine") {
|
|
|
|
redmine = {
|
2018-08-19 21:29:44 +01:00
|
|
|
group = cfg.group;
|
|
|
|
home = cfg.stateDir;
|
|
|
|
uid = config.ids.uids.redmine;
|
2019-09-14 18:51:29 +01:00
|
|
|
};
|
|
|
|
};
|
2018-08-19 21:29:44 +01:00
|
|
|
|
2019-09-14 18:51:29 +01:00
|
|
|
users.groups = optionalAttrs (cfg.group == "redmine") {
|
|
|
|
redmine.gid = config.ids.gids.redmine;
|
|
|
|
};
|
2018-08-19 21:29:44 +01:00
|
|
|
|
2014-10-07 09:53:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|