- deployment.targetHost is now defined as an option
- developed services.disnix.infrastructure option, which contains properties for the Disnix infrastructure model (these properties can be either used by Disnix itself or the Avahi publisher) svn path=/nixos/trunk/; revision=25052
This commit is contained in:
parent
05c25d3fb2
commit
e51fcac73c
@ -5,18 +5,12 @@ with pkgs.lib;
|
|||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
|
|
||||||
deployment = mkOption {
|
deployment = {
|
||||||
description = ''
|
targetHost = mkOption {
|
||||||
This option captures various custom attributes related to the configuration of the system, which
|
description = ''
|
||||||
are not directly used for building a system configuration. Usually these attributes
|
This option specifies a hostname or IP address which can be used by nixos-deploy-network
|
||||||
are used by external tooling, such as the nixos-deploy-network tool or the Disnix Avahi
|
to execute remote deployment operations.
|
||||||
publisher.
|
'';
|
||||||
'';
|
|
||||||
default = {};
|
|
||||||
example = {
|
|
||||||
description = "My production machine";
|
|
||||||
hostname = "my.test.org";
|
|
||||||
country = "NL";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -34,6 +34,23 @@ in
|
|||||||
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";
|
||||||
|
};
|
||||||
|
|
||||||
|
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";
|
||||||
|
};
|
||||||
|
|
||||||
publishAvahi = mkOption {
|
publishAvahi = mkOption {
|
||||||
default = false;
|
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";
|
||||||
@ -47,62 +64,74 @@ in
|
|||||||
###### implementation
|
###### implementation
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
|
||||||
environment.systemPackages = [ pkgs.disnix ] ++ optional cfg.useWebServiceInterface pkgs.DisnixWebService;
|
environment.systemPackages = [ pkgs.disnix ] ++ optional cfg.useWebServiceInterface pkgs.DisnixWebService;
|
||||||
|
|
||||||
services.dbus.enable = true;
|
services.dbus.enable = true;
|
||||||
services.dbus.packages = [ pkgs.disnix ];
|
services.dbus.packages = [ pkgs.disnix ];
|
||||||
|
|
||||||
|
services.avahi.enable = cfg.publishAvahi;
|
||||||
|
|
||||||
services.tomcat.enable = cfg.useWebServiceInterface;
|
services.tomcat.enable = cfg.useWebServiceInterface;
|
||||||
services.tomcat.extraGroups = [ "disnix" ];
|
services.tomcat.extraGroups = [ "disnix" ];
|
||||||
services.tomcat.javaOpts = "${optionalString cfg.useWebServiceInterface "-Djava.library.path=${pkgs.libmatthew_java}/lib/jni"} ";
|
services.tomcat.javaOpts = "${optionalString cfg.useWebServiceInterface "-Djava.library.path=${pkgs.libmatthew_java}/lib/jni"} ";
|
||||||
services.tomcat.sharedLibs = []
|
services.tomcat.sharedLibs = optional cfg.useWebServiceInterface "${pkgs.DisnixWebService}/share/java/DisnixConnection.jar"
|
||||||
++ 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;
|
services.tomcat.webapps = optional cfg.useWebServiceInterface pkgs.DisnixWebService;
|
||||||
|
|
||||||
users.extraGroups = singleton
|
users.extraGroups = singleton
|
||||||
{ name = "disnix";
|
{ name = "disnix";
|
||||||
gid = config.ids.gids.disnix;
|
gid = config.ids.gids.disnix;
|
||||||
};
|
};
|
||||||
|
|
||||||
jobs.disnix =
|
services.disnix.infrastructure =
|
||||||
{ description = "Disnix server";
|
optionalAttrs (cfg.publishInfrastructure.enable)
|
||||||
|
( { hostname = config.networking.hostName;
|
||||||
|
targetHost = config.deployment.targetHost;
|
||||||
|
}
|
||||||
|
// 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; }
|
||||||
|
// optionalAttrs (config.services.tomcat.enable) { tomcatPort = 8080; }
|
||||||
|
// optionalAttrs (cfg.publishInfrastructure.enableAuthentication) (
|
||||||
|
optionalAttrs (config.services.mysql.enable) { mysqlUsername = "root"; mysqlPassword = builtins.readFile config.services.mysql.rootPassword; })
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
jobs = {
|
||||||
|
disnix =
|
||||||
|
{ description = "Disnix server";
|
||||||
|
|
||||||
startOn = "started dbus";
|
startOn = "started dbus";
|
||||||
|
|
||||||
script =
|
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
|
export HOME=/root
|
||||||
|
|
||||||
${pkgs.disnix}/bin/disnix-service --activation-modules-dir=${disnix_activation_scripts}/libexec/disnix/activation-scripts
|
${pkgs.disnix}/bin/disnix-service --activation-modules-dir=${disnix_activation_scripts}/libexec/disnix/activation-scripts
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
} // optionalAttrs cfg.publishAvahi {
|
||||||
} //
|
disnixAvahi =
|
||||||
mkIf cfg.publishAvahi {
|
{ description = "Disnix Avahi publisher";
|
||||||
|
|
||||||
services.avahi.enable = true;
|
|
||||||
|
|
||||||
jobs.disnixAvahi =
|
|
||||||
{ description = "Disnix Avahi publisher";
|
|
||||||
|
|
||||||
startOn = "started avahi-daemon";
|
startOn = "started avahi-daemon";
|
||||||
|
|
||||||
exec =
|
exec =
|
||||||
''
|
''
|
||||||
${pkgs.avahi}/bin/avahi-publish-service disnix-$(${pkgs.nettools}/bin/hostname) _disnix._tcp 22 \
|
${pkgs.avahi}/bin/avahi-publish-service disnix-$(${pkgs.nettools}/bin/hostname) _disnix._tcp 22 \
|
||||||
"hostname=\"$(${pkgs.nettools}/bin/hostname)\"" \
|
"hostname=\"$(${pkgs.nettools}/bin/hostname)\"" \
|
||||||
"system=\"$(uname -m)-linux\"" \
|
"system=\"$(uname -m)-linux\"" \
|
||||||
"mem=$(grep 'MemTotal:' /proc/meminfo | sed -e 's/kB//' -e 's/MemTotal://' -e 's/ //g')" \
|
"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 (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.httpd.enable) ''"documentRoot=\"${config.services.httpd.documentRoot}\""''} \
|
||||||
${optionalString (config.services.mysql.enable) ''"mysqlPort=3306"''} \
|
${optionalString (config.services.mysql.enable) ''"mysqlPort=3306"''} \
|
||||||
${optionalString (config.services.tomcat.enable) ''"tomcatPort=8080"''} \
|
${optionalString (config.services.tomcat.enable) ''"tomcatPort=8080"''} \
|
||||||
"supportedTypes=[$(for i in ${disnix_activation_scripts}/libexec/disnix/activation-scripts/*; do echo -n " \"$(basename $i)\""; done) ]" \
|
"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 (deploymentAttrName: let deploymentAttrValue = getAttr deploymentAttrName (config.deployment); in ''${deploymentAttrName}=\"${deploymentAttrValue}\" '' ) (attrNames (config.deployment))}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user