Implemented a very very dirty hack, which makes it possible to statically determine which activation types are supported, instead of determining this by the avahi service

svn path=/nixos/trunk/; revision=32089
wip/yesman
Sander van der Burg 13 years ago
parent 89d5aa4dd2
commit 3a9dfceb07
  1. 72
      modules/services/misc/disnix.nix

@ -33,29 +33,29 @@ in
useWebServiceInterface = mkOption {
default = false;
description = "Whether to enable the DisnixWebService interface running on Apache Tomcat";
description = "Whether to enable the DisnixWebService interface running on Apache Tomcat";
};
publishInfrastructure = {
enable = mkOption {
default = false;
description = "Whether to publish capabilities/properties of this machine in as attributes in the infrastructure option";
};
description = "Whether to publish capabilities/properties of this machine in as attributes in the infrastructure option";
};
enableAuthentication = mkOption {
default = false;
description = "Whether to publish authentication credentials through the infrastructure attribute (not recommended in combination with Avahi)";
};
enableAuthentication = mkOption {
default = false;
description = "Whether to publish authentication credentials through the infrastructure attribute (not recommended in combination with Avahi)";
};
};
infrastructure = mkOption {
default = {};
description = "List of name value pairs containing properties for the infrastructure model";
description = "List of name value pairs containing properties for the infrastructure model";
};
publishAvahi = mkOption {
default = false;
description = "Whether to publish capabilities/properties as a Disnix service through Avahi";
description = "Whether to publish capabilities/properties as a Disnix service through Avahi";
};
};
@ -77,7 +77,7 @@ in
services.tomcat.extraGroups = [ "disnix" ];
services.tomcat.javaOpts = "${optionalString cfg.useWebServiceInterface "-Djava.library.path=${pkgs.libmatthew_java}/lib/jni"} ";
services.tomcat.sharedLibs = optional cfg.useWebServiceInterface "${pkgs.DisnixWebService}/share/java/DisnixConnection.jar"
++ optional cfg.useWebServiceInterface "${pkgs.dbus_java}/share/java/dbus.jar";
++ optional cfg.useWebServiceInterface "${pkgs.dbus_java}/share/java/dbus.jar";
services.tomcat.webapps = optional cfg.useWebServiceInterface pkgs.DisnixWebService;
users.extraGroups = singleton
@ -89,16 +89,29 @@ in
optionalAttrs (cfg.publishInfrastructure.enable)
( { hostname = config.networking.hostName;
targetHost = config.deployment.targetHost;
system = if config.nixpkgs.system == "" then builtins.currentSystem else config.nixpkgs.system;
system = if config.nixpkgs.system == "" then builtins.currentSystem else config.nixpkgs.system;
supportedTypes = (import "${pkgs.stdenv.mkDerivation {
name = "supportedtypes";
buildCommand = ''
( echo -n "[ "
cd ${disnix_activation_scripts}/libexec/disnix/activation-scripts
for i in *
do
echo -n "\"$i\" "
done
echo -n " ]") > $out
'';
}}");
}
// optionalAttrs (cfg.useWebServiceInterface) { targetEPR = "http://${config.deployment.targetHost}:8080/DisnixWebService/services/DisnixWebService"; }
// optionalAttrs (config.services.httpd.enable) { documentRoot = config.services.httpd.documentRoot; }
// optionalAttrs (config.services.mysql.enable) { mysqlPort = config.services.mysql.port; }
// optionalAttrs (config.services.tomcat.enable) { tomcatPort = 8080; }
// optionalAttrs (config.services.svnserve.enable) { svnBaseDir = config.services.svnserve.svnBaseDir; }
// optionalAttrs (cfg.publishInfrastructure.enableAuthentication) (
// optionalAttrs (config.services.svnserve.enable) { svnBaseDir = config.services.svnserve.svnBaseDir; }
// optionalAttrs (cfg.publishInfrastructure.enableAuthentication) (
optionalAttrs (config.services.mysql.enable) { mysqlUsername = "root"; mysqlPassword = builtins.readFile config.services.mysql.rootPassword; })
)
)
;
services.disnix.publishInfrastructure.enable = cfg.publishAvahi;
@ -108,14 +121,14 @@ in
{ description = "Disnix server";
startOn = "started dbus"
+ optionalString config.services.httpd.enable " and started httpd"
+ optionalString config.services.mysql.enable " and started mysql"
+ optionalString config.services.tomcat.enable " and started tomcat"
+ optionalString config.services.svnserve.enable " and started svnserve";
+ optionalString config.services.httpd.enable " and started httpd"
+ optionalString config.services.mysql.enable " and started mysql"
+ optionalString config.services.tomcat.enable " and started tomcat"
+ optionalString config.services.svnserve.enable " and started svnserve";
script =
''
export PATH=/var/run/current-system/sw/bin:/var/run/current-system/sw/sbin
export PATH=/var/run/current-system/sw/bin:/var/run/current-system/sw/sbin
export HOME=/root
${pkgs.disnix}/bin/disnix-service --activation-modules-dir=${disnix_activation_scripts}/libexec/disnix/activation-scripts
@ -127,21 +140,20 @@ in
startOn = "started avahi-daemon";
exec =
exec =
''
${pkgs.avahi}/bin/avahi-publish-service disnix-${config.networking.hostName} _disnix._tcp 22 \
"mem=$(grep 'MemTotal:' /proc/meminfo | sed -e 's/kB//' -e 's/MemTotal://' -e 's/ //g')" \
"supportedTypes=[$(for i in ${disnix_activation_scripts}/libexec/disnix/activation-scripts/*; do echo -n " \"$(basename $i)\""; done) ]" \
${concatMapStrings (infrastructureAttrName:
let infrastructureAttrValue = getAttr infrastructureAttrName (cfg.infrastructure);
in
if builtins.isInt infrastructureAttrValue then
''${infrastructureAttrName}=${toString infrastructureAttrValue} \
''
else
"mem=$(grep 'MemTotal:' /proc/meminfo | sed -e 's/kB//' -e 's/MemTotal://' -e 's/ //g')" \
${concatMapStrings (infrastructureAttrName:
let infrastructureAttrValue = getAttr infrastructureAttrName (cfg.infrastructure);
in
if builtins.isInt infrastructureAttrValue then
''${infrastructureAttrName}=${toString infrastructureAttrValue} \
''
else
''${infrastructureAttrName}=\"${infrastructureAttrValue}\" \
''
) (attrNames (cfg.infrastructure))}
) (attrNames (cfg.infrastructure))}
'';
};
};

Loading…
Cancel
Save