nixos/services.activemq: remove with lib;
This commit is contained in:
parent
5a670b332a
commit
82146f6a71
@ -1,18 +1,14 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with pkgs;
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.services.activemq;
|
||||
|
||||
activemqBroker = runCommand "activemq-broker"
|
||||
activemqBroker = pkgs.runCommand "activemq-broker"
|
||||
{
|
||||
nativeBuildInputs = [ jdk ];
|
||||
nativeBuildInputs = [ pkgs.jdk ];
|
||||
} ''
|
||||
mkdir -p $out/lib
|
||||
source ${activemq}/lib/classpath.env
|
||||
source ${pkgs.activemq}/lib/classpath.env
|
||||
export CLASSPATH
|
||||
ln -s "${./ActiveMQBroker.java}" ActiveMQBroker.java
|
||||
javac -d $out/lib ActiveMQBroker.java
|
||||
@ -23,25 +19,25 @@ in
|
||||
|
||||
options = {
|
||||
services.activemq = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Enable the Apache ActiveMQ message broker service.
|
||||
'';
|
||||
};
|
||||
configurationDir = mkOption {
|
||||
default = "${activemq}/conf";
|
||||
defaultText = literalExpression ''"''${pkgs.activemq}/conf"'';
|
||||
type = types.str;
|
||||
configurationDir = lib.mkOption {
|
||||
default = "${pkgs.activemq}/conf";
|
||||
defaultText = lib.literalExpression ''"''${pkgs.activemq}/conf"'';
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
The base directory for ActiveMQ's configuration.
|
||||
By default, this directory is searched for a file named activemq.xml,
|
||||
which should contain the configuration for the broker service.
|
||||
'';
|
||||
};
|
||||
configurationURI = mkOption {
|
||||
type = types.str;
|
||||
configurationURI = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "xbean:activemq.xml";
|
||||
description = ''
|
||||
The URI that is passed along to the BrokerFactory to
|
||||
@ -51,8 +47,8 @@ in
|
||||
an activemq.xml configuration file in it.
|
||||
'';
|
||||
};
|
||||
baseDir = mkOption {
|
||||
type = types.str;
|
||||
baseDir = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "/var/activemq";
|
||||
description = ''
|
||||
The base directory where ActiveMQ stores its persistent data and logs.
|
||||
@ -61,10 +57,10 @@ in
|
||||
this in activemq.xml.
|
||||
'';
|
||||
};
|
||||
javaProperties = mkOption {
|
||||
type = types.attrs;
|
||||
javaProperties = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
default = { };
|
||||
example = literalExpression ''
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
"java.net.preferIPv4Stack" = "true";
|
||||
}
|
||||
@ -73,7 +69,7 @@ in
|
||||
"activemq.base" = "${cfg.baseDir}";
|
||||
"activemq.data" = "${cfg.baseDir}/data";
|
||||
"activemq.conf" = "${cfg.configurationDir}";
|
||||
"activemq.home" = "${activemq}";
|
||||
"activemq.home" = "${pkgs.activemq}";
|
||||
} // attrs;
|
||||
description = ''
|
||||
Specifies Java properties that are sent to the ActiveMQ
|
||||
@ -83,8 +79,8 @@ in
|
||||
given reasonable defaults.
|
||||
'';
|
||||
};
|
||||
extraJavaOptions = mkOption {
|
||||
type = types.separatedString " ";
|
||||
extraJavaOptions = lib.mkOption {
|
||||
type = lib.types.separatedString " ";
|
||||
default = "";
|
||||
example = "-Xmx2G -Xms2G -XX:MaxPermSize=512M";
|
||||
description = ''
|
||||
@ -95,7 +91,7 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
config = lib.mkIf cfg.enable {
|
||||
users.users.activemq = {
|
||||
description = "ActiveMQ server user";
|
||||
group = "activemq";
|
||||
@ -118,13 +114,13 @@ in
|
||||
systemd.services.activemq = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
path = [ jre ];
|
||||
path = [ pkgs.jre ];
|
||||
serviceConfig.User = "activemq";
|
||||
script = ''
|
||||
source ${activemq}/lib/classpath.env
|
||||
source ${pkgs.activemq}/lib/classpath.env
|
||||
export CLASSPATH=${activemqBroker}/lib:${cfg.configurationDir}:$CLASSPATH
|
||||
exec java \
|
||||
${concatStringsSep " \\\n" (mapAttrsToList (name: value: "-D${name}=${value}") cfg.javaProperties)} \
|
||||
${lib.concatStringsSep " \\\n" (lib.mapAttrsToList (name: value: "-D${name}=${value}") cfg.javaProperties)} \
|
||||
${cfg.extraJavaOptions} ActiveMQBroker "${cfg.configurationURI}"
|
||||
'';
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user