diff options
author | Robin Gloster <mail@glob.in> | 2016-01-06 06:50:18 +0000 |
---|---|---|
committer | Robin Gloster <mail@glob.in> | 2016-01-07 06:39:06 +0000 |
commit | 88292fdf09960e9cb8e3c063a6b95ac4284222ec (patch) | |
tree | 34ff267ed7bacf9fd906b1736476b431e9afe909 /nixos/modules/services/misc/disnix.nix | |
parent | af50b03f50d88954e98018c7c18c0581928b7165 (diff) | |
download | nixlib-88292fdf09960e9cb8e3c063a6b95ac4284222ec.tar nixlib-88292fdf09960e9cb8e3c063a6b95ac4284222ec.tar.gz nixlib-88292fdf09960e9cb8e3c063a6b95ac4284222ec.tar.bz2 nixlib-88292fdf09960e9cb8e3c063a6b95ac4284222ec.tar.lz nixlib-88292fdf09960e9cb8e3c063a6b95ac4284222ec.tar.xz nixlib-88292fdf09960e9cb8e3c063a6b95ac4284222ec.tar.zst nixlib-88292fdf09960e9cb8e3c063a6b95ac4284222ec.zip |
jobs -> systemd.services
Diffstat (limited to 'nixos/modules/services/misc/disnix.nix')
-rw-r--r-- | nixos/modules/services/misc/disnix.nix | 110 |
1 files changed, 54 insertions, 56 deletions
diff --git a/nixos/modules/services/misc/disnix.nix b/nixos/modules/services/misc/disnix.nix index 0534c4fc942d..469a2a7ce3b4 100644 --- a/nixos/modules/services/misc/disnix.nix +++ b/nixos/modules/services/misc/disnix.nix @@ -91,7 +91,7 @@ in ( { hostname = config.networking.hostName; #targetHost = config.deployment.targetHost; system = if config.nixpkgs.system == "" then builtins.currentSystem else config.nixpkgs.system; - + supportedTypes = (import "${pkgs.stdenv.mkDerivation { name = "supportedtypes"; buildCommand = '' @@ -117,63 +117,61 @@ in services.disnix.publishInfrastructure.enable = cfg.publishAvahi; - jobs = { - disnix = - { 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"; - - restartIfChanged = false; - - path = [ pkgs.nix pkgs.disnix dysnomia "/run/current-system/sw" ]; - - environment = { - HOME = "/root"; - }; - - preStart = '' - 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 - ''; - - exec = "disnix-service"; + systemd.services = { + disnix = { + 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"; + + restartIfChanged = false; + + path = [ pkgs.nix pkgs.disnix dysnomia "/run/current-system/sw" ]; + + environment = { + HOME = "/root"; }; + + preStart = '' + 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 + ''; + + script = "disnix-service"; + }; } // optionalAttrs cfg.publishAvahi { - disnixAvahi = - { description = "Disnix Avahi publisher"; - - startOn = "started avahi-daemon"; - - exec = - '' - ${pkgs.avahi}/bin/avahi-publish-service disnix-${config.networking.hostName} _disnix._tcp 22 \ - "mem=$(grep 'MemTotal:' /proc/meminfo | sed -e 's/kB//' -e 's/MemTotal://' -e 's/ //g')" \ - ${concatMapStrings (infrastructureAttrName: - let infrastructureAttrValue = getAttr infrastructureAttrName (cfg.infrastructure); - in - if isInt infrastructureAttrValue then - ''${infrastructureAttrName}=${toString infrastructureAttrValue} \ - '' - else - ''${infrastructureAttrName}=\"${infrastructureAttrValue}\" \ - '' - ) (attrNames (cfg.infrastructure))} - ''; - }; + disnixAvahi = { + description = "Disnix Avahi publisher"; + wants = [ "avahi-daemon.service" ]; + wantedBy = [ "multi-user.target" ]; + + script = '' + ${pkgs.avahi}/bin/avahi-publish-service disnix-${config.networking.hostName} _disnix._tcp 22 \ + "mem=$(grep 'MemTotal:' /proc/meminfo | sed -e 's/kB//' -e 's/MemTotal://' -e 's/ //g')" \ + ${concatMapStrings (infrastructureAttrName: + let infrastructureAttrValue = getAttr infrastructureAttrName (cfg.infrastructure); + in + if isInt infrastructureAttrValue then + ''${infrastructureAttrName}=${toString infrastructureAttrValue} \ + '' + else + ''${infrastructureAttrName}=\"${infrastructureAttrValue}\" \ + '' + ) (attrNames (cfg.infrastructure))} + ''; + }; }; }; } |