Fixed the avahi service and do some better formatting of the key=value pairs

svn path=/nixos/trunk/; revision=25060
This commit is contained in:
Sander van der Burg 2010-12-10 23:58:57 +00:00
parent b3c4444c26
commit 281f3b0776

View File

@ -87,8 +87,8 @@ 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;
}
// optionalAttrs (config.nixpkgs.system != "") { system = config.nixpkgs.system; }
// 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; }
@ -98,6 +98,8 @@ in
)
;
services.disnix.publishInfrastructure.enable = cfg.publishAvahi;
jobs = {
disnix =
{ description = "Disnix server";
@ -120,16 +122,19 @@ in
exec =
''
${pkgs.avahi}/bin/avahi-publish-service disnix-$(${pkgs.nettools}/bin/hostname) _disnix._tcp 22 \
"hostname=\"$(${pkgs.nettools}/bin/hostname)\"" \
"system=\"$(uname -m)-linux\"" \
${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')" \
${optionalString (cfg.useWebServiceInterface) ''"targetEPR=\"http://(${pkgs.nettools}/bin/hostname):8080/DisnixWebService/services/DisnixWebService\""''} \
${optionalString (config.services.httpd.enable) ''"documentRoot=\"${config.services.httpd.documentRoot}\""''} \
${optionalString (config.services.mysql.enable) ''"mysqlPort=3306"''} \
${optionalString (config.services.tomcat.enable) ''"tomcatPort=8080"''} \
"supportedTypes=[$(for i in ${disnix_activation_scripts}/libexec/disnix/activation-scripts/*; do echo -n " \"$(basename $i)\""; done) ]" \
${concatMapStrings (deploymentAttrName: let deploymentAttrValue = getAttr deploymentAttrName (config.deployment); in ''${deploymentAttrName}=\"${deploymentAttrValue}\" '' ) (attrNames (config.deployment))}
${concatMapStrings (infrastructureAttrName:
let infrastructureAttrValue = getAttr infrastructureAttrName (cfg.infrastructure);
in
if builtins.isInt infrastructureAttrValue then
''${infrastructureAttrName}=${infrastructureAttrValue} \
''
else
''${infrastructureAttrName}=\"${infrastructureAttrValue}\" \
''
) (attrNames (cfg.infrastructure))}
'';
};
};