* Support post-stop actions.
svn path=/nixos/branches/modular-nixos/; revision=16393
This commit is contained in:
parent
8f7b33c87d
commit
bb292fdf04
@ -24,11 +24,21 @@ let
|
|||||||
end script
|
end script
|
||||||
'' else ""}
|
'' else ""}
|
||||||
|
|
||||||
${if job.exec != "" then ''
|
${if true then
|
||||||
exec ${job.exec}
|
# Simulate jobs without a main process (which Upstart 0.3
|
||||||
'' else ""}
|
# doesn't support) using a semi-infinite sleep.
|
||||||
|
''
|
||||||
|
exec ${if job.exec != "" then job.exec else "sleep 1e100"}
|
||||||
|
''
|
||||||
|
else ""}
|
||||||
|
|
||||||
${if job.respawn then "respawn" else ""}
|
${if job.respawn then "respawn" else ""}
|
||||||
|
|
||||||
|
${if job.postStop != "" then ''
|
||||||
|
stop script
|
||||||
|
${job.postStop}
|
||||||
|
end script
|
||||||
|
'' else ""}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
in
|
in
|
||||||
@ -145,7 +155,16 @@ in
|
|||||||
default = "";
|
default = "";
|
||||||
description = ''
|
description = ''
|
||||||
Shell commands executed before the job is started
|
Shell commands executed before the job is started
|
||||||
(i.e. before the <varname>exec</varname> command is run).
|
(i.e. before the job's main process is started).
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
postStop = mkOption {
|
||||||
|
type = types.string;
|
||||||
|
default = "";
|
||||||
|
description = ''
|
||||||
|
Shell commands executed after the job has stopped
|
||||||
|
(i.e. after the job's main process has terminated).
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -153,7 +172,10 @@ in
|
|||||||
type = types.string;
|
type = types.string;
|
||||||
default = "";
|
default = "";
|
||||||
description = ''
|
description = ''
|
||||||
Command to start the job.
|
Command to start the job's main process. If empty, the
|
||||||
|
job has no main process, but can still have pre/post-start
|
||||||
|
and pre/post-stop scripts, and is considered "running"
|
||||||
|
until it is stopped.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,75 +1,14 @@
|
|||||||
{pkgs, config, ...}:
|
{pkgs, config, ...}:
|
||||||
|
|
||||||
###### interface
|
|
||||||
let
|
|
||||||
inherit (pkgs.lib) mkOption mkIf;
|
|
||||||
|
|
||||||
options = {
|
|
||||||
services = {
|
|
||||||
ttyBackgrounds = {
|
|
||||||
|
|
||||||
enable = mkOption {
|
|
||||||
default = true;
|
|
||||||
description = "
|
|
||||||
Whether to enable graphical backgrounds for the virtual consoles.
|
|
||||||
";
|
|
||||||
};
|
|
||||||
|
|
||||||
defaultTheme = mkOption {
|
|
||||||
default = pkgs.fetchurl {
|
|
||||||
#url = http://www.bootsplash.de/files/themes/Theme-BabyTux.tar.bz2;
|
|
||||||
url = mirror://gentoo/distfiles/Theme-BabyTux.tar.bz2;
|
|
||||||
md5 = "a6d89d1c1cff3b6a08e2f526f2eab4e0";
|
|
||||||
};
|
|
||||||
description = "
|
|
||||||
The default theme for the virtual consoles. Themes can be found
|
|
||||||
at <link xlink:href='http://www.bootsplash.de/' />.
|
|
||||||
";
|
|
||||||
};
|
|
||||||
|
|
||||||
defaultSpecificThemes = mkOption {
|
|
||||||
default = [
|
|
||||||
/*
|
|
||||||
{ tty = 6;
|
|
||||||
theme = pkgs.fetchurl { # Yeah!
|
|
||||||
url = mirror://gentoo/distfiles/Theme-Pativo.tar.bz2;
|
|
||||||
md5 = "9e13beaaadf88d43a5293e7ab757d569";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
{ tty = 10;
|
|
||||||
theme = pkgs.themes "theme-gnu";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
description = "
|
|
||||||
This option sets specific themes for virtual consoles. If you
|
|
||||||
just want to set themes for additional consoles, use
|
|
||||||
<option>services.ttyBackgrounds.specificThemes</option>.
|
|
||||||
";
|
|
||||||
};
|
|
||||||
|
|
||||||
specificThemes = mkOption {
|
|
||||||
default = [
|
|
||||||
];
|
|
||||||
description = "
|
|
||||||
This option allows you to set specific themes for virtual
|
|
||||||
consoles.
|
|
||||||
";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
|
|
||||||
###### implementation
|
|
||||||
|
|
||||||
let
|
let
|
||||||
|
inherit (pkgs.lib) mkOption mkIf singleton;
|
||||||
inherit (pkgs) stdenv;
|
inherit (pkgs) stdenv;
|
||||||
|
|
||||||
kernelPackages = config.boot.kernelPackages;
|
kernelPackages = config.boot.kernelPackages;
|
||||||
splashutils = kernelPackages.splashutils;
|
splashutils = kernelPackages.splashutils;
|
||||||
requiredTTYs = config.requiredTTYs;
|
requiredTTYs = config.requiredTTYs;
|
||||||
backgrounds =
|
|
||||||
|
|
||||||
|
backgrounds =
|
||||||
let
|
let
|
||||||
|
|
||||||
specificThemes =
|
specificThemes =
|
||||||
@ -91,7 +30,6 @@ let
|
|||||||
}) defaultTTYs)
|
}) defaultTTYs)
|
||||||
++ specificThemes;
|
++ specificThemes;
|
||||||
|
|
||||||
|
|
||||||
themesUnpacked = stdenv.mkDerivation {
|
themesUnpacked = stdenv.mkDerivation {
|
||||||
name = "splash-themes";
|
name = "splash-themes";
|
||||||
builder = ./tty-backgrounds-combine.sh;
|
builder = ./tty-backgrounds-combine.sh;
|
||||||
@ -101,70 +39,125 @@ let
|
|||||||
};
|
};
|
||||||
|
|
||||||
unpackTheme = theme: import ../../lib/unpack-theme.nix {
|
unpackTheme = theme: import ../../lib/unpack-theme.nix {
|
||||||
inherit stdenv theme;
|
inherit stdenv theme;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
mkIf (config.services.ttyBackgrounds.enable) {
|
{
|
||||||
|
|
||||||
assertions = [ { assertion = kernelPackages.splashutils != null; message = "kernelPackages.splashutils may not be false"; } ];
|
###### interface
|
||||||
|
|
||||||
require = [
|
options = {
|
||||||
options
|
|
||||||
];
|
services.ttyBackgrounds = {
|
||||||
|
|
||||||
|
enable = mkOption {
|
||||||
|
default = true;
|
||||||
|
description = ''
|
||||||
|
Whether to enable graphical backgrounds for the virtual consoles.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
defaultTheme = mkOption {
|
||||||
|
default = pkgs.fetchurl {
|
||||||
|
#url = http://www.bootsplash.de/files/themes/Theme-BabyTux.tar.bz2;
|
||||||
|
url = mirror://gentoo/distfiles/Theme-BabyTux.tar.bz2;
|
||||||
|
md5 = "a6d89d1c1cff3b6a08e2f526f2eab4e0";
|
||||||
|
};
|
||||||
|
description = ''
|
||||||
|
The default theme for the virtual consoles. Themes can be found
|
||||||
|
at <link xlink:href='http://www.bootsplash.de/' />.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
defaultSpecificThemes = mkOption {
|
||||||
|
default = [
|
||||||
|
/*
|
||||||
|
{ tty = 6;
|
||||||
|
theme = pkgs.fetchurl { # Yeah!
|
||||||
|
url = mirror://gentoo/distfiles/Theme-Pativo.tar.bz2;
|
||||||
|
md5 = "9e13beaaadf88d43a5293e7ab757d569";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
{ tty = 10;
|
||||||
|
theme = pkgs.themes "theme-gnu";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
description = ''
|
||||||
|
This option sets specific themes for virtual consoles. If you
|
||||||
|
just want to set themes for additional consoles, use
|
||||||
|
<option>services.ttyBackgrounds.specificThemes</option>.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
specificThemes = mkOption {
|
||||||
|
default = [
|
||||||
|
];
|
||||||
|
description = ''
|
||||||
|
This option allows you to set specific themes for virtual
|
||||||
|
consoles.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
environment = {
|
###### implementation
|
||||||
etc = [
|
|
||||||
|
config = mkIf config.services.ttyBackgrounds.enable {
|
||||||
|
|
||||||
|
assertions = singleton
|
||||||
|
{ assertion = kernelPackages.splashutils != null;
|
||||||
|
message = "kernelPackages.splashutils may not be false";
|
||||||
|
};
|
||||||
|
|
||||||
|
environment.etc = singleton
|
||||||
{ source = themesUnpacked;
|
{ source = themesUnpacked;
|
||||||
target = "splash";
|
target = "splash";
|
||||||
}
|
};
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
|
jobs = singleton {
|
||||||
services = {
|
|
||||||
extraJobs = [ rec {
|
|
||||||
name = "tty-backgrounds";
|
name = "tty-backgrounds";
|
||||||
|
|
||||||
job = ''
|
startOn = "udev";
|
||||||
start on udev
|
|
||||||
|
|
||||||
start script
|
preStart =
|
||||||
|
''
|
||||||
|
# Critical: tell the kernel where to find splash_helper. It calls
|
||||||
|
# this program every time we switch between consoles.
|
||||||
|
helperProcFile=${splashutils.helperProcFile}
|
||||||
|
if test -e /proc/sys/fbcondecor; then helperProcFile=/proc/sys/fbcondecor; fi
|
||||||
|
echo ${splashutils}/${splashutils.helperName} > $helperProcFile
|
||||||
|
|
||||||
# Critical: tell the kernel where to find splash_helper. It calls
|
# For each console...
|
||||||
# this program every time we switch between consoles.
|
for tty in ${toString (map (x: x.tty) backgrounds)}; do
|
||||||
helperProcFile=${splashutils.helperProcFile}
|
# Make sure that the console exists.
|
||||||
if test -e /proc/sys/fbcondecor; then helperProcFile=/proc/sys/fbcondecor; fi
|
echo -n "" > /dev/tty$tty
|
||||||
echo ${splashutils}/${splashutils.helperName} > $helperProcFile
|
|
||||||
|
|
||||||
# For each console...
|
# Set the theme as determined by tty-backgrounds-combine.sh
|
||||||
for tty in ${toString (map (x: x.tty) backgrounds)}; do
|
# above.
|
||||||
# Make sure that the console exists.
|
theme=$(readlink ${themesUnpacked}/$tty)
|
||||||
echo -n "" > /dev/tty$tty
|
${splashutils}/${splashutils.controlName} --tty $tty -c setcfg -t $theme || true
|
||||||
|
${splashutils}/${splashutils.controlName} --tty $tty -c setpic -t $theme || true
|
||||||
|
${splashutils}/${splashutils.controlName} --tty $tty -c on || true
|
||||||
|
done
|
||||||
|
'';
|
||||||
|
|
||||||
# Set the theme as determined by tty-backgrounds-combine.sh
|
postStop =
|
||||||
# above.
|
''
|
||||||
theme=$(readlink ${themesUnpacked}/$tty)
|
/var/run/current-system/sw/bin/ps -axuw > /tmp/ps
|
||||||
${splashutils}/${splashutils.controlName} --tty $tty -c setcfg -t $theme || true
|
|
||||||
${splashutils}/${splashutils.controlName} --tty $tty -c setpic -t $theme || true
|
|
||||||
${splashutils}/${splashutils.controlName} --tty $tty -c on || true
|
|
||||||
done
|
|
||||||
|
|
||||||
end script
|
# Disable the theme on each console.
|
||||||
|
for tty in ${toString (map (x: x.tty) backgrounds)}; do
|
||||||
|
${splashutils}/${splashutils.controlName} --tty $tty -c off || true
|
||||||
|
done
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
respawn sleep 10000 # !!! Hack
|
|
||||||
|
|
||||||
stop script
|
|
||||||
# Disable the theme on each console.
|
|
||||||
for tty in ${toString (map (x: x.tty) backgrounds)}; do
|
|
||||||
${splashutils}/${splashutils.controlName} --tty $tty -c off || true
|
|
||||||
done
|
|
||||||
end script
|
|
||||||
'';
|
|
||||||
}];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user