2008-11-18 19:00:15 +01:00
|
|
|
# Disnix server
|
|
|
|
{config, pkgs}:
|
2008-07-06 20:34:19 +02:00
|
|
|
|
2008-11-18 19:00:15 +01:00
|
|
|
###### interface
|
2008-07-06 20:34:19 +02:00
|
|
|
let
|
2008-11-18 19:00:15 +01:00
|
|
|
inherit (pkgs.lib) mkOption;
|
2008-07-06 20:34:19 +02:00
|
|
|
|
2008-11-18 19:00:15 +01:00
|
|
|
options = {
|
|
|
|
services = {
|
|
|
|
disnix = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "Whether to enable Disnix";
|
|
|
|
};
|
|
|
|
|
|
|
|
activateHook = mkOption {
|
|
|
|
default = "";
|
|
|
|
description = "Custom script or executable that activates services through Disnix";
|
|
|
|
};
|
2008-07-06 20:34:19 +02:00
|
|
|
|
2008-11-18 19:00:15 +01:00
|
|
|
deactivateHook = mkOption {
|
|
|
|
default = "";
|
|
|
|
description = "Custom script or executable that deactivates services through Disnix";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2008-07-06 20:34:19 +02:00
|
|
|
in
|
2008-11-18 19:00:15 +01:00
|
|
|
|
|
|
|
###### implementation
|
|
|
|
let
|
|
|
|
cfg = config.services.disnix;
|
|
|
|
|
|
|
|
job = {
|
2008-07-06 20:34:19 +02:00
|
|
|
name = "disnix";
|
2008-07-23 16:13:27 +02:00
|
|
|
|
2008-07-06 20:34:19 +02:00
|
|
|
job = ''
|
|
|
|
description "Disnix server"
|
|
|
|
|
|
|
|
start on dbus
|
2008-07-23 16:13:27 +02:00
|
|
|
stop on shutdown
|
2008-07-06 20:34:19 +02:00
|
|
|
|
|
|
|
start script
|
|
|
|
# !!! quick hack: wait until dbus has started
|
|
|
|
sleep 3
|
|
|
|
end script
|
|
|
|
|
2008-08-13 11:44:40 +02:00
|
|
|
respawn ${pkgs.bash}/bin/sh -c 'export PATH=/var/run/current-system/sw/bin:$PATH; export HOME=/root; export DISNIX_ACTIVATE_HOOK=${cfg.activateHook}; export DISNIX_DEACTIVATE_HOOK=${cfg.deactivateHook}; ${pkgs.disnix}/bin/disnix-service'
|
2008-07-06 20:34:19 +02:00
|
|
|
'';
|
2008-11-18 19:00:15 +01:00
|
|
|
};
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
require = [
|
|
|
|
(import ../upstart-jobs/default.nix)
|
|
|
|
options
|
|
|
|
];
|
|
|
|
|
|
|
|
services = {
|
|
|
|
extraJobs = pkgs.lib.optional cfg.enable job;
|
|
|
|
};
|
2008-07-06 20:34:19 +02:00
|
|
|
}
|