mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-12 05:16:25 +03:00
* system/options.nix: gone :-)
svn path=/nixos/branches/modular-nixos/; revision=15772
This commit is contained in:
parent
fc9111fadf
commit
c6c9304b95
5 changed files with 183 additions and 197 deletions
|
@ -7,7 +7,7 @@
|
||||||
rec {
|
rec {
|
||||||
configComponents = [
|
configComponents = [
|
||||||
configuration
|
configuration
|
||||||
(import ../system/options.nix)
|
{ require = import ../modules/module-list.nix; }
|
||||||
];
|
];
|
||||||
|
|
||||||
config =
|
config =
|
||||||
|
|
|
@ -58,13 +58,7 @@ let
|
||||||
|
|
||||||
optional = cond: service: pkgs.lib.optional cond (makeJob service);
|
optional = cond: service: pkgs.lib.optional cond (makeJob service);
|
||||||
|
|
||||||
requiredTTYs = config.requiredTTYs;
|
jobs = map makeJob config.services.extraJobs;
|
||||||
|
|
||||||
jobs = map makeJob []
|
|
||||||
|
|
||||||
# User-defined events.
|
|
||||||
++ (map makeJob (config.services.extraJobs));
|
|
||||||
|
|
||||||
|
|
||||||
# Create an etc/event.d directory containing symlinks to the
|
# Create an etc/event.d directory containing symlinks to the
|
||||||
# specified list of Upstart job files.
|
# specified list of Upstart job files.
|
||||||
|
|
|
@ -1,7 +1,39 @@
|
||||||
{pkgs, config, ...}:
|
{pkgs, config, ...}:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (pkgs.lib) mkOption;
|
|
||||||
|
###### interface
|
||||||
|
|
||||||
|
# most options are defined in i18n.nix
|
||||||
|
|
||||||
|
options = {
|
||||||
|
|
||||||
|
boot.extraTTYs = pkgs.lib.mkOption {
|
||||||
|
default = [];
|
||||||
|
example = [8 9];
|
||||||
|
description = "
|
||||||
|
Tty (virtual console) devices, in addition to the consoles on
|
||||||
|
which mingetty and syslogd run, that must be initialised.
|
||||||
|
Only useful if you have some program that you want to run on
|
||||||
|
some fixed console. For example, the NixOS installation CD
|
||||||
|
opens the manual in a web browser on console 7, so it sets
|
||||||
|
<option>boot.extraTTYs</option> to <literal>[7]</literal>.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
|
||||||
|
# dummy option so that requiredTTYs can be passed
|
||||||
|
requiredTTYs = pkgs.lib.mkOption {
|
||||||
|
default = [];
|
||||||
|
description = "
|
||||||
|
FIXME: find another place for this option.
|
||||||
|
FIXME: find a good description.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
###### implementation
|
||||||
|
|
||||||
# think about where to put this chunk of code!
|
# think about where to put this chunk of code!
|
||||||
# required by other pieces as well
|
# required by other pieces as well
|
||||||
|
@ -16,26 +48,10 @@ let
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
###### implementation
|
|
||||||
|
|
||||||
# most options are defined in i18n.nix
|
|
||||||
|
|
||||||
{
|
{
|
||||||
|
require = [options];
|
||||||
|
|
||||||
inherit requiredTTYs; # pass them to upstart-job/default.nix
|
inherit requiredTTYs; # pass them to ./modules/tasks/tty-backgrounds.nix
|
||||||
|
|
||||||
# dummy option so that requiredTTYs can be passed, see above (FIXME)
|
|
||||||
require = [
|
|
||||||
{
|
|
||||||
requiredTTYs = mkOption {
|
|
||||||
default = [];
|
|
||||||
description = "
|
|
||||||
FIXME: find another place for this option.
|
|
||||||
FIXME: find a good description.
|
|
||||||
";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
extraJobs = [{
|
extraJobs = [{
|
||||||
|
|
|
@ -1,9 +1,70 @@
|
||||||
{pkgs, config, ...}:
|
{pkgs, config, ...}:
|
||||||
|
|
||||||
###### implementation
|
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
|
inherit (pkgs.lib) mkOption;
|
||||||
|
|
||||||
|
|
||||||
|
###### interface
|
||||||
|
|
||||||
|
options = {
|
||||||
|
|
||||||
|
networking.hostName = mkOption {
|
||||||
|
default = "nixos";
|
||||||
|
description = "
|
||||||
|
The name of the machine. Leave it empty if you want to obtain
|
||||||
|
it from a DHCP server (if using DHCP).
|
||||||
|
";
|
||||||
|
};
|
||||||
|
|
||||||
|
networking.nativeIPv6 = mkOption {
|
||||||
|
default = false;
|
||||||
|
description = "
|
||||||
|
Whether to use IPv6 even though gw6c is not used. For example,
|
||||||
|
for Postfix.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
|
||||||
|
networking.defaultGateway = mkOption {
|
||||||
|
default = "";
|
||||||
|
example = "131.211.84.1";
|
||||||
|
description = "
|
||||||
|
The default gateway. It can be left empty if it is auto-detected through DHCP.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
|
||||||
|
networking.nameservers = mkOption {
|
||||||
|
default = [];
|
||||||
|
example = ["130.161.158.4" "130.161.33.17"];
|
||||||
|
description = "
|
||||||
|
The list of nameservers. It can be left empty if it is auto-detected through DHCP.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
|
||||||
|
networking.domain = mkOption {
|
||||||
|
default = "";
|
||||||
|
example = "home";
|
||||||
|
description = "
|
||||||
|
The domain. It can be left empty if it is auto-detected through DHCP.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
|
||||||
|
networking.localCommands = mkOption {
|
||||||
|
default = "";
|
||||||
|
example = "text=anything; echo You can put $text here.";
|
||||||
|
description = "
|
||||||
|
Shell commands to be executed at the end of the
|
||||||
|
<literal>network-interfaces</literal> Upstart job. Note that if
|
||||||
|
you are using DHCP to obtain the network configuration,
|
||||||
|
interfaces may not be fully configured yet.
|
||||||
|
";
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
###### implementation
|
||||||
|
|
||||||
inherit (pkgs) nettools wirelesstools bash writeText;
|
inherit (pkgs) nettools wirelesstools bash writeText;
|
||||||
|
|
||||||
cfg = config.networking;
|
cfg = config.networking;
|
||||||
|
@ -18,92 +79,91 @@ let
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
services = {
|
require = [options];
|
||||||
extraJobs = [{
|
|
||||||
name = "network-interfaces";
|
services.extraJobs = [{
|
||||||
|
name = "network-interfaces";
|
||||||
job = ''
|
|
||||||
start on udev
|
job = ''
|
||||||
stop on shutdown
|
start on udev
|
||||||
|
stop on shutdown
|
||||||
start script
|
|
||||||
export PATH=${modprobe}/sbin:$PATH
|
start script
|
||||||
modprobe af_packet || true
|
export PATH=${modprobe}/sbin:$PATH
|
||||||
|
modprobe af_packet || true
|
||||||
for i in $(cd /sys/class/net && ls -d *); do
|
|
||||||
echo "Bringing up network device $i..."
|
for i in $(cd /sys/class/net && ls -d *); do
|
||||||
${nettools}/sbin/ifconfig $i up || true
|
echo "Bringing up network device $i..."
|
||||||
done
|
${nettools}/sbin/ifconfig $i up || true
|
||||||
|
done
|
||||||
# Configure the manually specified interfaces.
|
|
||||||
names=(${toString names})
|
# Configure the manually specified interfaces.
|
||||||
ipAddresses=(${toString ipAddresses})
|
names=(${toString names})
|
||||||
subnetMasks=(${toString subnetMasks})
|
ipAddresses=(${toString ipAddresses})
|
||||||
essids=(${toString essids})
|
subnetMasks=(${toString subnetMasks})
|
||||||
wepKeys=(${toString wepKeys})
|
essids=(${toString essids})
|
||||||
|
wepKeys=(${toString wepKeys})
|
||||||
for ((n = 0; n < ''${#names[*]}; n++)); do
|
|
||||||
name=''${names[$n]}
|
for ((n = 0; n < ''${#names[*]}; n++)); do
|
||||||
ipAddress=''${ipAddresses[$n]}
|
name=''${names[$n]}
|
||||||
subnetMask=''${subnetMasks[$n]}
|
ipAddress=''${ipAddresses[$n]}
|
||||||
essid=''${essids[$n]}
|
subnetMask=''${subnetMasks[$n]}
|
||||||
wepKey=''${wepKeys[$n]}
|
essid=''${essids[$n]}
|
||||||
|
wepKey=''${wepKeys[$n]}
|
||||||
# Set wireless networking stuff.
|
|
||||||
if test "$essid" != default; then
|
# Set wireless networking stuff.
|
||||||
${wirelesstools}/sbin/iwconfig "$name" essid "$essid" || true
|
if test "$essid" != default; then
|
||||||
fi
|
${wirelesstools}/sbin/iwconfig "$name" essid "$essid" || true
|
||||||
|
|
||||||
if test "$wepKey" != nokey; then
|
|
||||||
${wirelesstools}/sbin/iwconfig "$name" key "$(cat "$wepKey")" || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set IP address / netmask.
|
|
||||||
if test "$ipAddress" != dhcp; then
|
|
||||||
echo "Configuring interface $name..."
|
|
||||||
extraFlags=
|
|
||||||
if test "$subnetMask" != default; then
|
|
||||||
extraFlags="$extraFlags netmask $subnetMask"
|
|
||||||
fi
|
|
||||||
${nettools}/sbin/ifconfig "$name" "$ipAddress" $extraFlags || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
done
|
|
||||||
|
|
||||||
# Set the nameservers.
|
|
||||||
if test -n "${toString cfg.nameservers}"; then
|
|
||||||
rm -f /etc/resolv.conf
|
|
||||||
if test -n "${cfg.domain}"; then
|
|
||||||
echo "domain ${cfg.domain}" >> /etc/resolv.conf
|
|
||||||
fi
|
|
||||||
for i in ${toString cfg.nameservers}; do
|
|
||||||
echo "nameserver $i" >> /etc/resolv.conf
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set the default gateway.
|
if test "$wepKey" != nokey; then
|
||||||
if test -n "${cfg.defaultGateway}"; then
|
${wirelesstools}/sbin/iwconfig "$name" key "$(cat "$wepKey")" || true
|
||||||
${nettools}/sbin/route add default gw "${cfg.defaultGateway}" || true
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run any user-specified commands.
|
# Set IP address / netmask.
|
||||||
${bash}/bin/sh ${writeText "local-net-cmds" cfg.localCommands} || true
|
if test "$ipAddress" != dhcp; then
|
||||||
|
echo "Configuring interface $name..."
|
||||||
end script
|
extraFlags=
|
||||||
|
if test "$subnetMask" != default; then
|
||||||
# Hack: Upstart doesn't yet support what we want: a service that
|
extraFlags="$extraFlags netmask $subnetMask"
|
||||||
# doesn't have a running process associated with it.
|
fi
|
||||||
respawn sleep 100000
|
${nettools}/sbin/ifconfig "$name" "$ipAddress" $extraFlags || true
|
||||||
|
fi
|
||||||
stop script
|
|
||||||
for i in $(cd /sys/class/net && ls -d *); do
|
done
|
||||||
echo "Taking down network device $i..."
|
|
||||||
${nettools}/sbin/ifconfig $i down || true
|
# Set the nameservers.
|
||||||
|
if test -n "${toString cfg.nameservers}"; then
|
||||||
|
rm -f /etc/resolv.conf
|
||||||
|
if test -n "${cfg.domain}"; then
|
||||||
|
echo "domain ${cfg.domain}" >> /etc/resolv.conf
|
||||||
|
fi
|
||||||
|
for i in ${toString cfg.nameservers}; do
|
||||||
|
echo "nameserver $i" >> /etc/resolv.conf
|
||||||
done
|
done
|
||||||
end script
|
fi
|
||||||
'';
|
|
||||||
}];
|
# Set the default gateway.
|
||||||
};
|
if test -n "${cfg.defaultGateway}"; then
|
||||||
|
${nettools}/sbin/route add default gw "${cfg.defaultGateway}" || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run any user-specified commands.
|
||||||
|
${bash}/bin/sh ${writeText "local-net-cmds" cfg.localCommands} || true
|
||||||
|
|
||||||
|
end script
|
||||||
|
|
||||||
|
# Hack: Upstart doesn't yet support what we want: a service that
|
||||||
|
# doesn't have a running process associated with it.
|
||||||
|
respawn sleep 100000
|
||||||
|
|
||||||
|
stop script
|
||||||
|
for i in $(cd /sys/class/net && ls -d *); do
|
||||||
|
echo "Taking down network device $i..."
|
||||||
|
${nettools}/sbin/ifconfig $i down || true
|
||||||
|
done
|
||||||
|
end script
|
||||||
|
'';
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,84 +0,0 @@
|
||||||
{pkgs, config, ...}:
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (pkgs.lib) mkOption mergeOneOption;
|
|
||||||
in
|
|
||||||
|
|
||||||
{
|
|
||||||
|
|
||||||
boot = {
|
|
||||||
|
|
||||||
extraTTYs = mkOption {
|
|
||||||
default = [];
|
|
||||||
example = [8 9];
|
|
||||||
description = "
|
|
||||||
Tty (virtual console) devices, in addition to the consoles on
|
|
||||||
which mingetty and syslogd run, that must be initialised.
|
|
||||||
Only useful if you have some program that you want to run on
|
|
||||||
some fixed console. For example, the NixOS installation CD
|
|
||||||
opens the manual in a web browser on console 7, so it sets
|
|
||||||
<option>boot.extraTTYs</option> to <literal>[7]</literal>.
|
|
||||||
";
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
networking = {
|
|
||||||
|
|
||||||
hostName = mkOption {
|
|
||||||
default = "nixos";
|
|
||||||
description = "
|
|
||||||
The name of the machine. Leave it empty if you want to obtain
|
|
||||||
it from a DHCP server (if using DHCP).
|
|
||||||
";
|
|
||||||
};
|
|
||||||
|
|
||||||
nativeIPv6 = mkOption {
|
|
||||||
default = false;
|
|
||||||
description = "
|
|
||||||
Whether to use IPv6 even though gw6c is not used. For example,
|
|
||||||
for Postfix.
|
|
||||||
";
|
|
||||||
};
|
|
||||||
|
|
||||||
defaultGateway = mkOption {
|
|
||||||
default = "";
|
|
||||||
example = "131.211.84.1";
|
|
||||||
description = "
|
|
||||||
The default gateway. It can be left empty if it is auto-detected through DHCP.
|
|
||||||
";
|
|
||||||
};
|
|
||||||
|
|
||||||
nameservers = mkOption {
|
|
||||||
default = [];
|
|
||||||
example = ["130.161.158.4" "130.161.33.17"];
|
|
||||||
description = "
|
|
||||||
The list of nameservers. It can be left empty if it is auto-detected through DHCP.
|
|
||||||
";
|
|
||||||
};
|
|
||||||
|
|
||||||
domain = mkOption {
|
|
||||||
default = "";
|
|
||||||
example = "home";
|
|
||||||
description = "
|
|
||||||
The domain. It can be left empty if it is auto-detected through DHCP.
|
|
||||||
";
|
|
||||||
};
|
|
||||||
|
|
||||||
localCommands = mkOption {
|
|
||||||
default = "";
|
|
||||||
example = "text=anything; echo You can put $text here.";
|
|
||||||
description = "
|
|
||||||
Shell commands to be executed at the end of the
|
|
||||||
<literal>network-interfaces</literal> Upstart job. Note that if
|
|
||||||
you are using DHCP to obtain the network configuration,
|
|
||||||
interfaces may not be fully configured yet.
|
|
||||||
";
|
|
||||||
};
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
require = import ../modules/module-list.nix;
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue