2 { config, lib, pkgs, ... }:
8 cfg = config.services.disnix;
20 enable = mkEnableOption (lib.mdDoc "Disnix");
22 enableMultiUser = mkOption {
25 description = lib.mdDoc "Whether to support multi-user mode by enabling the Disnix D-Bus service";
28 useWebServiceInterface = mkEnableOption (lib.mdDoc "the DisnixWebService interface running on Apache Tomcat");
32 description = lib.mdDoc "The Disnix package";
33 default = pkgs.disnix;
34 defaultText = literalExpression "pkgs.disnix";
37 enableProfilePath = mkEnableOption (lib.mdDoc "exposing the Disnix profiles in the system's PATH");
40 type = types.listOf types.str;
41 default = [ "default" ];
42 description = lib.mdDoc "Names of the Disnix profiles to expose in the system's PATH";
50 config = mkIf cfg.enable {
51 dysnomia.enable = true;
53 environment.systemPackages = [ pkgs.disnix ] ++ optional cfg.useWebServiceInterface pkgs.DisnixWebService;
54 environment.variables.PATH = lib.optionals cfg.enableProfilePath (map (profileName: "/nix/var/nix/profiles/disnix/${profileName}/bin" ) cfg.profiles);
55 environment.variables.DISNIX_REMOTE_CLIENT = lib.optionalString (cfg.enableMultiUser) "disnix-client";
57 services.dbus.enable = true;
58 services.dbus.packages = [ pkgs.disnix ];
60 services.tomcat.enable = cfg.useWebServiceInterface;
61 services.tomcat.extraGroups = [ "disnix" ];
62 services.tomcat.javaOpts = "${optionalString cfg.useWebServiceInterface "-Djava.library.path=${pkgs.libmatthew_java}/lib/jni"} ";
63 services.tomcat.sharedLibs = optional cfg.useWebServiceInterface "${pkgs.DisnixWebService}/share/java/DisnixConnection.jar"
64 ++ optional cfg.useWebServiceInterface "${pkgs.dbus_java}/share/java/dbus.jar";
65 services.tomcat.webapps = optional cfg.useWebServiceInterface pkgs.DisnixWebService;
67 users.groups.disnix.gid = config.ids.gids.disnix;
70 disnix = mkIf cfg.enableMultiUser {
71 description = "Disnix server";
72 wants = [ "dysnomia.target" ];
73 wantedBy = [ "multi-user.target" ];
74 after = [ "dbus.service" ]
75 ++ optional config.services.httpd.enable "httpd.service"
76 ++ optional config.services.mysql.enable "mysql.service"
77 ++ optional config.services.postgresql.enable "postgresql.service"
78 ++ optional config.services.tomcat.enable "tomcat.service"
79 ++ optional config.services.svnserve.enable "svnserve.service"
80 ++ optional config.services.mongodb.enable "mongodb.service"
81 ++ optional config.services.influxdb.enable "influxdb.service";
83 restartIfChanged = false;
85 path = [ config.nix.package cfg.package config.dysnomia.package "/run/current-system/sw" ];
90 // (if config.environment.variables ? DYSNOMIA_CONTAINERS_PATH then { inherit (config.environment.variables) DYSNOMIA_CONTAINERS_PATH; } else {})
91 // (if config.environment.variables ? DYSNOMIA_MODULES_PATH then { inherit (config.environment.variables) DYSNOMIA_MODULES_PATH; } else {});
93 serviceConfig.ExecStart = "${cfg.package}/bin/disnix-service";