diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix index a0f5ce72f339..feb9c68301d5 100644 --- a/nixos/modules/misc/ids.nix +++ b/nixos/modules/misc/ids.nix @@ -71,7 +71,7 @@ in #utmp = 29; # unused # ddclient = 30; # converted to DynamicUser = true davfs2 = 31; - #disnix = 33; # module removed + #disnix = 33; # unused osgi = 34; tor = 35; cups = 36; @@ -387,7 +387,7 @@ in utmp = 29; # ddclient = 30; # converted to DynamicUser = true davfs2 = 31; - #disnix = 33; # module removed + disnix = 33; osgi = 34; tor = 35; #cups = 36; # unused diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 6524cc62bb75..ca7898687b8b 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -461,6 +461,8 @@ ./services/misc/devmon.nix ./services/misc/dictd.nix ./services/misc/dwm-status.nix + ./services/misc/dysnomia.nix + ./services/misc/disnix.nix ./services/misc/docker-registry.nix ./services/misc/domoticz.nix ./services/misc/errbot.nix diff --git a/nixos/modules/services/misc/disnix.nix b/nixos/modules/services/misc/disnix.nix new file mode 100644 index 000000000000..41483d80a2dd --- /dev/null +++ b/nixos/modules/services/misc/disnix.nix @@ -0,0 +1,98 @@ +# Disnix server +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.services.disnix; + +in + +{ + + ###### interface + + options = { + + services.disnix = { + + enable = mkEnableOption "Disnix"; + + enableMultiUser = mkOption { + type = types.bool; + default = true; + description = "Whether to support multi-user mode by enabling the Disnix D-Bus service"; + }; + + useWebServiceInterface = mkEnableOption "the DisnixWebService interface running on Apache Tomcat"; + + package = mkOption { + type = types.path; + description = "The Disnix package"; + default = pkgs.disnix; + defaultText = "pkgs.disnix"; + }; + + enableProfilePath = mkEnableOption "exposing the Disnix profiles in the system's PATH"; + + profiles = mkOption { + type = types.listOf types.string; + default = [ "default" ]; + example = [ "default" ]; + description = "Names of the Disnix profiles to expose in the system's PATH"; + }; + }; + + }; + + ###### implementation + + config = mkIf cfg.enable { + dysnomia.enable = true; + + environment.systemPackages = [ pkgs.disnix ] ++ optional cfg.useWebServiceInterface pkgs.DisnixWebService; + environment.variables.PATH = lib.optionals cfg.enableProfilePath (map (profileName: "/nix/var/nix/profiles/disnix/${profileName}/bin" ) cfg.profiles); + + services.dbus.enable = true; + services.dbus.packages = [ pkgs.disnix ]; + + services.tomcat.enable = cfg.useWebServiceInterface; + services.tomcat.extraGroups = [ "disnix" ]; + services.tomcat.javaOpts = "${optionalString cfg.useWebServiceInterface "-Djava.library.path=${pkgs.libmatthew_java}/lib/jni"} "; + services.tomcat.sharedLibs = optional cfg.useWebServiceInterface "${pkgs.DisnixWebService}/share/java/DisnixConnection.jar" + ++ optional cfg.useWebServiceInterface "${pkgs.dbus_java}/share/java/dbus.jar"; + services.tomcat.webapps = optional cfg.useWebServiceInterface pkgs.DisnixWebService; + + users.groups.disnix.gid = config.ids.gids.disnix; + + systemd.services = { + disnix = mkIf cfg.enableMultiUser { + description = "Disnix server"; + wants = [ "dysnomia.target" ]; + wantedBy = [ "multi-user.target" ]; + after = [ "dbus.service" ] + ++ optional config.services.httpd.enable "httpd.service" + ++ optional config.services.mysql.enable "mysql.service" + ++ optional config.services.postgresql.enable "postgresql.service" + ++ optional config.services.tomcat.enable "tomcat.service" + ++ optional config.services.svnserve.enable "svnserve.service" + ++ optional config.services.mongodb.enable "mongodb.service" + ++ optional config.services.influxdb.enable "influxdb.service"; + + restartIfChanged = false; + + path = [ config.nix.package cfg.package config.dysnomia.package "/run/current-system/sw" ]; + + environment = { + HOME = "/root"; + } + // (if config.environment.variables ? DYSNOMIA_CONTAINERS_PATH then { inherit (config.environment.variables) DYSNOMIA_CONTAINERS_PATH; } else {}) + // (if config.environment.variables ? DYSNOMIA_MODULES_PATH then { inherit (config.environment.variables) DYSNOMIA_MODULES_PATH; } else {}); + + serviceConfig.ExecStart = "${cfg.package}/bin/disnix-service"; + }; + + }; + }; +} diff --git a/nixos/modules/services/misc/dysnomia.nix b/nixos/modules/services/misc/dysnomia.nix new file mode 100644 index 000000000000..eb94791fbbff --- /dev/null +++ b/nixos/modules/services/misc/dysnomia.nix @@ -0,0 +1,257 @@ +{pkgs, lib, config, ...}: + +with lib; + +let + cfg = config.dysnomia; + + printProperties = properties: + concatMapStrings (propertyName: + let + property = properties.${propertyName}; + in + if isList property then "${propertyName}=(${lib.concatMapStrings (elem: "\"${toString elem}\" ") (properties.${propertyName})})\n" + else "${propertyName}=\"${toString property}\"\n" + ) (builtins.attrNames properties); + + properties = pkgs.stdenv.mkDerivation { + name = "dysnomia-properties"; + buildCommand = '' + cat > $out << "EOF" + ${printProperties cfg.properties} + EOF + ''; + }; + + containersDir = pkgs.stdenv.mkDerivation { + name = "dysnomia-containers"; + buildCommand = '' + mkdir -p $out + cd $out + + ${concatMapStrings (containerName: + let + containerProperties = cfg.containers.${containerName}; + in + '' + cat > ${containerName} < /etc/systemd-mutable/system/dysnomia.target + fi + ''; + }; +} diff --git a/pkgs/tools/package-management/disnix/DisnixWebService/default.nix b/pkgs/tools/package-management/disnix/DisnixWebService/default.nix new file mode 100644 index 000000000000..ba3c51822e90 --- /dev/null +++ b/pkgs/tools/package-management/disnix/DisnixWebService/default.nix @@ -0,0 +1,28 @@ +{lib, stdenv, fetchurl, apacheAnt, jdk, axis2, dbus_java }: + +stdenv.mkDerivation { + name = "DisnixWebService-0.10"; + src = fetchurl { + url = "https://github.com/svanderburg/DisnixWebService/releases/download/DisnixWebService-0.10/DisnixWebService-0.10.tar.gz"; + sha256 = "0m451msd127ay09yb8rbflg68szm8s4hh65j99f7s3mz375vc114"; + }; + buildInputs = [ apacheAnt jdk ]; + PREFIX = "\${env.out}"; + AXIS2_LIB = "${axis2}/lib"; + AXIS2_WEBAPP = "${axis2}/webapps/axis2"; + DBUS_JAVA_LIB = "${dbus_java}/share/java"; + prePatch = '' + sed -i -e "s|#JAVA_HOME=|JAVA_HOME=${jdk}|" \ + -e "s|#AXIS2_LIB=|AXIS2_LIB=${axis2}/lib|" \ + scripts/disnix-soap-client + ''; + buildPhase = "ant"; + installPhase = "ant install"; + + meta = { + description = "A SOAP interface and client for Disnix"; + license = lib.licenses.mit; + maintainers = [ lib.maintainers.sander ]; + platforms = lib.platforms.linux; + }; +} diff --git a/pkgs/tools/package-management/disnix/default.nix b/pkgs/tools/package-management/disnix/default.nix new file mode 100644 index 000000000000..14be0924f271 --- /dev/null +++ b/pkgs/tools/package-management/disnix/default.nix @@ -0,0 +1,20 @@ +{ lib, stdenv, fetchurl, pkg-config, glib, libxml2, libxslt, getopt, gettext, nixUnstable, dysnomia, libintl, libiconv, help2man, doclifter, docbook5, dblatex, doxygen, libnixxml, autoreconfHook }: + +stdenv.mkDerivation { + name = "disnix-0.10"; + + src = fetchurl { + url = "https://github.com/svanderburg/disnix/releases/download/disnix-0.10/disnix-0.10.tar.gz"; + sha256 = "0mciqbc2h60nc0i6pd36w0m2yr96v97ybrzrqzh5f67ac1f0gqwg"; + }; + + nativeBuildInputs = [ pkg-config ]; + buildInputs = [ glib libxml2 libxslt getopt nixUnstable libintl libiconv dysnomia ]; + + meta = { + description = "A Nix-based distributed service deployment tool"; + license = lib.licenses.lgpl21Plus; + maintainers = with lib.maintainers; [ sander tomberek ]; + platforms = lib.platforms.unix; + }; +} diff --git a/pkgs/tools/package-management/disnix/disnixos/default.nix b/pkgs/tools/package-management/disnix/disnixos/default.nix new file mode 100644 index 000000000000..1b9d2eaefcd8 --- /dev/null +++ b/pkgs/tools/package-management/disnix/disnixos/default.nix @@ -0,0 +1,20 @@ +{ lib, stdenv, fetchurl, dysnomia, disnix, socat, pkg-config, getopt }: + +stdenv.mkDerivation { + name = "disnixos-0.9"; + + src = fetchurl { + url = "https://github.com/svanderburg/disnixos/releases/download/disnixos-0.9/disnixos-0.9.tar.gz"; + sha256 = "0vllm5a8d9dvz5cjiq1mmkc4r4vnljabq42ng0ml85sjn0w7xvm7"; + }; + + nativeBuildInputs = [ pkg-config ]; + buildInputs = [ socat dysnomia disnix getopt ]; + + meta = { + description = "Provides complementary NixOS infrastructure deployment to Disnix"; + license = lib.licenses.lgpl21Plus; + maintainers = [ lib.maintainers.sander ]; + platforms = lib.platforms.linux; + }; +} diff --git a/pkgs/tools/package-management/disnix/dydisnix/default.nix b/pkgs/tools/package-management/disnix/dydisnix/default.nix new file mode 100644 index 000000000000..b4c3851a50ff --- /dev/null +++ b/pkgs/tools/package-management/disnix/dydisnix/default.nix @@ -0,0 +1,27 @@ +{ lib, stdenv, fetchFromGitHub, autoconf, automake, libtool , pkg-config, glib, libxml2, libxslt, getopt, libiconv, gettext, nix, disnix, libnixxml }: + +stdenv.mkDerivation rec { + version="2020-07-04"; + name = "dydisnix-${version}"; + + src = fetchFromGitHub { + owner = "svanderburg"; + repo = "dydisnix"; + rev = "e99091f1c2329d562097e35faedee80622d387f0"; + sha256 = "sha256-XKab2hNGtWDkIEMxE1vMvqQBTP9BvHTabBVfzpH57h0="; + }; + + nativeBuildInputs = [ pkg-config autoconf automake libtool ]; + buildInputs = [ glib libxml2 libxslt getopt nix disnix libiconv gettext libnixxml ]; + preConfigure = '' + ./bootstrap + ''; + + meta = { + description = "A toolset enabling self-adaptive redeployment on top of Disnix"; + longDescription = "Dynamic Disnix is a (very experimental!) prototype extension framework for Disnix supporting dynamic (re)deployment of service-oriented systems."; + license = lib.licenses.lgpl21Plus; + maintainers = [ lib.maintainers.tomberek ]; + platforms = lib.platforms.unix; + }; +} diff --git a/pkgs/tools/package-management/disnix/dysnomia/default.nix b/pkgs/tools/package-management/disnix/dysnomia/default.nix new file mode 100644 index 000000000000..56ba16afb47b --- /dev/null +++ b/pkgs/tools/package-management/disnix/dysnomia/default.nix @@ -0,0 +1,71 @@ +{ lib, stdenv, fetchurl, netcat +, systemd ? null, ejabberd ? null, mysql ? null, postgresql ? null, subversion ? null, mongodb ? null, mongodb-tools ? null, influxdb ? null, supervisor ? null, docker ? null +, enableApacheWebApplication ? false +, enableAxis2WebService ? false +, enableEjabberdDump ? false +, enableMySQLDatabase ? false +, enablePostgreSQLDatabase ? false +, enableSubversionRepository ? false +, enableTomcatWebApplication ? false +, enableMongoDatabase ? false +, enableInfluxDatabase ? false +, enableSupervisordProgram ? false +, enableDockerContainer ? true +, enableLegacy ? false +, catalinaBaseDir ? "/var/tomcat" +, jobTemplate ? "systemd" +, getopt +}: + +assert enableMySQLDatabase -> mysql != null; +assert enablePostgreSQLDatabase -> postgresql != null; +assert enableSubversionRepository -> subversion != null; +assert enableEjabberdDump -> ejabberd != null; +assert enableMongoDatabase -> (mongodb != null && mongodb-tools != null); +assert enableInfluxDatabase -> influxdb != null; +assert enableSupervisordProgram -> supervisor != null; +assert enableDockerContainer -> docker != null; + +stdenv.mkDerivation { + name = "dysnomia-0.10"; + src = fetchurl { + url = "https://github.com/svanderburg/dysnomia/releases/download/dysnomia-0.10/dysnomia-0.10.tar.gz"; + sha256 = "19zg4nhn0f9v4i7c9hhan1i4xv3ljfpl2d0s84ph8byiscvhyrna"; + }; + + preConfigure = if enableEjabberdDump then "export PATH=$PATH:${ejabberd}/sbin" else ""; + + configureFlags = [ + (if enableApacheWebApplication then "--with-apache" else "--without-apache") + (if enableAxis2WebService then "--with-axis2" else "--without-axis2") + (if enableEjabberdDump then "--with-ejabberd" else "--without-ejabberd") + (if enableMySQLDatabase then "--with-mysql" else "--without-mysql") + (if enablePostgreSQLDatabase then "--with-postgresql" else "--without-postgresql") + (if enableSubversionRepository then "--with-subversion" else "--without-subversion") + (if enableTomcatWebApplication then "--with-tomcat=${catalinaBaseDir}" else "--without-tomcat") + (if enableMongoDatabase then "--with-mongodb" else "--without-mongodb") + (if enableInfluxDatabase then "--with-influxdb" else "--without-influxdb") + (if enableSupervisordProgram then "--with-supervisord" else "--without-supervisord") + (if enableDockerContainer then "--with-docker" else "--without-docker") + "--with-job-template=${jobTemplate}" + ] ++ lib.optional enableLegacy "--enable-legacy"; + + buildInputs = [ getopt netcat ] + ++ lib.optional stdenv.isLinux systemd + ++ lib.optional enableEjabberdDump ejabberd + ++ lib.optional enableMySQLDatabase mysql.out + ++ lib.optional enablePostgreSQLDatabase postgresql + ++ lib.optional enableSubversionRepository subversion + ++ lib.optional enableMongoDatabase mongodb + ++ lib.optional enableMongoDatabase mongodb-tools + ++ lib.optional enableInfluxDatabase influxdb + ++ lib.optional enableSupervisordProgram supervisor + ++ lib.optional enableDockerContainer docker; + + meta = { + description = "Automated deployment of mutable components and services for Disnix"; + license = lib.licenses.mit; + maintainers = [ lib.maintainers.sander ]; + platforms = lib.platforms.unix; + }; +} diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index 27a933c0f93c..fab7de30d4aa 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -150,9 +150,6 @@ mapAliases ({ dbus_glib = dbus-glib; # added 2018-02-25 dbus_libs = dbus; # added 2018-04-25 diffuse = throw "diffuse has been removed from nixpkgs, as it's unmaintained"; # added 2019-12-10 - disnix = throw "disnix has been removed."; # added 2021-01-27 - disnixos = throw "disnixos has been removed."; # added 2021-01-27 - DisnixWebService = throw "DisnixWebService has been removed."; # added 2021-01-27 dbus_tools = dbus.out; # added 2018-04-25 deadbeef-mpris2-plugin = deadbeefPlugins.mpris2; # added 2018-02-23 deadpixi-sam = deadpixi-sam-unstable; @@ -169,8 +166,6 @@ mapAliases ({ docker_compose = docker-compose; # 2018-11-10 draftsight = throw "draftsight has been removed, no longer available as freeware"; # added 2020-08-14 dvb_apps = throw "dvb_apps has been removed."; # added 2020-11-03 - dydisnix = throw "dydisnix has been removed."; # added 2021-01-27 - dysnomia = throw "dysnomia has been removed."; # added 2021-01-27 dwarf_fortress = dwarf-fortress; # added 2016-01-23 dwm-git = throw "dwm-git has been removed from nixpkgs, as it had no updates for 2 years not serving it's purpose."; # added 2021-02-07 elasticmq = throw "elasticmq has been removed in favour of elasticmq-server-bin"; # added 2021-01-17 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index feefc47051b5..43549d492a09 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -29657,6 +29657,18 @@ in solfege = python3Packages.callPackage ../misc/solfege { }; + disnix = callPackage ../tools/package-management/disnix { }; + + dysnomia = callPackage ../tools/package-management/disnix/dysnomia (config.disnix or { + inherit (pythonPackages) supervisor; + }); + + dydisnix = callPackage ../tools/package-management/disnix/dydisnix { }; + + disnixos = callPackage ../tools/package-management/disnix/disnixos { }; + + DisnixWebService = callPackage ../tools/package-management/disnix/DisnixWebService { }; + lkproof = callPackage ../tools/typesetting/tex/lkproof { }; lice = python3Packages.callPackage ../tools/misc/lice {};