2 { config, lib, pkgs, ... }:
5 cfg = config.services.disnix;
17 enable = lib.mkEnableOption "Disnix";
19 enableMultiUser = lib.mkOption {
20 type = lib.types.bool;
22 description = "Whether to support multi-user mode by enabling the Disnix D-Bus service";
25 useWebServiceInterface = lib.mkEnableOption "the DisnixWebService interface running on Apache Tomcat";
27 package = lib.mkPackageOption pkgs "disnix" {};
29 enableProfilePath = lib.mkEnableOption "exposing the Disnix profiles in the system's PATH";
31 profiles = lib.mkOption {
32 type = lib.types.listOf lib.types.str;
33 default = [ "default" ];
34 description = "Names of the Disnix profiles to expose in the system's PATH";
42 config = lib.mkIf cfg.enable {
43 dysnomia.enable = true;
45 environment.systemPackages = [ pkgs.disnix ] ++ lib.optional cfg.useWebServiceInterface pkgs.DisnixWebService;
46 environment.variables.PATH = lib.optionals cfg.enableProfilePath (map (profileName: "/nix/var/nix/profiles/disnix/${profileName}/bin" ) cfg.profiles);
47 environment.variables.DISNIX_REMOTE_CLIENT = lib.optionalString (cfg.enableMultiUser) "disnix-client";
49 services.dbus.enable = true;
50 services.dbus.packages = [ pkgs.disnix ];
52 services.tomcat.enable = cfg.useWebServiceInterface;
53 services.tomcat.extraGroups = [ "disnix" ];
54 services.tomcat.javaOpts = "${lib.optionalString cfg.useWebServiceInterface "-Djava.library.path=${pkgs.libmatthew_java}/lib/jni"} ";
55 services.tomcat.sharedLibs = lib.optional cfg.useWebServiceInterface "${pkgs.DisnixWebService}/share/java/DisnixConnection.jar"
56 ++ lib.optional cfg.useWebServiceInterface "${pkgs.dbus_java}/share/java/dbus.jar";
57 services.tomcat.webapps = lib.optional cfg.useWebServiceInterface pkgs.DisnixWebService;
59 users.groups.disnix.gid = config.ids.gids.disnix;
62 disnix = lib.mkIf cfg.enableMultiUser {
63 description = "Disnix server";
64 wants = [ "dysnomia.target" ];
65 wantedBy = [ "multi-user.target" ];
66 after = [ "dbus.service" ]
67 ++ lib.optional config.services.httpd.enable "httpd.service"
68 ++ lib.optional config.services.mysql.enable "mysql.service"
69 ++ lib.optional config.services.postgresql.enable "postgresql.service"
70 ++ lib.optional config.services.tomcat.enable "tomcat.service"
71 ++ lib.optional config.services.svnserve.enable "svnserve.service"
72 ++ lib.optional config.services.mongodb.enable "mongodb.service"
73 ++ lib.optional config.services.influxdb.enable "influxdb.service";
75 restartIfChanged = false;
77 path = [ config.nix.package cfg.package config.dysnomia.package "/run/current-system/sw" ];
82 // (lib.optionalAttrs (config.environment.variables ? DYSNOMIA_CONTAINERS_PATH) { inherit (config.environment.variables) DYSNOMIA_CONTAINERS_PATH; })
83 // (lib.optionalAttrs (config.environment.variables ? DYSNOMIA_MODULES_PATH) { inherit (config.environment.variables) DYSNOMIA_MODULES_PATH; });
85 serviceConfig.ExecStart = "${cfg.package}/bin/disnix-service";