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 | |
parent | af50b03f50d88954e98018c7c18c0581928b7165 (diff) | |
download | nixpkgs-88292fdf09960e9cb8e3c063a6b95ac4284222ec.tar nixpkgs-88292fdf09960e9cb8e3c063a6b95ac4284222ec.tar.gz nixpkgs-88292fdf09960e9cb8e3c063a6b95ac4284222ec.tar.bz2 nixpkgs-88292fdf09960e9cb8e3c063a6b95ac4284222ec.tar.lz nixpkgs-88292fdf09960e9cb8e3c063a6b95ac4284222ec.tar.xz nixpkgs-88292fdf09960e9cb8e3c063a6b95ac4284222ec.tar.zst nixpkgs-88292fdf09960e9cb8e3c063a6b95ac4284222ec.zip |
jobs -> systemd.services
Diffstat (limited to 'nixos/modules/services/misc')
-rw-r--r-- | nixos/modules/services/misc/dictd.nix | 15 | ||||
-rw-r--r-- | nixos/modules/services/misc/disnix.nix | 110 | ||||
-rw-r--r-- | nixos/modules/services/misc/felix.nix | 95 | ||||
-rw-r--r-- | nixos/modules/services/misc/folding-at-home.nix | 32 | ||||
-rw-r--r-- | nixos/modules/services/misc/svnserve.nix | 10 |
5 files changed, 124 insertions, 138 deletions
diff --git a/nixos/modules/services/misc/dictd.nix b/nixos/modules/services/misc/dictd.nix index 552e0a435ef..118d299042d 100644 --- a/nixos/modules/services/misc/dictd.nix +++ b/nixos/modules/services/misc/dictd.nix @@ -51,13 +51,12 @@ with lib; gid = config.ids.gids.dictd; }; - jobs.dictd = - { description = "DICT.org Dictionary Server"; - startOn = "startup"; - environment = { LOCALE_ARCHIVE = "/run/current-system/sw/lib/locale/locale-archive"; }; - daemonType = "fork"; - exec = "${pkgs.dict}/sbin/dictd -s -c ${dictdb}/share/dictd/dictd.conf --locale en_US.UTF-8"; - }; + systemd.services.dictd = { + description = "DICT.org Dictionary Server"; + wantedBy = [ "multi-user.target" ]; + environment = { LOCALE_ARCHIVE = "/run/current-system/sw/lib/locale/locale-archive"; }; + serviceConfig.Type = "forking"; + script = "${pkgs.dict}/sbin/dictd -s -c ${dictdb}/share/dictd/dictd.conf --locale en_US.UTF-8"; + }; }; - } diff --git a/nixos/modules/services/misc/disnix.nix b/nixos/modules/services/misc/disnix.nix index 0534c4fc942..469a2a7ce3b 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))} + ''; + }; }; }; } diff --git a/nixos/modules/services/misc/felix.nix b/nixos/modules/services/misc/felix.nix index a01c7f08b91..08a8581711f 100644 --- a/nixos/modules/services/misc/felix.nix +++ b/nixos/modules/services/misc/felix.nix @@ -57,54 +57,51 @@ in home = "/homeless-shelter"; }; - jobs.felix = - { description = "Felix server"; - - preStart = - '' - # Initialise felix instance on first startup - if [ ! -d /var/felix ] - then - # Symlink system files - - mkdir -p /var/felix - chown ${cfg.user}:${cfg.group} /var/felix - - for i in ${pkgs.felix}/* - do - if [ "$i" != "${pkgs.felix}/bundle" ] - then - ln -sfn $i /var/felix/$(basename $i) - fi - done - - # Symlink bundles - mkdir -p /var/felix/bundle - chown ${cfg.user}:${cfg.group} /var/felix/bundle - - for i in ${pkgs.felix}/bundle/* ${toString cfg.bundles} - do - if [ -f $i ] - then - ln -sfn $i /var/felix/bundle/$(basename $i) - elif [ -d $i ] - then - for j in $i/bundle/* - do - ln -sfn $j /var/felix/bundle/$(basename $j) - done - fi - done - fi - ''; - - script = - '' - cd /var/felix - ${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh ${cfg.user} -c '${pkgs.jre}/bin/java -jar bin/felix.jar' - ''; - }; - + systemd.services.felix = { + description = "Felix server"; + wantedBy = [ "multi-user.target" ]; + + preStart = '' + # Initialise felix instance on first startup + if [ ! -d /var/felix ] + then + # Symlink system files + + mkdir -p /var/felix + chown ${cfg.user}:${cfg.group} /var/felix + + for i in ${pkgs.felix}/* + do + if [ "$i" != "${pkgs.felix}/bundle" ] + then + ln -sfn $i /var/felix/$(basename $i) + fi + done + + # Symlink bundles + mkdir -p /var/felix/bundle + chown ${cfg.user}:${cfg.group} /var/felix/bundle + + for i in ${pkgs.felix}/bundle/* ${toString cfg.bundles} + do + if [ -f $i ] + then + ln -sfn $i /var/felix/bundle/$(basename $i) + elif [ -d $i ] + then + for j in $i/bundle/* + do + ln -sfn $j /var/felix/bundle/$(basename $j) + done + fi + done + fi + ''; + + script = '' + cd /var/felix + ${pkgs.su}/bin/su -s ${pkgs.bash}/bin/sh ${cfg.user} -c '${pkgs.jre}/bin/java -jar bin/felix.jar' + ''; + }; }; - } diff --git a/nixos/modules/services/misc/folding-at-home.nix b/nixos/modules/services/misc/folding-at-home.nix index 392d2d1f002..4f09cbfdd79 100644 --- a/nixos/modules/services/misc/folding-at-home.nix +++ b/nixos/modules/services/misc/folding-at-home.nix @@ -49,26 +49,20 @@ in { home = stateDir; }; - jobs.foldingAtHome = - { name = "foldingathome"; - - startOn = "started network-interfaces"; - stopOn = "stopping network-interfaces"; - - preStart = - '' - mkdir -m 0755 -p ${stateDir} - chown ${fahUser} ${stateDir} - cp -f ${pkgs.writeText "client.cfg" cfg.config} ${stateDir}/client.cfg - ''; - exec = "${pkgs.su}/bin/su -s ${pkgs.stdenv.shell} ${fahUser} -c 'cd ${stateDir}; ${pkgs.foldingathome}/bin/fah6'"; - }; - - services.foldingAtHome.config = '' - [settings] - username=${cfg.nickname} + systemd.services.foldingathome = { + after = [ "network-interfaces.target" ]; + wantedBy = [ "multi-user.target" ]; + preStart = '' + mkdir -m 0755 -p ${stateDir} + chown ${fahUser} ${stateDir} + cp -f ${pkgs.writeText "client.cfg" cfg.config} ${stateDir}/client.cfg ''; + script = "${pkgs.su}/bin/su -s ${pkgs.stdenv.shell} ${fahUser} -c 'cd ${stateDir}; ${pkgs.foldingathome}/bin/fah6'"; + }; + services.foldingAtHome.config = '' + [settings] + username=${cfg.nickname} + ''; }; - } diff --git a/nixos/modules/services/misc/svnserve.nix b/nixos/modules/services/misc/svnserve.nix index 848905ca457..37dd133e137 100644 --- a/nixos/modules/services/misc/svnserve.nix +++ b/nixos/modules/services/misc/svnserve.nix @@ -34,13 +34,11 @@ in ###### implementation config = mkIf cfg.enable { - jobs.svnserve = { - startOn = "started network-interfaces"; - stopOn = "stopping network-interfaces"; - + systemd.services.svnserve = { + after = [ "network-interfaces.target" ]; + wantedBy = [ "multi-user.target" ]; preStart = "mkdir -p ${cfg.svnBaseDir}"; - - exec = "${pkgs.subversion}/bin/svnserve -r ${cfg.svnBaseDir} -d --foreground --pid-file=/var/run/svnserve.pid"; + script = "${pkgs.subversion}/bin/svnserve -r ${cfg.svnBaseDir} -d --foreground --pid-file=/var/run/svnserve.pid"; }; }; } |