Convert "mysql"
svn path=/nixos/branches/fix-style/; revision=14389
This commit is contained in:
parent
aa78690465
commit
72303e9b6c
@ -479,41 +479,6 @@ in
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mysql = {
|
|
||||||
enable = mkOption {
|
|
||||||
default = false;
|
|
||||||
description = "
|
|
||||||
Whether to enable the MySQL server.
|
|
||||||
";
|
|
||||||
};
|
|
||||||
|
|
||||||
port = mkOption {
|
|
||||||
default = "3306";
|
|
||||||
description = "Port of MySQL";
|
|
||||||
};
|
|
||||||
|
|
||||||
user = mkOption {
|
|
||||||
default = "mysql";
|
|
||||||
description = "User account under which MySQL runs";
|
|
||||||
};
|
|
||||||
|
|
||||||
dataDir = mkOption {
|
|
||||||
default = "/var/mysql";
|
|
||||||
description = "Location where MySQL stores its table files";
|
|
||||||
};
|
|
||||||
|
|
||||||
logError = mkOption {
|
|
||||||
default = "/var/log/mysql_err.log";
|
|
||||||
description = "Location of the MySQL error logfile";
|
|
||||||
};
|
|
||||||
|
|
||||||
pidDir = mkOption {
|
|
||||||
default = "/var/run/mysql";
|
|
||||||
description = "Location of the file which stores the PID of the MySQL server";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
postgresql = {
|
postgresql = {
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
default = false;
|
default = false;
|
||||||
@ -890,6 +855,7 @@ in
|
|||||||
(import ../upstart-jobs/samba.nix) # TODO: doesn't start here (?)
|
(import ../upstart-jobs/samba.nix) # TODO: doesn't start here (?)
|
||||||
(import ../upstart-jobs/ircd-hybrid.nix) # TODO: doesn't compile on x86_64-linux, can't test
|
(import ../upstart-jobs/ircd-hybrid.nix) # TODO: doesn't compile on x86_64-linux, can't test
|
||||||
(import ../upstart-jobs/xfs.nix)
|
(import ../upstart-jobs/xfs.nix)
|
||||||
|
(import ../upstart-jobs/mysql.nix)
|
||||||
|
|
||||||
# nix
|
# nix
|
||||||
(import ../upstart-jobs/nix.nix) # nix options and daemon
|
(import ../upstart-jobs/nix.nix) # nix options and daemon
|
||||||
|
@ -131,12 +131,6 @@ let
|
|||||||
inherit config;
|
inherit config;
|
||||||
})
|
})
|
||||||
|
|
||||||
# MySQL server
|
|
||||||
++ optional config.services.mysql.enable
|
|
||||||
(import ../upstart-jobs/mysql.nix {
|
|
||||||
inherit config pkgs;
|
|
||||||
})
|
|
||||||
|
|
||||||
# Postgres SQL server
|
# Postgres SQL server
|
||||||
++ optional config.services.postgresql.enable
|
++ optional config.services.postgresql.enable
|
||||||
(import ../upstart-jobs/postgresql.nix {
|
(import ../upstart-jobs/postgresql.nix {
|
||||||
|
@ -1,4 +1,49 @@
|
|||||||
{pkgs, config}:
|
{pkgs, config, ...}:
|
||||||
|
|
||||||
|
###### interface
|
||||||
|
let
|
||||||
|
inherit (pkgs.lib) mkOption mkIf;
|
||||||
|
|
||||||
|
options = {
|
||||||
|
services = {
|
||||||
|
mysql = {
|
||||||
|
enable = mkOption {
|
||||||
|
default = false;
|
||||||
|
description = "
|
||||||
|
Whether to enable the MySQL server.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
|
||||||
|
port = mkOption {
|
||||||
|
default = "3306";
|
||||||
|
description = "Port of MySQL";
|
||||||
|
};
|
||||||
|
|
||||||
|
user = mkOption {
|
||||||
|
default = "mysql";
|
||||||
|
description = "User account under which MySQL runs";
|
||||||
|
};
|
||||||
|
|
||||||
|
dataDir = mkOption {
|
||||||
|
default = "/var/mysql";
|
||||||
|
description = "Location where MySQL stores its table files";
|
||||||
|
};
|
||||||
|
|
||||||
|
logError = mkOption {
|
||||||
|
default = "/var/log/mysql_err.log";
|
||||||
|
description = "Location of the MySQL error logfile";
|
||||||
|
};
|
||||||
|
|
||||||
|
pidDir = mkOption {
|
||||||
|
default = "/var/run/mysql";
|
||||||
|
description = "Location of the file which stores the PID of the MySQL server";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
|
||||||
|
###### implementation
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
@ -14,39 +59,51 @@ let
|
|||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
|
||||||
name = "mysql";
|
mkIf config.services.mysql.enable {
|
||||||
|
require = [
|
||||||
users = [
|
options
|
||||||
{ name = "mysql";
|
|
||||||
description = "MySQL server user";
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
|
|
||||||
extraPath = [mysql];
|
users = {
|
||||||
|
extraUsers = [
|
||||||
job = ''
|
{ name = "mysql";
|
||||||
description "MySQL server"
|
description = "MySQL server user";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
stop on shutdown
|
services = {
|
||||||
|
extraJobs = [{
|
||||||
|
name = "mysql";
|
||||||
|
|
||||||
|
|
||||||
start script
|
extraPath = [mysql];
|
||||||
if ! test -e ${cfg.dataDir}; then
|
|
||||||
mkdir -m 0700 -p ${cfg.dataDir}
|
job = ''
|
||||||
chown -R ${cfg.user} ${cfg.dataDir}
|
description "MySQL server"
|
||||||
${mysql}/bin/mysql_install_db ${mysqldOptions}
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -m 0700 -p ${cfg.pidDir}
|
stop on shutdown
|
||||||
chown -R ${cfg.user} ${cfg.pidDir}
|
|
||||||
end script
|
|
||||||
|
|
||||||
respawn ${mysql}/bin/mysqld ${mysqldOptions}
|
start script
|
||||||
|
if ! test -e ${cfg.dataDir}; then
|
||||||
|
mkdir -m 0700 -p ${cfg.dataDir}
|
||||||
|
chown -R ${cfg.user} ${cfg.dataDir}
|
||||||
|
${mysql}/bin/mysql_install_db ${mysqldOptions}
|
||||||
|
fi
|
||||||
|
|
||||||
stop script
|
mkdir -m 0700 -p ${cfg.pidDir}
|
||||||
pid=$(cat ${pidFile})
|
chown -R ${cfg.user} ${cfg.pidDir}
|
||||||
kill "$pid"
|
end script
|
||||||
${mysql}/bin/mysql_waitpid "$pid" 1000
|
|
||||||
end script
|
respawn ${mysql}/bin/mysqld ${mysqldOptions}
|
||||||
'';
|
|
||||||
|
stop script
|
||||||
|
pid=$(cat ${pidFile})
|
||||||
|
kill "$pid"
|
||||||
|
${mysql}/bin/mysql_waitpid "$pid" 1000
|
||||||
|
end script
|
||||||
|
'';
|
||||||
|
}];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user