2008-11-18 18:00:15 +00:00
|
|
|
# Disnix server
|
2009-01-25 15:48:39 +00:00
|
|
|
{config, pkgs, ...}:
|
2008-07-06 18:34:19 +00:00
|
|
|
|
2008-11-18 18:00:15 +00:00
|
|
|
###### interface
|
2008-07-06 18:34:19 +00:00
|
|
|
let
|
2008-11-18 18:00:15 +00:00
|
|
|
inherit (pkgs.lib) mkOption;
|
2008-07-06 18:34:19 +00:00
|
|
|
|
2008-11-18 18:00:15 +00: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 18:34:19 +00:00
|
|
|
|
2008-11-18 18:00:15 +00:00
|
|
|
deactivateHook = mkOption {
|
|
|
|
default = "";
|
|
|
|
description = "Custom script or executable that deactivates services through Disnix";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2008-07-06 18:34:19 +00:00
|
|
|
in
|
2008-11-18 18:00:15 +00:00
|
|
|
|
|
|
|
###### implementation
|
|
|
|
let
|
|
|
|
cfg = config.services.disnix;
|
2008-11-23 01:29:25 +00:00
|
|
|
inherit (pkgs.lib) mkIf;
|
2008-11-18 18:00:15 +00:00
|
|
|
|
|
|
|
job = {
|
2008-07-06 18:34:19 +00:00
|
|
|
name = "disnix";
|
2008-07-23 14:13:27 +00:00
|
|
|
|
2008-07-06 18:34:19 +00:00
|
|
|
job = ''
|
|
|
|
description "Disnix server"
|
|
|
|
|
|
|
|
start on dbus
|
2008-07-23 14:13:27 +00:00
|
|
|
stop on shutdown
|
2008-07-06 18:34:19 +00:00
|
|
|
|
|
|
|
start script
|
|
|
|
# !!! quick hack: wait until dbus has started
|
|
|
|
sleep 3
|
|
|
|
end script
|
|
|
|
|
2008-08-13 09:44:40 +00: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 18:34:19 +00:00
|
|
|
'';
|
2008-11-18 18:00:15 +00:00
|
|
|
};
|
|
|
|
in
|
|
|
|
|
2008-11-23 01:29:25 +00:00
|
|
|
mkIf cfg.enable {
|
2008-11-18 18:00:15 +00:00
|
|
|
require = [
|
|
|
|
(import ../upstart-jobs/default.nix)
|
2008-11-23 01:28:58 +00:00
|
|
|
(import ../upstart-jobs/dbus.nix) # services.dbus.*
|
2008-11-18 18:00:15 +00:00
|
|
|
options
|
|
|
|
];
|
|
|
|
|
|
|
|
services = {
|
2008-11-23 01:29:25 +00:00
|
|
|
extraJobs = [job];
|
2008-11-23 01:28:58 +00:00
|
|
|
|
|
|
|
dbus = {
|
2008-11-23 01:29:25 +00:00
|
|
|
enable = true;
|
|
|
|
services = [pkgs.disnix];
|
2008-11-23 01:28:58 +00:00
|
|
|
};
|
2008-11-18 18:00:15 +00:00
|
|
|
};
|
2008-07-06 18:34:19 +00:00
|
|
|
}
|