Update all legacy-style modules

I.e., modules that use "require = [options]".  Nowadays that should be
written as

  {
    options = { ... };
    config = { ... };
  };

Also, use "imports" instead of "require" in places where we actually
import another module.
This commit is contained in:
Eelco Dolstra 2013-09-04 13:05:09 +02:00
parent 3a23e6dd31
commit 17457297cb
54 changed files with 1827 additions and 1934 deletions

View File

@ -2,11 +2,20 @@
with pkgs.lib;
###### interface
let
glibcLocales = pkgs.glibcLocales.override {
allLocales = any (x: x == "all") config.i18n.supportedLocales;
locales = config.i18n.supportedLocales;
};
in
{
###### interface
options = {
i18n = {
defaultLocale = mkOption {
default = "en_US.UTF-8";
@ -53,17 +62,10 @@ let
};
###### implementation
glibcLocales = pkgs.glibcLocales.override {
allLocales = any (x: x == "all") config.i18n.supportedLocales;
locales = config.i18n.supportedLocales;
};
in
{
require = options;
config = {
environment.systemPackages = [ glibcLocales ];
@ -80,4 +82,6 @@ in
LANG=${config.i18n.defaultLocale}
'';
};
};
}

View File

@ -1,12 +1,18 @@
{pkgs, config, ...}:
{ config, pkgs, ... }:
with pkgs.lib;
###### interface
let
inherit (pkgs.lib) mkOption mkIf;
cfg = config.krb5;
in
{
###### interface
options = {
krb5 = {
enable = mkOption {
@ -35,20 +41,16 @@ let
};
};
};
in
###### implementation
mkIf config.krb5.enable {
require = [
options
];
config = mkIf config.krb5.enable {
environment = {
systemPackages = [ pkgs.krb5 ];
etc = [
{ source = pkgs.writeText "krb5.conf"
environment.systemPackages = [ pkgs.krb5 ];
environment.etc."krb5.conf".text =
''
[libdefaults]
default_realm = ${cfg.defaultRealm}
@ -186,7 +188,6 @@ mkIf config.krb5.enable {
krb4_convert = true
krb4_get_tickets = false
[appdefaults]
pam = {
debug = false
@ -197,9 +198,7 @@ mkIf config.krb5.enable {
initial_timeout = 1
}
'';
target = "krb5.conf";
}
];
};
}

View File

@ -1,150 +1,12 @@
{pkgs, config, ...}:
{ config, pkgs, ... }:
with pkgs.lib;
with pkgs;
###### interface
let
inherit mkOption mkIf optionalString stringAfter singleton;
cfg = config.users.ldap;
options = {
users = {
ldap = {
enable = mkOption {
default = false;
description = "
Whether to enable authentication against an LDAP server.
";
};
server = mkOption {
example = "ldap://ldap.example.org/";
description = "
The URL of the LDAP server.
";
};
base = mkOption {
example = "dc=example,dc=org";
description = "
The distinguished name of the search base.
";
};
useTLS = mkOption {
default = false;
description = "
If enabled, use TLS (encryption) over an LDAP (port 389)
connection. The alternative is to specify an LDAPS server (port
636) in <option>users.ldap.server</option> or to forego
security.
";
};
timeLimit = mkOption {
default = 0;
type = types.int;
description = "
Specifies the time limit (in seconds) to use when performing
searches. A value of zero (0), which is the default, is to
wait indefinitely for searches to be completed.
";
};
daemon = {
enable = mkOption {
default = false;
description = ''
Whether to let the nslcd daemon (nss-pam-ldapd) handle the
LDAP lookups for NSS and PAM. This can improve performance,
and if you need to bind to the LDAP server with a password,
it increases security, since only the nslcd user needs to
have access to the bindpw file, not everyone that uses NSS
and/or PAM. If this option is enabled, a local nscd user is
created automatically, and the nslcd service is started
automatically when the network get up.
'';
};
extraConfig = mkOption {
default = "";
type = types.string;
description = ''
Extra configuration options that will be added verbatim at
the end of the nslcd configuration file (nslcd.conf).
'' ;
} ;
};
bind = {
distinguishedName = mkOption {
default = "";
example = "cn=admin,dc=example,dc=com";
type = types.string;
description = "
The distinguished name to bind to the LDAP server with. If this
is not specified, an anonymous bind will be done.
";
};
password = mkOption {
default = "/etc/ldap/bind.password";
type = types.string;
description = "
The path to a file containing the credentials to use when binding
to the LDAP server (if not binding anonymously).
";
};
timeLimit = mkOption {
default = 30;
type = types.int;
description = "
Specifies the time limit (in seconds) to use when connecting
to the directory server. This is distinct from the time limit
specified in <literal>users.ldap.timeLimit</literal> and affects
the initial server connection only.
";
};
policy = mkOption {
default = "hard_open";
type = types.string;
description = "
Specifies the policy to use for reconnecting to an unavailable
LDAP server. The default is <literal>hard_open</literal>, which
reconnects if opening the connection to the directory server
failed. By contrast, <literal>hard_init</literal> reconnects if
initializing the connection failed. Initializing may not
actually contact the directory server, and it is possible that
a malformed configuration file will trigger reconnection. If
<literal>soft</literal> is specified, then
<literal>nss_ldap</literal> will return immediately on server
failure. All hard reconnect policies block with exponential
backoff before retrying.
";
};
};
extraConfig = mkOption {
default = "" ;
type = types.string ;
description = ''
Extra configuration options that will be added verbatim at
the end of the ldap configuration file (ldap.conf).
If <literal>users.ldap.daemon</literal> is enabled, this
configuration will not be used. In that case, use
<literal>users.ldap.daemon.extraConfig</literal> instead.
'' ;
};
};
};
};
# Careful: OpenLDAP seems to be very picky about the indentation of
# this file. Directives HAVE to start in the first column!
ldapConfig = {
@ -186,11 +48,143 @@ let
in
{
###### interface
options = {
users.ldap = {
enable = mkOption {
default = false;
description = "Whether to enable authentication against an LDAP server.";
};
server = mkOption {
example = "ldap://ldap.example.org/";
description = "The URL of the LDAP server.";
};
base = mkOption {
example = "dc=example,dc=org";
description = "The distinguished name of the search base.";
};
useTLS = mkOption {
default = false;
description = ''
If enabled, use TLS (encryption) over an LDAP (port 389)
connection. The alternative is to specify an LDAPS server (port
636) in <option>users.ldap.server</option> or to forego
security.
'';
};
timeLimit = mkOption {
default = 0;
type = types.int;
description = ''
Specifies the time limit (in seconds) to use when performing
searches. A value of zero (0), which is the default, is to
wait indefinitely for searches to be completed.
'';
};
daemon = {
enable = mkOption {
default = false;
description = ''
Whether to let the nslcd daemon (nss-pam-ldapd) handle the
LDAP lookups for NSS and PAM. This can improve performance,
and if you need to bind to the LDAP server with a password,
it increases security, since only the nslcd user needs to
have access to the bindpw file, not everyone that uses NSS
and/or PAM. If this option is enabled, a local nscd user is
created automatically, and the nslcd service is started
automatically when the network get up.
'';
};
extraConfig = mkOption {
default = "";
type = types.string;
description = ''
Extra configuration options that will be added verbatim at
the end of the nslcd configuration file (nslcd.conf).
'' ;
} ;
};
bind = {
distinguishedName = mkOption {
default = "";
example = "cn=admin,dc=example,dc=com";
type = types.string;
description = ''
The distinguished name to bind to the LDAP server with. If this
is not specified, an anonymous bind will be done.
'';
};
password = mkOption {
default = "/etc/ldap/bind.password";
type = types.string;
description = ''
The path to a file containing the credentials to use when binding
to the LDAP server (if not binding anonymously).
'';
};
timeLimit = mkOption {
default = 30;
type = types.int;
description = ''
Specifies the time limit (in seconds) to use when connecting
to the directory server. This is distinct from the time limit
specified in <literal>users.ldap.timeLimit</literal> and affects
the initial server connection only.
'';
};
policy = mkOption {
default = "hard_open";
type = types.string;
description = ''
Specifies the policy to use for reconnecting to an unavailable
LDAP server. The default is <literal>hard_open</literal>, which
reconnects if opening the connection to the directory server
failed. By contrast, <literal>hard_init</literal> reconnects if
initializing the connection failed. Initializing may not
actually contact the directory server, and it is possible that
a malformed configuration file will trigger reconnection. If
<literal>soft</literal> is specified, then
<literal>nss_ldap</literal> will return immediately on server
failure. All hard reconnect policies block with exponential
backoff before retrying.
'';
};
};
extraConfig = mkOption {
default = "";
type = types.string;
description = ''
Extra configuration options that will be added verbatim at
the end of the ldap configuration file (ldap.conf).
If <literal>users.ldap.daemon</literal> is enabled, this
configuration will not be used. In that case, use
<literal>users.ldap.daemon.extraConfig</literal> instead.
'' ;
};
};
};
###### implementation
mkIf cfg.enable {
require = [
options
];
config = mkIf cfg.enable {
environment.etc = if cfg.daemon.enable then [nslcdConfig] else [ldapConfig];
@ -221,6 +215,7 @@ mkIf cfg.enable {
};
systemd.services = mkIf cfg.daemon.enable {
nslcd = {
wantedBy = [ "nss-user-lookup.target" ];
before = [ "nss-user-lookup.target" ];
@ -244,5 +239,8 @@ mkIf cfg.enable {
Restart = "always";
};
};
};
};
}

View File

@ -8,6 +8,10 @@ let
cfg = config.networking;
in
{
options = {
networking.extraHosts = pkgs.lib.mkOption {
@ -32,10 +36,7 @@ let
};
in
{
require = [options];
config = {
environment.etc =
{ # /etc/services: TCP/UDP port assignments.
@ -81,4 +82,7 @@ in
# services that depend on IP connectivity (like ntpd) should be
# pulled in by this target.
systemd.targets.ip-up.description = "Services Requiring IP Connectivity";
};
}

View File

@ -6,17 +6,22 @@ with pkgs.lib;
let
inherit (config.services.avahi) nssmdns;
in
{
options = {
# NSS modules. Hacky!
system.nssModules = mkOption {
internal = true;
default = [];
description = "
description = ''
Search path for NSS (Name Service Switch) modules. This allows
several DNS resolution methods to be specified via
<filename>/etc/nsswitch.conf</filename>.
";
'';
merge = mergeListOption;
apply = list:
{
@ -27,12 +32,7 @@ let
};
inherit (config.services.avahi) nssmdns;
in
{
require = [ options ];
config = {
environment.etc =
[ # Name Service Switch configuration file. Required by the C library.
@ -57,4 +57,6 @@ in
# a valid IP address. It returns all locally configured IP
# addresses, or ::1 and 127.0.0.2 as fallbacks.
system.nssModules = [ pkgs.systemd ];
};
}

View File

@ -54,7 +54,9 @@ let
extraManpages
];
in
{
options = {
environment = {
@ -78,9 +80,7 @@ let
# to work.
default = [];
example = ["/"];
description = "
Lists directories to be symlinked in `/run/current-system/sw'.
";
description = "List of directories to be symlinked in `/run/current-system/sw'.";
};
};
@ -120,15 +120,12 @@ let
};
in
{
require = [ options ];
config = {
environment.systemPackages = requiredPackages;
environment.pathsToLink = [
"/bin"
environment.pathsToLink =
[ "/bin"
"/etc/xdg"
"/info"
"/lib"
@ -140,4 +137,6 @@ in
"/share/terminfo"
"/share/man"
];
};
}

View File

@ -1,43 +1,34 @@
{pkgs, config, ...}:
###### interface
let
inherit (pkgs.lib) mkOption mkIf;
options = {
environment = {
unixODBCDrivers = mkOption {
default = [];
example = "map (x : x.ini) (with pkgs.unixODBCDrivers; [ mysql psql psqlng ] )";
description = ''
specifies unix odbc drivers to be registered at /etc/odbcinst.ini.
Maybe you also want to add pkgs.unixODBC to the system path to get a
command line client t connnect to odbc databases.
'';
};
};
};
in
###### implementation
{ config, pkgs, ... }:
with pkgs.lib;
# unixODBC drivers (this solution is not perfect.. Because the user has to
# ask the admin to add a driver.. but it's simple and works
mkIf (config.environment.unixODBCDrivers != []) {
{
###### interface
require = [
options
];
environment = {
etc = [
{ source =
let inis = config.environment.unixODBCDrivers;
in pkgs.writeText "odbcinst.ini" (pkgs.lib.concatStringsSep "\n" inis);
target = "odbcinst.ini";
}
];
options = {
environment.unixODBCDrivers = mkOption {
default = [];
example = literalExample "map (x : x.ini) (with pkgs.unixODBCDrivers; [ mysql psql psqlng ] )";
description = ''
Specifies Unix ODBC drivers to be registered in
<filename>/etc/odbcinst.ini</filename>. You may also want to
add <literal>pkgs.unixODBC</literal> to the system path to get
a command line client to connnect to ODBC databases.
'';
};
};
###### implementation
config = mkIf (config.environment.unixODBCDrivers != []) {
environment.etc."odbcinst.ini".text =
let inis = config.environment.unixODBCDrivers;
in pkgs.lib.concatStringsSep "\n" inis;
};
}

View File

@ -1,13 +1,22 @@
{pkgs, config, ...}:
{ config, pkgs, ... }:
with pkgs.lib;
###### interface
let
inherit (pkgs.lib) mkOption
mergeEnableOption mergeListOption;
pcmciaUtils = pkgs.pcmciaUtils.passthru.function {
inherit (config.hardware.pcmcia) firmware config;
};
in
{
###### interface
options = {
hardware = {
pcmcia = {
hardware.pcmcia = {
enable = mkOption {
default = false;
merge = mergeEnableOption;
@ -32,30 +41,19 @@ let
'';
};
};
};
};
in
###### implementation
let
inherit (pkgs.lib) mkIf;
pcmciaUtils = pkgs.pcmciaUtils.passthru.function {
inherit (config.hardware.pcmcia) firmware config;
};
in
mkIf config.hardware.pcmcia.enable {
require = [
# ../upstart-jobs/udev.nix
# ? # config.environment.extraPackages
options
];
config = mkIf config.hardware.pcmcia.enable {
boot.kernelModules = [ "pcmcia" ];
services.udev.packages = [ pcmciaUtils ];
environment.systemPackages = [ pcmciaUtils ];
};
}

View File

@ -6,7 +6,7 @@
with pkgs.lib;
{
require =
imports =
[ ./memtest.nix
./channel.nix
./iso-image.nix

View File

@ -1,7 +1,7 @@
{ config, pkgs, ... }:
{
require = [ ./installation-cd-minimal.nix ];
imports = [ ./installation-cd-minimal.nix ];
boot.kernelPackages = pkgs.linuxPackages_3_9;
boot.vesa = false;

View File

@ -6,10 +6,7 @@
with pkgs.lib;
{
require = [
./installation-cd-base.nix
../../profiles/graphical.nix
];
imports = [ ./installation-cd-base.nix ../../profiles/graphical.nix ];
# Provide wicd for easy wireless configuration.
#networking.wicd.enable = true;

View File

@ -1,7 +1,7 @@
{ config, pkgs, ... }:
{
require = [ ./installation-cd-minimal.nix ];
imports = [ ./installation-cd-minimal.nix ];
boot.kernelPackages = pkgs.linuxPackages_3_10;
boot.vesa = false;

View File

@ -4,7 +4,7 @@
{ config, pkgs, ... }:
{
require =
imports =
[ ./installation-cd-base.nix
../../profiles/minimal.nix
];

View File

@ -1,7 +1,7 @@
{ config, pkgs, ... }:
{
require = [ ./installation-cd-graphical.nix ];
imports = [ ./installation-cd-graphical.nix ];
boot.kernelPackages = pkgs.linuxPackages_3_10;
boot.vesa = false;

View File

@ -8,6 +8,79 @@ with pkgs.lib;
let
# The Grub image.
grubImage = pkgs.runCommand "grub_eltorito" {}
''
${pkgs.grub2}/bin/grub-mkimage -O i386-pc -o tmp biosdisk iso9660 help linux linux16 chain png jpeg echo gfxmenu reboot
cat ${pkgs.grub2}/lib/grub/*/cdboot.img tmp > $out
''; # */
# The configuration file for Grub.
grubCfg =
''
set default=${builtins.toString config.boot.loader.grub.default}
set timeout=${builtins.toString config.boot.loader.grub.timeout}
if loadfont /boot/grub/unicode.pf2; then
set gfxmode=640x480
insmod gfxterm
insmod vbe
terminal_output gfxterm
insmod png
if background_image /boot/grub/splash.png; then
set color_normal=white/black
set color_highlight=black/white
else
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
fi
fi
${config.boot.loader.grub.extraEntries}
'';
# The efi boot image
efiImg = pkgs.runCommand "efi-image_eltorito" {}
''
#Let's hope 10M is enough
dd bs=2048 count=5120 if=/dev/zero of="$out"
${pkgs.dosfstools}/sbin/mkfs.vfat "$out"
${pkgs.mtools}/bin/mmd -i "$out" efi
${pkgs.mtools}/bin/mmd -i "$out" efi/boot
${pkgs.mtools}/bin/mmd -i "$out" efi/nixos
${pkgs.mtools}/bin/mmd -i "$out" loader
${pkgs.mtools}/bin/mmd -i "$out" loader/entries
${pkgs.mtools}/bin/mcopy -v -i "$out" \
${pkgs.gummiboot}/lib/gummiboot/gummiboot${targetArch}.efi \
::efi/boot/boot${targetArch}.efi
${pkgs.mtools}/bin/mcopy -v -i "$out" \
${config.boot.kernelPackages.kernel + "/bzImage"} ::bzImage
${pkgs.mtools}/bin/mcopy -v -i "$out" \
${config.system.build.initialRamdisk + "/initrd"} ::efi/nixos/initrd
echo "title NixOS LiveCD" > boot-params
echo "linux /bzImage" >> boot-params
echo "initrd /efi/nixos/initrd" >> boot-params
echo "options init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams}" >> boot-params
${pkgs.mtools}/bin/mcopy -v -i "$out" boot-params ::loader/entries/nixos-livecd.conf
echo "default nixos-livecd" > boot-params
echo "timeout 5" >> boot-params
${pkgs.mtools}/bin/mcopy -v -i "$out" boot-params ::loader/loader.conf
'';
targetArch = if pkgs.stdenv.isi686 then
"ia32"
else if pkgs.stdenv.isx86_64 then
"x64"
else
throw "Unsupported architecture";
in
{
options = {
isoImage.isoName = mkOption {
@ -84,80 +157,7 @@ let
};
# The Grub image.
grubImage = pkgs.runCommand "grub_eltorito" {}
''
${pkgs.grub2}/bin/grub-mkimage -O i386-pc -o tmp biosdisk iso9660 help linux linux16 chain png jpeg echo gfxmenu reboot
cat ${pkgs.grub2}/lib/grub/*/cdboot.img tmp > $out
''; # */
# The configuration file for Grub.
grubCfg =
''
set default=${builtins.toString config.boot.loader.grub.default}
set timeout=${builtins.toString config.boot.loader.grub.timeout}
if loadfont /boot/grub/unicode.pf2; then
set gfxmode=640x480
insmod gfxterm
insmod vbe
terminal_output gfxterm
insmod png
if background_image /boot/grub/splash.png; then
set color_normal=white/black
set color_highlight=black/white
else
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
fi
fi
${config.boot.loader.grub.extraEntries}
'';
# The efi boot image
efiImg = pkgs.runCommand "efi-image_eltorito" {}
''
#Let's hope 10M is enough
dd bs=2048 count=5120 if=/dev/zero of="$out"
${pkgs.dosfstools}/sbin/mkfs.vfat "$out"
${pkgs.mtools}/bin/mmd -i "$out" efi
${pkgs.mtools}/bin/mmd -i "$out" efi/boot
${pkgs.mtools}/bin/mmd -i "$out" efi/nixos
${pkgs.mtools}/bin/mmd -i "$out" loader
${pkgs.mtools}/bin/mmd -i "$out" loader/entries
${pkgs.mtools}/bin/mcopy -v -i "$out" \
${pkgs.gummiboot}/lib/gummiboot/gummiboot${targetArch}.efi \
::efi/boot/boot${targetArch}.efi
${pkgs.mtools}/bin/mcopy -v -i "$out" \
${config.boot.kernelPackages.kernel + "/bzImage"} ::bzImage
${pkgs.mtools}/bin/mcopy -v -i "$out" \
${config.system.build.initialRamdisk + "/initrd"} ::efi/nixos/initrd
echo "title NixOS LiveCD" > boot-params
echo "linux /bzImage" >> boot-params
echo "initrd /efi/nixos/initrd" >> boot-params
echo "options init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams}" >> boot-params
${pkgs.mtools}/bin/mcopy -v -i "$out" boot-params ::loader/entries/nixos-livecd.conf
echo "default nixos-livecd" > boot-params
echo "timeout 5" >> boot-params
${pkgs.mtools}/bin/mcopy -v -i "$out" boot-params ::loader/loader.conf
'';
targetArch = if pkgs.stdenv.isi686 then
"ia32"
else if pkgs.stdenv.isx86_64 then
"x64"
else
throw "Unsupported architecture";
in
{
require = options;
config = {
boot.loader.grub.version = 2;
@ -308,4 +308,6 @@ in
# contents of the CD to a bootable USB stick. Need unionfs-fuse for union mounts
boot.initrd.supportedFilesystems = [ "vfat" "unionfs-fuse" ];
};
}

View File

@ -1,7 +1,7 @@
{ config, pkgs, ... }:
{
require = [./installation-cd-base.nix];
imports = [ ./installation-cd-base.nix ];
# Build the build-time dependencies of this configuration on the DVD
# to speed up installation.

View File

@ -14,13 +14,8 @@ let
''
{ config, pkgs, ... }:
{
require = [ ];
# Add your own options below
# E.g.,
{ # Add your own options below, e.g.:
# services.openssh.enable = true;
nixpkgs.config.platform = pkgs.platforms.fuloong2f_n32;
}
'';
@ -45,11 +40,7 @@ let
in
{
require =
[
./system-tarball.nix
];
imports = [ ./system-tarball.nix ];
# Disable some other stuff we don't need.
security.sudo.enable = false;

View File

@ -65,7 +65,7 @@ let
in
{
require =
imports =
[ ./system-tarball.nix
# Profiles of this basic installation.

View File

@ -18,8 +18,6 @@ let
{ config, pkgs, ... }:
{
require = [ ];
# Add your own options below and run "nixos-rebuild switch".
# E.g.,
# services.openssh.enable = true;
@ -39,10 +37,7 @@ let
in
{
require =
[
./system-tarball.nix
];
imports = [ ./system-tarball.nix ];
# Disable some other stuff we don't need.
security.sudo.enable = false;

View File

@ -8,6 +8,11 @@ with pkgs.lib;
let
versionFile = pkgs.writeText "nixos-version" config.system.nixosVersion;
in
{
options = {
tarball.contents = mkOption {
example =
@ -31,12 +36,7 @@ let
};
versionFile = pkgs.writeText "nixos-version" config.system.nixosVersion;
in
{
require = options;
config = {
# In stage 1 of the boot, mount the CD/DVD as the root FS by label
# so that we don't need to know its device.
@ -86,4 +86,7 @@ in
touch /etc/NIXOS
${config.environment.nix}/bin/nix-env -p /nix/var/nix/profiles/system --set /run/current-system
'';
};
}

View File

@ -8,7 +8,7 @@ my @attrs = ();
my @kernelModules = ();
my @initrdKernelModules = ();
my @modulePackages = ();
my @requires = ("<nixos/modules/installer/scan/not-detected.nix>");
my @imports = ("<nixos/modules/installer/scan/not-detected.nix>");
sub debug {
@ -227,7 +227,7 @@ my $initrdKernelModules = toNixExpr(removeDups @initrdKernelModules);
my $kernelModules = toNixExpr(removeDups @kernelModules);
my $modulePackages = toNixExpr(removeDups @modulePackages);
my $attrs = multiLineList(" ", removeDups @attrs);
my $requires = multiLineList(" ", removeDups @requires);
my $imports = multiLineList(" ", removeDups @imports);
print <<EOF ;
@ -236,7 +236,7 @@ print <<EOF ;
{ config, pkgs, ... }:
{
require = [$requires ];
imports = [$imports ];
boot.initrd.kernelModules = [$initrdKernelModules ];
boot.kernelModules = [$kernelModules ];

View File

@ -215,7 +215,7 @@ if $generate; then
{ config, pkgs, ... }:
{
require =
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];

View File

@ -1,7 +1,7 @@
{ config, pkgs, ... }:
{
require =
imports =
[ ../virtualisation/virtualbox-image.nix
../installer/cd-dvd/channel.nix
../profiles/demo.nix

View File

@ -3,8 +3,7 @@
{ config, pkgs, ... }:
let
{
options = {
ids.uids = pkgs.lib.mkOption {
@ -21,10 +20,8 @@ let
};
in
{
require = options;
config = {
ids.uids = {
root = 0;
@ -198,4 +195,6 @@ in
nogroup = 65534;
};
};
}

View File

@ -3,8 +3,7 @@
{ config, pkgs, ... }:
let
{
options = {
passthru = pkgs.lib.mkOption {
description = ''
@ -13,9 +12,4 @@ options = {
'';
};
};
in
{
require = options;
}

View File

@ -224,7 +224,6 @@
#./services/x11/window-managers/compiz.nix
./services/x11/window-managers/default.nix
./services/x11/window-managers/icewm.nix
./services/x11/window-managers/kwm.nix
./services/x11/window-managers/metacity.nix
./services/x11/window-managers/none.nix
./services/x11/window-managers/twm.nix

View File

@ -49,7 +49,7 @@
# Include lots of firmware.
hardware.enableAllFirmware = true;
require =
imports =
[ ../hardware/network/zydas-zd1211.nix ];
}

View File

@ -47,7 +47,7 @@ let
{ config, pkgs, ... }:
{
require = [ ${toString config.installer.cloneConfigIncludes} ];
imports = [ ${toString config.installer.cloneConfigIncludes} ];
}
'';

View File

@ -1,7 +1,7 @@
{ config, pkgs, ... }:
{
require = [ ./graphical.nix ];
imports = [ ./graphical.nix ];
users.extraUsers.demo =
{ description = "Demo user account";

View File

@ -31,6 +31,9 @@ let
mapAttrsFlatten (k: v: "alias ${k}='${v}'") cfg.shellAliases
);
in
{
options = {
environment.promptInit = mkOption {
@ -87,36 +90,28 @@ let
};
in
{
require = [options];
config = {
environment.etc =
[ { # Script executed when the shell starts as a login shell.
source = pkgs.substituteAll {
# Script executed when the shell starts as a login shell.
environment.etc."profile".source =
pkgs.substituteAll {
src = ./profile.sh;
wrapperDir = config.security.wrapperDir;
inherit (cfg) shellInit;
};
target = "profile";
}
{ # /etc/bashrc: executed every time an interactive bash
# /etc/bashrc: executed every time an interactive bash
# starts. Sources /etc/profile to ensure that the system
# environment is configured properly.
source = pkgs.substituteAll {
environment.etc."bashrc".source =
pkgs.substituteAll {
src = ./bashrc.sh;
inherit (cfg) interactiveShellInit;
};
target = "bashrc";
}
{ # Configuration for readline in bash.
source = ./inputrc;
target = "inputrc";
}
];
# Configuration for readline in bash.
environment.etc."inputrc".source = ./inputrc;
environment.shellAliases =
{ ls = "ls --color=tty";
@ -153,4 +148,7 @@ in
"/etc/bash_completion.d"
"/share/bash-completion"
];
};
}

View File

@ -9,6 +9,12 @@ with pkgs.lib;
let
cfg = config.networking.defaultMailServer;
in
{
options = {
networking.defaultMailServer = {
@ -16,82 +22,78 @@ let
directDelivery = mkOption {
default = false;
example = true;
description = "
description = ''
Use the trivial Mail Transfer Agent (MTA)
<command>ssmtp</command> package to allow programs to send
e-mail. If you don't want to run a ``real'' MTA like
e-mail. If you don't want to run a real MTA like
<command>sendmail</command> or <command>postfix</command> on
your machine, set this option to <literal>true</literal>, and
set the option
<option>networking.defaultMailServer.hostName</option> to the
host name of your preferred mail server.
";
'';
};
hostName = mkOption {
example = "mail.example.org";
description = "
description = ''
The host name of the default mail server to use to deliver
e-mail.
";
'';
};
domain = mkOption {
default = "";
example = "example.org";
description = "
description = ''
The domain from which mail will appear to be sent.
";
'';
};
useTLS = mkOption {
default = false;
example = true;
description = "
description = ''
Whether TLS should be used to connect to the default mail
server.
";
'';
};
useSTARTTLS = mkOption {
default = false;
example = true;
description = "
description = ''
Whether the STARTTLS should be used to connect to the default
mail server. (This is needed for TLS-capable mail servers
running on the default SMTP port 25.)
";
'';
};
authUser = mkOption {
default = "";
example = "foo@example.org";
description = "
description = ''
Username used for SMTP auth. Leave blank to disable.
";
'';
};
authPass = mkOption {
default = "";
example = "correctHorseBatteryStaple";
description = "
description = ''
Password used for SMTP auth. (STORED PLAIN TEXT, WORLD-READABLE IN NIX STORE)
";
'';
};
};
};
cfg = config.networking.defaultMailServer;
in
config = mkIf cfg.directDelivery {
mkIf cfg.directDelivery {
require = [options];
environment.etc =
[ { source = pkgs.writeText "ssmtp.conf" ''
environment.etc."ssmtp/ssmtp.conf".text =
''
MailHub=${cfg.hostName}
FromLineOverride=YES
${if cfg.domain != "" then "rewriteDomain=${cfg.domain}" else ""}
@ -101,9 +103,9 @@ mkIf cfg.directDelivery {
${if cfg.authUser != "" then "AuthUser=${cfg.authUser}" else ""}
${if cfg.authPass != "" then "AuthPass=${cfg.authPass}" else ""}
'';
target = "ssmtp/ssmtp.conf";
}
];
environment.systemPackages = [pkgs.ssmtp];
};
}

View File

@ -1,47 +1,42 @@
{pkgs, config, ...}:
{ config, pkgs, ... }:
with pkgs.lib;
let
inherit (pkgs.lib) mkOption mkIf;
cfg = config.services.xserver.desktopManager.gnome;
gnome = pkgs.gnome;
options = { services = { xserver = { desktopManager = {
in
gnome = {
enable = mkOption {
{
options = {
services.xserver.desktopManager.gnome.enable = mkOption {
default = false;
example = true;
description = "Enable a gnome terminal as a desktop manager.";
};
};
}; }; }; };
in
config = mkIf cfg.enable {
mkIf cfg.enable {
require = options;
services = {
xserver = {
desktopManager = {
session = [{
name = "gnome";
services.xserver.desktopManager.session = singleton
{ name = "gnome";
start = ''
${gnome.gnometerminal}/bin/gnome-terminal -ls &
waitPID=$!
'';
}];
};
};
};
environment = {
x11Packages = [
gnome.gnometerminal
environment.systemPackages =
[ gnome.gnometerminal
gnome.GConf
gnome.gconfeditor
];
};
}

View File

@ -1,10 +1,14 @@
{pkgs, config, ...}:
{ config, pkgs, ... }:
with pkgs.lib;
let
inherit (pkgs.lib) mkOption mkIf;
cfg = config.services.xserver.desktopManager.xterm;
in
{
options = {
services.xserver.desktopManager.xterm.enable = mkOption {
@ -15,30 +19,18 @@ let
};
in
config = mkIf cfg.enable {
mkIf cfg.enable {
require = options;
services = {
xserver = {
desktopManager = {
session = [{
name = "xterm";
services.xserver.desktopManager.session = singleton
{ name = "xterm";
start = ''
${pkgs.xterm}/bin/xterm -ls &
waitPID=$!
'';
}];
};
};
environment.systemPackages = [ pkgs.xterm ];
};
environment = {
x11Packages = [
pkgs.xterm
];
};
}

View File

@ -1,15 +1,15 @@
{pkgs, config, ...}:
{ config, pkgs, ... }:
with pkgs.lib;
let
inherit (pkgs.lib) mkOption mergeOneOption any;
cfg = config.services.xserver.windowManager;
in
{
imports = [
./compiz.nix
imports =
[ ./compiz.nix
./openbox.nix
./kwm.nix
./metacity.nix
./none.nix
./twm.nix
@ -20,6 +20,7 @@ in
];
options = {
services.xserver.windowManager = {
session = mkOption {
@ -28,11 +29,11 @@ in
name = "wmii";
start = "...";
}];
description = "
description = ''
Internal option used to add some common line to window manager
scripts before forwarding the value to the
<varname>displayManager</varname>.
";
'';
apply = map (d: d // {
manage = "window";
});
@ -41,9 +42,7 @@ in
default = mkOption {
default = "none";
example = "wmii";
description = "
Default window manager loaded if none have been chosen.
";
description = "Default window manager loaded if none have been chosen.";
merge = mergeOneOption;
apply = defaultWM:
if any (w: w.name == defaultWM) cfg.session then
@ -53,6 +52,7 @@ in
};
};
};
config = {

View File

@ -1,46 +0,0 @@
{pkgs, config, ...}:
let
inherit (pkgs.lib) mkOption mkIf;
cfg = config.services.xserver.windowManager.kwm;
option = { services = { xserver = { windowManager = {
kwm = {
enable = mkOption {
default = false;
example = true;
description = "Enable the kwm window manager.";
};
};
}; }; }; };
in
mkIf cfg.enable {
require = option;
services = {
xserver = {
windowManager = {
session = [{
name = "kwm";
start = "
${pkgs.kde3.kdebase}/bin/kwin &
waitPID=$!
";
}];
};
};
};
environment = {
x11Packages = [
pkgs.kde3.kdelibs
pkgs.kde3.kdebase
];
};
}

View File

@ -1,15 +1,19 @@
{pkgs, config, ...}:
{ config, pkgs, ... }:
with pkgs.lib;
let
inherit (pkgs.lib) mkOption mkIf;
cfg = config.services.xserver.windowManager.metacity;
xorg = config.services.xserver.package;
gnome = pkgs.gnome;
option = { services = { xserver = { windowManager = {
in
metacity = {
enable = mkOption {
{
options = {
services.xserver.windowManager.metacity.enable = mkOption {
default = false;
example = true;
description = "Enable the metacity window manager.";
@ -17,18 +21,10 @@ let
};
}; }; }; };
in
config = mkIf cfg.enable {
mkIf cfg.enable {
require = option;
services = {
xserver = {
windowManager = {
session = [{
name = "metacity";
services.xserver.windowManager.session = singleton
{ name = "metacity";
start = ''
env LD_LIBRARY_PATH=${xorg.libX11}/lib:${xorg.libXext}/lib:/usr/lib/
# !!! Hack: load the schemas for Metacity.
@ -37,13 +33,10 @@ mkIf cfg.enable {
${gnome.metacity}/bin/metacity &
waitPID=$!
'';
}];
};
};
environment.systemPackages = [ gnome.metacity ];
};
environment = {
x11Packages = [ gnome.metacity ];
};
}

View File

@ -1,27 +1,27 @@
{pkgs, config, ...}:
{ config, pkgs, ... }:
with pkgs.lib;
let
inherit (pkgs.lib) mkOption mkIf;
cfg = config.services.xserver.windowManager.wmii;
option = { services = { xserver = { windowManager = {
in
wmii = {
enable = mkOption {
{
options = {
services.xserver.windowManager.wmii.enable = mkOption {
default = false;
example = true;
description = "Enable the wmii window manager.";
};
};
}; }; }; };
in
config = mkIf cfg.enable {
mkIf cfg.enable {
require = option;
services = {
xserver = {
services.xserver.windowManager.session = singleton
# stop wmii by
# $wmiir xwrite /ctl quit
# this will cause wmii exiting with exit code 0
@ -32,23 +32,16 @@ mkIf cfg.enable {
# lost and all applications running on X will terminate.
# Another use case is kill -9 wmii; after rotating screen.
# Note: we don't like kill for that purpose. But it works (-> subject "wmii and xrandr" on mailinglist)
windowManager = {
session = [{
name = "wmii";
start = "
{ name = "wmii";
start = ''
while :; do
${pkgs.wmiiSnap}/bin/wmii && break
done
";
}];
'';
};
};
environment.systemPackages = [ pkgs.wmiiSnap ];
};
environment = {
x11Packages = [
pkgs.wmiiSnap
];
};
}

View File

@ -4,66 +4,6 @@ with pkgs.lib;
let
options = {
system.build = mkOption {
default = {};
description = ''
Attribute set of derivations used to setup the system.
'';
};
nesting.children = mkOption {
default = [];
description = ''
Additional configurations to build.
'';
};
nesting.clone = mkOption {
default = [];
description = ''
Additional configurations to build based on the current
configuration which is has a lower priority.
'';
};
system.boot.loader.id = mkOption {
default = "";
description = ''
Id string of the used bootloader.
'';
};
system.boot.loader.kernelFile = mkOption {
default = pkgs.stdenv.platform.kernelTarget;
type = types.uniq types.string;
description = ''
Name of the kernel file to be passed to the bootloader.
'';
};
system.copySystemConfiguration = mkOption {
default = false;
description = ''
If enabled, copies the NixOS configuration file
<literal>$NIXOS_CONFIG</literal> (usually
<filename>/etc/nixos/configuration.nix</filename>)
to the system store path.
'';
};
system.extraSystemBuilderCmds = mkOption {
default = "";
internal = true;
merge = concatStringsSep "\n";
description = ''
This code will be added to the builder creating the system store path.
'';
};
};
# This attribute is responsible for creating boot entries for
# child configuration. They are only (directly) accessible
@ -176,8 +116,71 @@ let
};
in {
require = [options];
in
{
options = {
system.build = mkOption {
default = {};
description = ''
Attribute set of derivations used to setup the system.
'';
};
nesting.children = mkOption {
default = [];
description = ''
Additional configurations to build.
'';
};
nesting.clone = mkOption {
default = [];
description = ''
Additional configurations to build based on the current
configuration which is has a lower priority.
'';
};
system.boot.loader.id = mkOption {
default = "";
description = ''
Id string of the used bootloader.
'';
};
system.boot.loader.kernelFile = mkOption {
default = pkgs.stdenv.platform.kernelTarget;
type = types.uniq types.string;
description = ''
Name of the kernel file to be passed to the bootloader.
'';
};
system.copySystemConfiguration = mkOption {
default = false;
description = ''
If enabled, copies the NixOS configuration file
<literal>$NIXOS_CONFIG</literal> (usually
<filename>/etc/nixos/configuration.nix</filename>)
to the system store path.
'';
};
system.extraSystemBuilderCmds = mkOption {
default = "";
internal = true;
merge = concatStringsSep "\n";
description = ''
This code will be added to the builder creating the system store path.
'';
};
};
config = {
system.extraSystemBuilderCmds =
optionalString
@ -185,4 +188,7 @@ in {
"cp ${maybeEnv "NIXOS_CONFIG" "/etc/nixos/configuration.nix"} $out";
system.build.toplevel = system;
};
}

View File

@ -1,13 +1,26 @@
{pkgs, config, ...}:
{ config, pkgs, ... }:
with pkgs.lib;
###### interface
let
inherit (pkgs.lib) mkOption mkIf;
generationsDirBuilder = pkgs.substituteAll {
src = ./generations-dir-builder.sh;
isExecutable = true;
inherit (pkgs) bash;
path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep];
inherit (config.boot.loader.generationsDir) copyKernels;
};
# Temporary check, for nixos to cope both with nixpkgs stdenv-updates and trunk
platform = pkgs.stdenv.platform;
in
{
options = {
boot = {
loader = {
generationsDir = {
boot.loader.generationsDir = {
enable = mkOption {
default = false;
@ -34,37 +47,17 @@ let
/nix/store is not needed by the boot loader.
";
};
};
};
};
};
in
###### implementation
let
generationsDirBuilder = pkgs.substituteAll {
src = ./generations-dir-builder.sh;
isExecutable = true;
inherit (pkgs) bash;
path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep];
inherit (config.boot.loader.generationsDir) copyKernels;
};
# Temporary check, for nixos to cope both with nixpkgs stdenv-updates and trunk
platform = pkgs.stdenv.platform;
in
{
require = [
options
# config.system.build
# ../system/system-options.nix
];
config = mkIf config.boot.loader.generationsDir.enable {
system.build.installBootLoader = generationsDirBuilder;
system.boot.loader.id = "generationsDir";
system.boot.loader.kernelFile = platform.kernelTarget;
system = mkIf config.boot.loader.generationsDir.enable {
build.installBootLoader = generationsDirBuilder;
boot.loader.id = "generationsDir";
boot.loader.kernelFile = platform.kernelTarget;
};
}

View File

@ -1,30 +1,9 @@
{pkgs, config, ...}:
{ config, pkgs, ... }:
with pkgs.lib;
###### interface
let
inherit (pkgs.lib) mkOption mkIf;
options = {
boot = {
loader = {
raspberryPi = {
enable = mkOption {
default = false;
description = ''
Whether to create files with the system generations in
<literal>/boot</literal>.
<literal>/boot/old</literal> will hold files from old generations.
'';
};
};
};
};
};
in
###### implementation
let
builder = pkgs.substituteAll {
src = ./builder.sh;
isExecutable = true;
@ -34,18 +13,26 @@ let
};
platform = pkgs.stdenv.platform;
in
{
require = [
options
options = {
# config.system.build
# ../system/system-options.nix
];
boot.loader.raspberryPi.enable = mkOption {
default = false;
description = ''
Whether to create files with the system generations in
<literal>/boot</literal>.
<literal>/boot/old</literal> will hold files from old generations.
'';
};
system = mkIf config.boot.loader.raspberryPi.enable {
build.installBootLoader = builder;
boot.loader.id = "raspberrypi";
boot.loader.kernelFile = platform.kernelTarget;
};
config = mkIf config.boot.loader.raspberryPi.enable {
system.build.installBootLoader = builder;
system.boot.loader.id = "raspberrypi";
system.boot.loader.kernelFile = platform.kernelTarget;
};
}

View File

@ -11,116 +11,6 @@ let
udev = config.systemd.package;
options = {
boot.resumeDevice = mkOption {
default = "";
example = "0:0";
description = "
Device for manual resume attempt during boot. Looks like
major:minor. ls -l /dev/SWAP_PARTION shows them.
";
};
boot.initrd.enableSplashScreen = mkOption {
default = true;
description = "
Whether to show a nice splash screen while booting.
";
};
boot.initrd.checkJournalingFS = mkOption {
default = true;
type = types.bool;
description = ''
Whether to run fsck on journaling filesystems such as ext3.
'';
};
boot.initrd.mdadmConf = mkOption {
default = "";
type = with types; string;
description = ''
Contents of /etc/mdadm.conf at initrd.
'';
};
boot.initrd.preLVMCommands = mkOption {
default = "";
type = with types; string;
description = ''
Shell commands to be executed immediately before lvm discovery.
'';
};
boot.initrd.postDeviceCommands = mkOption {
default = "";
type = with types; string;
description = ''
Shell commands to be executed immediately after stage 1 of the
boot has loaded kernel modules and created device nodes in
/dev.
'';
};
boot.initrd.postMountCommands = mkOption {
default = "";
type = with types; string;
description = ''
Shell commands to be executed immediately after the stage 1
filesystems have been mounted.
'';
};
boot.initrd.extraUtilsCommands = mkOption {
internal = true;
default = "";
type = with types; string;
description = ''
Shell commands to be executed in the builder of the
extra-utils derivation. This can be used to provide
additional utilities in the initial ramdisk.
'';
};
boot.initrd.extraUtilsCommandsTest = mkOption {
internal = true;
default = "";
type = with types; string;
description = ''
Shell commands to be executed in the builder of the
extra-utils derivation after patchelf has done its
job. This can be used to test additional utilities
copied in extraUtilsCommands.
'';
};
boot.initrd.compressor = mkOption {
default = "gzip -9";
type = types.string;
description = "The compressor to use on the initrd";
example = "xz";
};
fileSystems = mkOption {
options.neededForBoot = mkOption {
default = false;
type = types.bool;
description = ''
If set, this file system will be mounted in the initial
ramdisk. By default, this applies to the root file system
and to the file system containing
<filename>/nix/store</filename>.
'';
};
};
};
kernelPackages = config.boot.kernelPackages;
modulesTree = config.system.modulesTree;
@ -141,7 +31,8 @@ let
&& kernelPackages.kernel.features.needsCifsUtils
&& any (fs: fs.fsType == "cifs") fileSystems;
busybox = if needsCifsUtils
busybox =
if needsCifsUtils
then pkgs.busybox.override {
extraConfig = ''
CONFIG_FEATURE_MOUNT_CIFS n
@ -351,9 +242,119 @@ let
];
};
in {
in
require = [options];
{
options = {
boot.resumeDevice = mkOption {
default = "";
example = "0:0";
description = "
Device for manual resume attempt during boot. Looks like
major:minor. ls -l /dev/SWAP_PARTION shows them.
";
};
boot.initrd.enableSplashScreen = mkOption {
default = true;
description = "
Whether to show a nice splash screen while booting.
";
};
boot.initrd.checkJournalingFS = mkOption {
default = true;
type = types.bool;
description = ''
Whether to run fsck on journaling filesystems such as ext3.
'';
};
boot.initrd.mdadmConf = mkOption {
default = "";
type = with types; string;
description = ''
Contents of /etc/mdadm.conf at initrd.
'';
};
boot.initrd.preLVMCommands = mkOption {
default = "";
type = with types; string;
description = ''
Shell commands to be executed immediately before lvm discovery.
'';
};
boot.initrd.postDeviceCommands = mkOption {
default = "";
type = with types; string;
description = ''
Shell commands to be executed immediately after stage 1 of the
boot has loaded kernel modules and created device nodes in
/dev.
'';
};
boot.initrd.postMountCommands = mkOption {
default = "";
type = with types; string;
description = ''
Shell commands to be executed immediately after the stage 1
filesystems have been mounted.
'';
};
boot.initrd.extraUtilsCommands = mkOption {
internal = true;
default = "";
type = with types; string;
description = ''
Shell commands to be executed in the builder of the
extra-utils derivation. This can be used to provide
additional utilities in the initial ramdisk.
'';
};
boot.initrd.extraUtilsCommandsTest = mkOption {
internal = true;
default = "";
type = with types; string;
description = ''
Shell commands to be executed in the builder of the
extra-utils derivation after patchelf has done its
job. This can be used to test additional utilities
copied in extraUtilsCommands.
'';
};
boot.initrd.compressor = mkOption {
default = "gzip -9";
type = types.string;
description = "The compressor to use on the initrd";
example = "xz";
};
fileSystems = mkOption {
options.neededForBoot = mkOption {
default = false;
type = types.bool;
description = ''
If set, this file system will be mounted in the initial
ramdisk. By default, this applies to the root file system
and to the file system containing
<filename>/nix/store</filename>.
'';
};
};
};
config = {
system.build.bootStage1 = bootStage1;
system.build.initialRamdisk = initialRamdisk;
@ -363,4 +364,6 @@ in {
(isYes "TMPFS")
(isYes "BLK_DEV_INITRD")
];
};
}

View File

@ -4,6 +4,38 @@ with pkgs.lib;
let
kernel = config.boot.kernelPackages.kernel;
activateConfiguration = config.system.activationScripts.script;
readonlyMountpoint = pkgs.runCommand "readonly-mountpoint" {} ''
mkdir -p $out/bin
cc -O3 ${./readonly-mountpoint.c} -o $out/bin/readonly-mountpoint
strip -s $out/bin/readonly-mountpoint
'';
bootStage2 = pkgs.substituteAll {
src = ./stage-2-init.sh;
shellDebug = "${pkgs.bashInteractive}/bin/bash";
isExecutable = true;
inherit (config.boot) devShmSize runSize cleanTmpDir;
inherit (config.nix) readOnlyStore;
ttyGid = config.ids.gids.tty;
path =
[ pkgs.coreutils
pkgs.utillinux
pkgs.sysvtools
] ++ (optional config.boot.cleanTmpDir pkgs.findutils)
++ optional config.nix.readOnlyStore readonlyMountpoint;
postBootCommands = pkgs.writeText "local-cmds"
''
${config.boot.postBootCommands}
${config.powerManagement.powerUpCommands}
'';
};
in
{
options = {
boot = {
@ -59,39 +91,10 @@ let
};
kernel = config.boot.kernelPackages.kernel;
activateConfiguration = config.system.activationScripts.script;
readonlyMountpoint = pkgs.runCommand "readonly-mountpoint" {} ''
mkdir -p $out/bin
cc -O3 ${./readonly-mountpoint.c} -o $out/bin/readonly-mountpoint
strip -s $out/bin/readonly-mountpoint
'';
bootStage2 = pkgs.substituteAll {
src = ./stage-2-init.sh;
shellDebug = "${pkgs.bashInteractive}/bin/bash";
isExecutable = true;
inherit (config.boot) devShmSize runSize cleanTmpDir;
inherit (config.nix) readOnlyStore;
ttyGid = config.ids.gids.tty;
path =
[ pkgs.coreutils
pkgs.utillinux
pkgs.sysvtools
] ++ (optional config.boot.cleanTmpDir pkgs.findutils)
++ optional config.nix.readOnlyStore readonlyMountpoint;
postBootCommands = pkgs.writeText "local-cmds"
''
${config.boot.postBootCommands}
${config.powerManagement.powerUpCommands}
'';
};
in
{
require = [options];
config = {
system.build.bootStage2 = bootStage2;
};
}

View File

@ -1,5 +1,5 @@
{ config, pkgs, modulesPath, ... }:
{
require = [ "${modulesPath}/virtualisation/amazon-image.nix" ];
imports = [ "${modulesPath}/virtualisation/amazon-image.nix" ];
}

View File

@ -3,7 +3,7 @@
with pkgs.lib;
{
require = [ ../profiles/headless.nix ./ec2-data.nix ];
imports = [ ../profiles/headless.nix ./ec2-data.nix ];
system.build.amazonImage =
pkgs.vmTools.runInLinuxVM (

View File

@ -5,7 +5,8 @@
{ config, pkgs, ... }:
with pkgs.lib;
let
{
options = {
ec2.metadata = mkOption {
type = types.bool;
@ -15,9 +16,8 @@ let
'';
};
};
in
{
require = [options];
config = {
systemd.services."fetch-ec2-data" =
{ description = "Fetch EC2 Data";
@ -95,4 +95,5 @@ in
serviceConfig.RemainAfterExit = true;
};
};
}

View File

@ -1,5 +1,5 @@
{ config, pkgs, modulesPath, ... }:
{
require = [ "${modulesPath}/virtualisation/nova-image.nix" ];
imports = [ "${modulesPath}/virtualisation/nova-image.nix" ];
}

View File

@ -3,7 +3,7 @@
with pkgs.lib;
{
require = [ ../profiles/qemu-guest.nix ../profiles/headless.nix ./ec2-data.nix ];
imports = [ ../profiles/qemu-guest.nix ../profiles/headless.nix ./ec2-data.nix ];
system.build.novaImage =
pkgs.vmTools.runInLinuxVM (

View File

@ -18,6 +18,123 @@ let
then "noname"
else config.networking.hostName;
cfg = config.virtualisation;
qemuGraphics = if cfg.graphics then "" else "-nographic";
kernelConsole = if cfg.graphics then "" else "console=ttyS0";
ttys = [ "tty1" "tty2" "tty3" "tty4" "tty5" "tty6" ];
# Shell script to start the VM.
startVM =
''
#! ${pkgs.stdenv.shell}
NIX_DISK_IMAGE=$(readlink -f ''${NIX_DISK_IMAGE:-${config.virtualisation.diskImage}})
if ! test -e "$NIX_DISK_IMAGE"; then
${pkgs.qemu_kvm}/bin/qemu-img create -f qcow2 "$NIX_DISK_IMAGE" \
${toString config.virtualisation.diskSize}M || exit 1
fi
# Create a directory for exchanging data with the VM.
if [ -z "$TMPDIR" -o -z "$USE_TMPDIR" ]; then
TMPDIR=$(mktemp -d nix-vm.XXXXXXXXXX --tmpdir)
fi
cd $TMPDIR
mkdir -p $TMPDIR/xchg
idx=2
extraDisks=""
${flip concatMapStrings cfg.emptyDiskImages (size: ''
${pkgs.qemu_kvm}/bin/qemu-img create -f raw "empty$idx" "${toString size}M"
extraDisks="$extraDisks -drive index=$idx,file=$(pwd)/empty$idx,if=virtio,werror=report"
idx=$((idx + 1))
'')}
# Start QEMU.
# "-boot menu=on" is there, because I don't know how to make qemu boot from 2nd hd.
exec ${pkgs.qemu_kvm}/bin/qemu-kvm \
-name ${vmName} \
-m ${toString config.virtualisation.memorySize} \
${optionalString (pkgs.stdenv.system == "x86_64-linux") "-cpu kvm64"} \
-net nic,vlan=0,model=virtio \
-net user,vlan=0''${QEMU_NET_OPTS:+,$QEMU_NET_OPTS} \
-virtfs local,path=/nix/store,security_model=none,mount_tag=store \
-virtfs local,path=$TMPDIR/xchg,security_model=none,mount_tag=xchg \
-virtfs local,path=''${SHARED_DIR:-$TMPDIR/xchg},security_model=none,mount_tag=shared \
${if cfg.useBootLoader then ''
-drive index=0,id=drive1,file=$NIX_DISK_IMAGE,if=virtio,cache=writeback,werror=report \
-drive index=1,id=drive2,file=${bootDisk}/disk.img,if=virtio,readonly \
-boot menu=on
'' else ''
-drive file=$NIX_DISK_IMAGE,if=virtio,cache=writeback,werror=report \
-kernel ${config.system.build.toplevel}/kernel \
-initrd ${config.system.build.toplevel}/initrd \
-append "$(cat ${config.system.build.toplevel}/kernel-params) init=${config.system.build.toplevel}/init regInfo=${regInfo} ${kernelConsole} $QEMU_KERNEL_PARAMS" \
''} \
$extraDisks \
${qemuGraphics} \
${toString config.virtualisation.qemu.options} \
$QEMU_OPTS
'';
regInfo = pkgs.runCommand "reginfo"
{ exportReferencesGraph =
map (x: [("closure-" + baseNameOf x) x]) config.virtualisation.pathsInNixDB;
buildInputs = [ pkgs.perl ];
preferLocalBuild = true;
}
''
printRegistration=1 perl ${pkgs.pathsFromGraph} closure-* > $out
'';
# Generate a hard disk image containing a /boot partition and GRUB
# in the MBR. Used when the `useBootLoader' option is set.
bootDisk =
pkgs.vmTools.runInLinuxVM (
pkgs.runCommand "nixos-boot-disk"
{ preVM =
''
mkdir $out
diskImage=$out/disk.img
${pkgs.qemu_kvm}/bin/qemu-img create -f qcow2 $diskImage "32M"
'';
buildInputs = [ pkgs.utillinux ];
}
''
# Create a single /boot partition.
${pkgs.parted}/sbin/parted /dev/vda mklabel msdos
${pkgs.parted}/sbin/parted /dev/vda -- mkpart primary ext2 1M -1s
. /sys/class/block/vda1/uevent
mknod /dev/vda1 b $MAJOR $MINOR
. /sys/class/block/vda/uevent
${pkgs.e2fsprogs}/sbin/mkfs.ext4 -L boot /dev/vda1
${pkgs.e2fsprogs}/sbin/tune2fs -c 0 -i 0 /dev/vda1
# Mount /boot.
mkdir /boot
mount /dev/vda1 /boot
# This is needed for GRUB 0.97, which doesn't know about virtio devices.
mkdir /boot/grub
echo '(hd0) /dev/vda' > /boot/grub/device.map
# Install GRUB and generate the GRUB boot menu.
touch /etc/NIXOS
mkdir -p /nix/var/nix/profiles
${config.system.build.toplevel}/bin/switch-to-configuration boot
umount /boot
''
);
in
{
imports = [ ../profiles/qemu-guest.nix ];
options = {
virtualisation.memorySize =
@ -154,122 +271,7 @@ let
};
cfg = config.virtualisation;
qemuGraphics = if cfg.graphics then "" else "-nographic";
kernelConsole = if cfg.graphics then "" else "console=ttyS0";
ttys = [ "tty1" "tty2" "tty3" "tty4" "tty5" "tty6" ];
# Shell script to start the VM.
startVM =
''
#! ${pkgs.stdenv.shell}
NIX_DISK_IMAGE=$(readlink -f ''${NIX_DISK_IMAGE:-${config.virtualisation.diskImage}})
if ! test -e "$NIX_DISK_IMAGE"; then
${pkgs.qemu_kvm}/bin/qemu-img create -f qcow2 "$NIX_DISK_IMAGE" \
${toString config.virtualisation.diskSize}M || exit 1
fi
# Create a directory for exchanging data with the VM.
if [ -z "$TMPDIR" -o -z "$USE_TMPDIR" ]; then
TMPDIR=$(mktemp -d nix-vm.XXXXXXXXXX --tmpdir)
fi
cd $TMPDIR
mkdir -p $TMPDIR/xchg
idx=2
extraDisks=""
${flip concatMapStrings cfg.emptyDiskImages (size: ''
${pkgs.qemu_kvm}/bin/qemu-img create -f raw "empty$idx" "${toString size}M"
extraDisks="$extraDisks -drive index=$idx,file=$(pwd)/empty$idx,if=virtio,werror=report"
idx=$((idx + 1))
'')}
# Start QEMU.
# "-boot menu=on" is there, because I don't know how to make qemu boot from 2nd hd.
exec ${pkgs.qemu_kvm}/bin/qemu-kvm \
-name ${vmName} \
-m ${toString config.virtualisation.memorySize} \
${optionalString (pkgs.stdenv.system == "x86_64-linux") "-cpu kvm64"} \
-net nic,vlan=0,model=virtio \
-net user,vlan=0''${QEMU_NET_OPTS:+,$QEMU_NET_OPTS} \
-virtfs local,path=/nix/store,security_model=none,mount_tag=store \
-virtfs local,path=$TMPDIR/xchg,security_model=none,mount_tag=xchg \
-virtfs local,path=''${SHARED_DIR:-$TMPDIR/xchg},security_model=none,mount_tag=shared \
${if cfg.useBootLoader then ''
-drive index=0,id=drive1,file=$NIX_DISK_IMAGE,if=virtio,cache=writeback,werror=report \
-drive index=1,id=drive2,file=${bootDisk}/disk.img,if=virtio,readonly \
-boot menu=on
'' else ''
-drive file=$NIX_DISK_IMAGE,if=virtio,cache=writeback,werror=report \
-kernel ${config.system.build.toplevel}/kernel \
-initrd ${config.system.build.toplevel}/initrd \
-append "$(cat ${config.system.build.toplevel}/kernel-params) init=${config.system.build.toplevel}/init regInfo=${regInfo} ${kernelConsole} $QEMU_KERNEL_PARAMS" \
''} \
$extraDisks \
${qemuGraphics} \
${toString config.virtualisation.qemu.options} \
$QEMU_OPTS
'';
regInfo = pkgs.runCommand "reginfo"
{ exportReferencesGraph =
map (x: [("closure-" + baseNameOf x) x]) config.virtualisation.pathsInNixDB;
buildInputs = [ pkgs.perl ];
preferLocalBuild = true;
}
''
printRegistration=1 perl ${pkgs.pathsFromGraph} closure-* > $out
'';
# Generate a hard disk image containing a /boot partition and GRUB
# in the MBR. Used when the `useBootLoader' option is set.
bootDisk =
pkgs.vmTools.runInLinuxVM (
pkgs.runCommand "nixos-boot-disk"
{ preVM =
''
mkdir $out
diskImage=$out/disk.img
${pkgs.qemu_kvm}/bin/qemu-img create -f qcow2 $diskImage "32M"
'';
buildInputs = [ pkgs.utillinux ];
}
''
# Create a single /boot partition.
${pkgs.parted}/sbin/parted /dev/vda mklabel msdos
${pkgs.parted}/sbin/parted /dev/vda -- mkpart primary ext2 1M -1s
. /sys/class/block/vda1/uevent
mknod /dev/vda1 b $MAJOR $MINOR
. /sys/class/block/vda/uevent
${pkgs.e2fsprogs}/sbin/mkfs.ext4 -L boot /dev/vda1
${pkgs.e2fsprogs}/sbin/tune2fs -c 0 -i 0 /dev/vda1
# Mount /boot.
mkdir /boot
mount /dev/vda1 /boot
# This is needed for GRUB 0.97, which doesn't know about virtio devices.
mkdir /boot/grub
echo '(hd0) /dev/vda' > /boot/grub/device.map
# Install GRUB and generate the GRUB boot menu.
touch /etc/NIXOS
mkdir -p /nix/var/nix/profiles
${config.system.build.toplevel}/bin/switch-to-configuration boot
umount /boot
''
);
in
{
require = [ options ../profiles/qemu-guest.nix ];
config = {
boot.loader.grub.device = mkOverride 50 "/dev/vda";
@ -414,4 +416,6 @@ in
(isYes "SERIAL_8250_CONSOLE")
(isYes "SERIAL_8250")
];
};
}

View File

@ -5,7 +5,7 @@
machine =
{ config, pkgs, ... }:
{ require = [ ./common/x11.nix ];
{ imports = [ ./common/x11.nix ];
environment.systemPackages = [ pkgs.firefox ];
};

View File

@ -37,7 +37,7 @@ let
''
{ config, pkgs, modulesPath, ... }:
{ require =
{ imports =
[ ./hardware.nix
"''${modulesPath}/testing/test-instrumentation.nix"
];

View File

@ -5,7 +5,7 @@
machine =
{ config, pkgs, ... }:
{ require = [ ./common/user-account.nix ];
{ imports = [ ./common/user-account.nix ];
virtualisation.memorySize = 768;

View File

@ -17,7 +17,7 @@ rec {
client =
{ config, pkgs, ... }:
{ require = [ ./common/x11.nix ];
{ imports = [ ./common/x11.nix ];
services.xserver.driSupport = true;
services.xserver.defaultDepth = pkgs.lib.mkOverride 0 16;
environment.systemPackages = [ pkgs.quake3demo ];

View File

@ -3,9 +3,8 @@
{
nodes = {
storage =
{pkgs, config, ...}:
{
services.nfs.server.enable = true;
{ config, pkgs, ... }:
{ services.nfs.server.enable = true;
services.nfs.server.exports = ''
/repos 192.168.1.0/255.255.255.0(rw,no_root_squash)
'';
@ -14,9 +13,7 @@
postgresql =
{ config, pkgs, ... }:
{
services.openssh.enable = true;
services.postgresql.enable = true;
{ services.postgresql.enable = true;
services.postgresql.package = pkgs.postgresql92;
services.postgresql.enableTCPIP = true;
services.postgresql.authentication = ''
@ -30,14 +27,12 @@
webserver =
{ config, pkgs, ... }:
{
fileSystems = pkgs.lib.mkOverride 50
{ fileSystems = pkgs.lib.mkOverride 50
[ { mountPoint = "/repos";
device = "storage:/repos";
fsType = "nfs";
}
];
services.httpd.enable = true;
services.httpd.adminAddr = "root@localhost";
services.httpd.extraSubservices = [ { serviceType = "trac"; } ];
@ -46,8 +41,7 @@
client =
{ config, pkgs, ... }:
{
require = [ ./common/x11.nix ];
{ imports = [ ./common/x11.nix ];
services.xserver.desktopManager.kde4.enable = true;
};
};

View File

@ -5,7 +5,7 @@
machine =
{ config, pkgs, ... }:
{ require = [ ./common/user-account.nix ];
{ imports = [ ./common/user-account.nix ];
services.xserver.enable = true;