Revert "nixos/dysnomia nixos/disnix: Drop modules"

This reverts commit a3f4db8679.
This commit is contained in:
Sander van der Burg 2021-03-28 17:46:10 +02:00 committed by Sander van der Burg
parent 733f0586c5
commit 4ae1fa61ad
11 changed files with 537 additions and 7 deletions

View File

@ -71,7 +71,7 @@ in
#utmp = 29; # unused #utmp = 29; # unused
# ddclient = 30; # converted to DynamicUser = true # ddclient = 30; # converted to DynamicUser = true
davfs2 = 31; davfs2 = 31;
#disnix = 33; # module removed #disnix = 33; # unused
osgi = 34; osgi = 34;
tor = 35; tor = 35;
cups = 36; cups = 36;
@ -387,7 +387,7 @@ in
utmp = 29; utmp = 29;
# ddclient = 30; # converted to DynamicUser = true # ddclient = 30; # converted to DynamicUser = true
davfs2 = 31; davfs2 = 31;
#disnix = 33; # module removed disnix = 33;
osgi = 34; osgi = 34;
tor = 35; tor = 35;
#cups = 36; # unused #cups = 36; # unused

View File

@ -461,6 +461,8 @@
./services/misc/devmon.nix ./services/misc/devmon.nix
./services/misc/dictd.nix ./services/misc/dictd.nix
./services/misc/dwm-status.nix ./services/misc/dwm-status.nix
./services/misc/dysnomia.nix
./services/misc/disnix.nix
./services/misc/docker-registry.nix ./services/misc/docker-registry.nix
./services/misc/domoticz.nix ./services/misc/domoticz.nix
./services/misc/errbot.nix ./services/misc/errbot.nix

View File

@ -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";
};
};
};
}

View File

@ -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} <<EOF
${printProperties containerProperties}
type=${containerName}
EOF
''
) (builtins.attrNames cfg.containers)}
'';
};
linkMutableComponents = {containerName}:
''
mkdir ${containerName}
${concatMapStrings (componentName:
let
component = cfg.components.${containerName}.${componentName};
in
"ln -s ${component} ${containerName}/${componentName}\n"
) (builtins.attrNames (cfg.components.${containerName} or {}))}
'';
componentsDir = pkgs.stdenv.mkDerivation {
name = "dysnomia-components";
buildCommand = ''
mkdir -p $out
cd $out
${concatMapStrings (containerName:
linkMutableComponents { inherit containerName; }
) (builtins.attrNames cfg.components)}
'';
};
dysnomiaFlags = {
enableApacheWebApplication = config.services.httpd.enable;
enableAxis2WebService = config.services.tomcat.axis2.enable;
enableDockerContainer = config.virtualisation.docker.enable;
enableEjabberdDump = config.services.ejabberd.enable;
enableMySQLDatabase = config.services.mysql.enable;
enablePostgreSQLDatabase = config.services.postgresql.enable;
enableTomcatWebApplication = config.services.tomcat.enable;
enableMongoDatabase = config.services.mongodb.enable;
enableSubversionRepository = config.services.svnserve.enable;
enableInfluxDatabase = config.services.influxdb.enable;
};
in
{
options = {
dysnomia = {
enable = mkOption {
type = types.bool;
default = false;
description = "Whether to enable Dysnomia";
};
enableAuthentication = mkOption {
type = types.bool;
default = false;
description = "Whether to publish privacy-sensitive authentication credentials";
};
package = mkOption {
type = types.path;
description = "The Dysnomia package";
};
properties = mkOption {
description = "An attribute set in which each attribute represents a machine property. Optionally, these values can be shell substitutions.";
default = {};
};
containers = mkOption {
description = "An attribute set in which each key represents a container and each value an attribute set providing its configuration properties";
default = {};
};
components = mkOption {
description = "An atttribute set in which each key represents a container and each value an attribute set in which each key represents a component and each value a derivation constructing its initial state";
default = {};
};
extraContainerProperties = mkOption {
description = "An attribute set providing additional container settings in addition to the default properties";
default = {};
};
extraContainerPaths = mkOption {
description = "A list of paths containing additional container configurations that are added to the search folders";
default = [];
};
extraModulePaths = mkOption {
description = "A list of paths containing additional modules that are added to the search folders";
default = [];
};
enableLegacyModules = mkOption {
type = types.bool;
default = true;
description = "Whether to enable Dysnomia legacy process and wrapper modules";
};
};
};
config = mkIf cfg.enable {
environment.etc = {
"dysnomia/containers" = {
source = containersDir;
};
"dysnomia/components" = {
source = componentsDir;
};
"dysnomia/properties" = {
source = properties;
};
};
environment.variables = {
DYSNOMIA_STATEDIR = "/var/state/dysnomia-nixos";
DYSNOMIA_CONTAINERS_PATH = "${lib.concatMapStrings (containerPath: "${containerPath}:") cfg.extraContainerPaths}/etc/dysnomia/containers";
DYSNOMIA_MODULES_PATH = "${lib.concatMapStrings (modulePath: "${modulePath}:") cfg.extraModulePaths}/etc/dysnomia/modules";
};
environment.systemPackages = [ cfg.package ];
dysnomia.package = pkgs.dysnomia.override (origArgs: dysnomiaFlags // lib.optionalAttrs (cfg.enableLegacyModules) {
enableLegacy = builtins.trace ''
WARNING: Dysnomia has been configured to use the legacy 'process' and 'wrapper'
modules for compatibility reasons! If you rely on these modules, consider
migrating to better alternatives.
More information: https://raw.githubusercontent.com/svanderburg/dysnomia/f65a9a84827bcc4024d6b16527098b33b02e4054/README-legacy.md
If you have migrated already or don't rely on these Dysnomia modules, you can
disable legacy mode with the following NixOS configuration option:
dysnomia.enableLegacyModules = false;
In a future version of Dysnomia (and NixOS) the legacy option will go away!
'' true;
});
dysnomia.properties = {
hostname = config.networking.hostName;
inherit (config.nixpkgs.localSystem) system;
supportedTypes = [
"echo"
"fileset"
"process"
"wrapper"
# These are not base modules, but they are still enabled because they work with technology that are always enabled in NixOS
"systemd-unit"
"sysvinit-script"
"nixos-configuration"
]
++ optional (dysnomiaFlags.enableApacheWebApplication) "apache-webapplication"
++ optional (dysnomiaFlags.enableAxis2WebService) "axis2-webservice"
++ optional (dysnomiaFlags.enableDockerContainer) "docker-container"
++ optional (dysnomiaFlags.enableEjabberdDump) "ejabberd-dump"
++ optional (dysnomiaFlags.enableInfluxDatabase) "influx-database"
++ optional (dysnomiaFlags.enableMySQLDatabase) "mysql-database"
++ optional (dysnomiaFlags.enablePostgreSQLDatabase) "postgresql-database"
++ optional (dysnomiaFlags.enableTomcatWebApplication) "tomcat-webapplication"
++ optional (dysnomiaFlags.enableMongoDatabase) "mongo-database"
++ optional (dysnomiaFlags.enableSubversionRepository) "subversion-repository";
};
dysnomia.containers = lib.recursiveUpdate ({
process = {};
wrapper = {};
}
// lib.optionalAttrs (config.services.httpd.enable) { apache-webapplication = {
documentRoot = config.services.httpd.virtualHosts.localhost.documentRoot;
}; }
// lib.optionalAttrs (config.services.tomcat.axis2.enable) { axis2-webservice = {}; }
// lib.optionalAttrs (config.services.ejabberd.enable) { ejabberd-dump = {
ejabberdUser = config.services.ejabberd.user;
}; }
// lib.optionalAttrs (config.services.mysql.enable) { mysql-database = {
mysqlPort = config.services.mysql.port;
mysqlSocket = "/run/mysqld/mysqld.sock";
} // lib.optionalAttrs cfg.enableAuthentication {
mysqlUsername = "root";
};
}
// lib.optionalAttrs (config.services.postgresql.enable) { postgresql-database = {
} // lib.optionalAttrs (cfg.enableAuthentication) {
postgresqlUsername = "postgres";
};
}
// lib.optionalAttrs (config.services.tomcat.enable) { tomcat-webapplication = {
tomcatPort = 8080;
}; }
// lib.optionalAttrs (config.services.mongodb.enable) { mongo-database = {}; }
// lib.optionalAttrs (config.services.influxdb.enable) {
influx-database = {
influxdbUsername = config.services.influxdb.user;
influxdbDataDir = "${config.services.influxdb.dataDir}/data";
influxdbMetaDir = "${config.services.influxdb.dataDir}/meta";
};
}
// lib.optionalAttrs (config.services.svnserve.enable) { subversion-repository = {
svnBaseDir = config.services.svnserve.svnBaseDir;
}; }) cfg.extraContainerProperties;
system.activationScripts.dysnomia = ''
mkdir -p /etc/systemd-mutable/system
if [ ! -f /etc/systemd-mutable/system/dysnomia.target ]
then
( echo "[Unit]"
echo "Description=Services that are activated and deactivated by Dysnomia"
echo "After=final.target"
) > /etc/systemd-mutable/system/dysnomia.target
fi
'';
};
}

View File

@ -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;
};
}

View File

@ -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;
};
}

View File

@ -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;
};
}

View File

@ -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;
};
}

View File

@ -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;
};
}

View File

@ -150,9 +150,6 @@ mapAliases ({
dbus_glib = dbus-glib; # added 2018-02-25 dbus_glib = dbus-glib; # added 2018-02-25
dbus_libs = dbus; # added 2018-04-25 dbus_libs = dbus; # added 2018-04-25
diffuse = throw "diffuse has been removed from nixpkgs, as it's unmaintained"; # added 2019-12-10 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 dbus_tools = dbus.out; # added 2018-04-25
deadbeef-mpris2-plugin = deadbeefPlugins.mpris2; # added 2018-02-23 deadbeef-mpris2-plugin = deadbeefPlugins.mpris2; # added 2018-02-23
deadpixi-sam = deadpixi-sam-unstable; deadpixi-sam = deadpixi-sam-unstable;
@ -169,8 +166,6 @@ mapAliases ({
docker_compose = docker-compose; # 2018-11-10 docker_compose = docker-compose; # 2018-11-10
draftsight = throw "draftsight has been removed, no longer available as freeware"; # added 2020-08-14 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 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 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 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 elasticmq = throw "elasticmq has been removed in favour of elasticmq-server-bin"; # added 2021-01-17

View File

@ -29657,6 +29657,18 @@ in
solfege = python3Packages.callPackage ../misc/solfege { }; 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 { }; lkproof = callPackage ../tools/typesetting/tex/lkproof { };
lice = python3Packages.callPackage ../tools/misc/lice {}; lice = python3Packages.callPackage ../tools/misc/lice {};