* Sketch for purely functional NixOS configuration.
svn path=/nixu/trunk/; revision=6694
This commit is contained in:
parent
c8b64ef689
commit
89c31b1c2c
20
pure/devices.nix
Normal file
20
pure/devices.nix
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
[
|
||||||
|
{ id = "net-dev-1";
|
||||||
|
comment = "Broadcom Corporation NetXtreme BCM5751 Gigabit Ethernet PCI Express";
|
||||||
|
location = {
|
||||||
|
busId = "pci-0000:02:00.0";
|
||||||
|
macAddr = "00:14:22:bc:68:51";
|
||||||
|
prefer = "macAddr"; # i.e., don't care if busId changes
|
||||||
|
};
|
||||||
|
extraModules = []; # tg3
|
||||||
|
}
|
||||||
|
|
||||||
|
{ id = "keyboard-1";
|
||||||
|
comment = "Dell Computer Corp. SK-8125 Keyboard";
|
||||||
|
location = {
|
||||||
|
busId = "usb-003-003";
|
||||||
|
};
|
||||||
|
extraModules = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
84
pure/disks.nix
Normal file
84
pure/disks.nix
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
{
|
||||||
|
|
||||||
|
/* Old school. */
|
||||||
|
|
||||||
|
volume1 = {
|
||||||
|
mountPoint = "/";
|
||||||
|
filesystem = "ext3";
|
||||||
|
location = {
|
||||||
|
device = "/dev/hda1";
|
||||||
|
};
|
||||||
|
creationParams = {
|
||||||
|
disk = "/dev/hda";
|
||||||
|
partition = 1;
|
||||||
|
startCylinder = 1;
|
||||||
|
endCylinder = 1000;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
volume2 = {
|
||||||
|
filesystem = "swap";
|
||||||
|
location = {
|
||||||
|
device = "/dev/hda2";
|
||||||
|
};
|
||||||
|
creationParams = {
|
||||||
|
disk = "/dev/hda";
|
||||||
|
startCylinder = 1001;
|
||||||
|
endCylinder = 1100;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* With partition labels; don't care which device holds the file
|
||||||
|
system. */
|
||||||
|
|
||||||
|
volume1 = {
|
||||||
|
mountPoint = "/";
|
||||||
|
filesystem = "auto";
|
||||||
|
location = {
|
||||||
|
label = "ROOT_DISK";
|
||||||
|
};
|
||||||
|
# Only relevant when creating.
|
||||||
|
creationParams = {
|
||||||
|
disk = "/dev/hda";
|
||||||
|
partition = 1;
|
||||||
|
startCylinder = 1;
|
||||||
|
endCylinder = 1000;
|
||||||
|
filesystem = "ext3";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* LVM. */
|
||||||
|
|
||||||
|
volume1 = {
|
||||||
|
mountPoint = "/data";
|
||||||
|
filesystem = "auto";
|
||||||
|
location = {
|
||||||
|
lvmVolumeGroup = "system";
|
||||||
|
lvmVolumeName = "big-volume"; # -> /dev/mapper/system-big-volume
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
lvmConfig = {
|
||||||
|
devices = [
|
||||||
|
...
|
||||||
|
];
|
||||||
|
groups = [
|
||||||
|
{ name = "system";
|
||||||
|
volumes = [
|
||||||
|
{ name = "big-volume";
|
||||||
|
size = 1048576; # -> 1 GiB
|
||||||
|
}
|
||||||
|
{ name = "blah";
|
||||||
|
size = 1048576; # -> 1 GiB
|
||||||
|
}
|
||||||
|
];
|
||||||
|
# When realising this configuration, only delete explicitly
|
||||||
|
# listed volumes for safety.
|
||||||
|
canDelete = ["foobar"];
|
||||||
|
};
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
58
pure/networking.nix
Normal file
58
pure/networking.nix
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
{
|
||||||
|
|
||||||
|
identification = {
|
||||||
|
fromDHCP = false;
|
||||||
|
hostname = "foobar";
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
interfaces = [
|
||||||
|
|
||||||
|
# Manual configuration.
|
||||||
|
{ name = "eth0";
|
||||||
|
hardware = {
|
||||||
|
type = "ethernet";
|
||||||
|
device = "net-dev-1";
|
||||||
|
};
|
||||||
|
link = {
|
||||||
|
ip4 = {
|
||||||
|
address = "192.168.1.2";
|
||||||
|
nameservers = [ # to be used when this interface is up
|
||||||
|
"1.2.3.4";
|
||||||
|
"1.2.3.5";
|
||||||
|
];
|
||||||
|
routes = [ # idem, add when up
|
||||||
|
{ destination = "0.0.0.0";
|
||||||
|
netmask = "0.0.0.0";
|
||||||
|
gateway = "192.168.1.1";
|
||||||
|
# iface implied (eth0)
|
||||||
|
}
|
||||||
|
{ destination = "192.168.1.0";
|
||||||
|
netmask = "255.255.255.0";
|
||||||
|
# iface implied (eth0)
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
ip6 = ...;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
# Automatic configuration via DHCP
|
||||||
|
{ name = "eth0";
|
||||||
|
hardware = {
|
||||||
|
type = "ethernet";
|
||||||
|
device = "net-dev-1";
|
||||||
|
};
|
||||||
|
link = {
|
||||||
|
useDHCP = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
firewall = {
|
||||||
|
# ...
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
26
pure/top-level.nix
Normal file
26
pure/top-level.nix
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
rec {
|
||||||
|
|
||||||
|
devices = import ./devices.nix;
|
||||||
|
|
||||||
|
disks = import ./disks.nix;
|
||||||
|
|
||||||
|
networking = import ./networking.nix;
|
||||||
|
|
||||||
|
systemServices = [
|
||||||
|
terminalRunner
|
||||||
|
syslogServer
|
||||||
|
dhcpClient
|
||||||
|
sshServer
|
||||||
|
subversionServer
|
||||||
|
];
|
||||||
|
|
||||||
|
systemInit = {
|
||||||
|
inherit devices disks networking;
|
||||||
|
inherit systemServices;
|
||||||
|
};
|
||||||
|
|
||||||
|
kernel = import ... {
|
||||||
|
externalModules = [nvidia vmware ...];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user