@ -34,6 +34,23 @@ in
description = " W h e t h e r t o e n a b l e t h e D i s n i x W e b S e r v i c e i n t e r f a c e r u n n i n g o n A p a c h e T o m c a t " ;
} ;
publishInfrastructure = {
enable = mkOption {
default = false ;
description = " W h e t h e r t o p u b l i s h c a p a b i l i t i e s / p r o p e r t i e s o f t h i s m a c h i n e i n a s a t t r i b u t e s i n t h e i n f r a s t r u c t u r e o p t i o n " ;
} ;
enableAuthentication = mkOption {
default = false ;
description = " W h e t h e r t o p u b l i s h a u t h e n t i c a t i o n c r e d e n t i a l s t h r o u g h t h e i n f r a s t r u c t u r e a t t r i b u t e ( n o t r e c o m m e n d e d i n c o m b i n a t i o n w i t h A v a h i ) " ;
} ;
} ;
infrastructure = mkOption {
default = { } ;
description = " L i s t o f n a m e v a l u e p a i r s c o n t a i n i n g p r o p e r t i e s f o r t h e i n f r a s t r u c t u r e m o d e l " ;
} ;
publishAvahi = mkOption {
default = false ;
description = " W h e t h e r t o p u b l i s h c a p a b i l i t i e s / p r o p e r t i e s a s a D i s n i x s e r v i c e t h r o u g h A v a h i " ;
@ -47,62 +64,74 @@ in
###### implementation
config = mkIf cfg . enable {
environment . systemPackages = [ pkgs . disnix ] ++ optional cfg . useWebServiceInterface pkgs . DisnixWebService ;
services . dbus . enable = true ;
services . dbus . packages = [ pkgs . disnix ] ;
services . avahi . enable = cfg . publishAvahi ;
services . tomcat . enable = cfg . useWebServiceInterface ;
services . tomcat . extraGroups = [ " d i s n i x " ] ;
services . tomcat . javaOpts = " ${ optionalString cfg . useWebServiceInterface " - D j a v a . l i b r a r y . p a t h = ${ pkgs . libmatthew_java } / l i b / j n i " } " ;
services . tomcat . sharedLibs = [ ]
++ optional cfg . useWebServiceInterface " ${ pkgs . DisnixWebService } / s h a r e / j a v a / D i s n i x C o n n e c t i o n . j a r "
services . tomcat . sharedLibs = optional cfg . useWebServiceInterface " ${ pkgs . DisnixWebService } / s h a r e / j a v a / D i s n i x C o n n e c t i o n . j a r "
++ optional cfg . useWebServiceInterface " ${ pkgs . dbus_java } / s h a r e / j a v a / d b u s . j a r " ;
services . tomcat . webapps = [ ] ++ optional cfg . useWebServiceInterface pkgs . DisnixWebService ;
services . tomcat . webapps = optional cfg . useWebServiceInterface pkgs . DisnixWebService ;
users . extraGroups = singleton
{ name = " d i s n i x " ;
gid = config . ids . gids . disnix ;
} ;
jobs . disnix =
{ description = " D i s n i x s e r v e r " ;
services . disnix . infrastructure =
optionalAttrs ( cfg . publishInfrastructure . enable )
( { hostname = config . networking . hostName ;
targetHost = config . deployment . targetHost ;
}
// optionalAttrs ( config . nixpkgs . system != " " ) { system = config . nixpkgs . system ; }
// optionalAttrs ( cfg . useWebServiceInterface ) { targetEPR = " h t t p : / / ${ config . deployment . targetHost } : 8 0 8 0 / D i s n i x W e b S e r v i c e / s e r v i c e s / D i s n i x W e b S e r v i c e " ; }
// 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 = " r o o t " ; mysqlPassword = builtins . readFile config . services . mysql . rootPassword ; } )
)
;
jobs = {
disnix =
{ description = " D i s n i x s e r v e r " ;
startOn = " s t a r t e d d b u s " ;
startOn = " s t a r t e d d b u s " ;
script =
script =
''
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
'' ;
} ;
} //
mkIf cfg . publishAvahi {
services . avahi . enable = true ;
jobs . disnixAvahi =
{ description = " D i s n i x A v a h i p u b l i s h e r " ;
} ;
} // optionalAttrs cfg . publishAvahi {
disnixAvahi =
{ description = " D i s n i x A v a h i p u b l i s h e r " ;
startOn = " s t a r t e d a v a h i - d a e m o n " ;
startOn = " s t a r t e d a v a h i - d a e m o n " ;
exec =
''
$ { pkgs . avahi } /bin/avahi-publish-service disnix- $ ( $ { pkgs . nettools } /bin/hostname ) _disnix . _tcp 22 \
" h o s t n a m e = \" $ ( ${ pkgs . nettools } / b i n / h o s t n a m e ) \" " \
" s y s t e m = \" $ ( u n a m e - m ) - l i n u x \" " \
" m e m = $ ( g r e p ' M e m T o t a l : ' / p r o c / m e m i n f o | s e d - e ' s / k B / / ' - e ' s / M e m T o t a l : / / ' - e ' s / / / g ' ) " \
$ { optionalString ( cfg . useWebServiceInterface ) '' " t a r g e t E P R = \ " h t t p : / / ( ${ pkgs . nettools } / b i n / h o s t n a m e ) : 8 0 8 0 / D i s n i x W e b S e r v i c e / s e r v i c e s / D i s n i x W e b S e r v i c e \ " " '' } \
$ { optionalString ( config . services . httpd . enable ) '' " d o c u m e n t R o o t = \ " ${ config . services . httpd . documentRoot } \ " " '' } \
$ { optionalString ( config . services . mysql . enable ) '' " m y s q l P o r t = 3 3 0 6 " '' } \
$ { optionalString ( config . services . tomcat . enable ) '' " t o m c a t P o r t = 8 0 8 0 " '' } \
" s u p p o r t e d T y p e s = [ $ ( f o r i i n ${ disnix_activation_scripts } / l i b e x e c / d i s n i x / a c t i v a t i o n - s c r i p t s / * ; d o e c h o - n " \ " $ ( b a s e n a m e $ i ) \" " ; done ) ] " \
$ { concatMapStrings ( deploymentAttrName : let deploymentAttrValue = getAttr deploymentAttrName ( config . deployment ) ; in '' ${ deploymentAttrName } = \ " ${ deploymentAttrValue } \ " '' ) ( attrNames ( config . deployment ) ) }
'' ;
} ;
exec =
''
$ { pkgs . avahi } /bin/avahi-publish-service disnix- $ ( $ { pkgs . nettools } /bin/hostname ) _disnix . _tcp 22 \
" h o s t n a m e = \" $ ( ${ pkgs . nettools } / b i n / h o s t n a m e ) \" " \
" s y s t e m = \" $ ( u n a m e - m ) - l i n u x \" " \
" m e m = $ ( g r e p ' M e m T o t a l : ' / p r o c / m e m i n f o | s e d - e ' s / k B / / ' - e ' s / M e m T o t a l : / / ' - e ' s / / / g ' ) " \
$ { optionalString ( cfg . useWebServiceInterface ) '' " t a r g e t E P R = \ " h t t p : / / ( ${ pkgs . nettools } / b i n / h o s t n a m e ) : 8 0 8 0 / D i s n i x W e b S e r v i c e / s e r v i c e s / D i s n i x W e b S e r v i c e \ " " '' } \
$ { optionalString ( config . services . httpd . enable ) '' " d o c u m e n t R o o t = \ " ${ config . services . httpd . documentRoot } \ " " '' } \
$ { optionalString ( config . services . mysql . enable ) '' " m y s q l P o r t = 3 3 0 6 " '' } \
$ { optionalString ( config . services . tomcat . enable ) '' " t o m c a t P o r t = 8 0 8 0 " '' } \
" s u p p o r t e d T y p e s = [ $ ( f o r i i n ${ disnix_activation_scripts } / l i b e x e c / d i s n i x / a c t i v a t i o n - s c r i p t s / * ; d o e c h o - n " \ " $ ( b a s e n a m e $ i ) \" " ; done ) ] " \
$ { concatMapStrings ( deploymentAttrName : let deploymentAttrValue = getAttr deploymentAttrName ( config . deployment ) ; in '' ${ deploymentAttrName } = \ " ${ deploymentAttrValue } \ " '' ) ( attrNames ( config . deployment ) ) }
'' ;
} ;
} ;
} ;
}