nixpkgs/modules/tasks/swraid.nix
Eelco Dolstra fc9111fadf * Move various system initialisation tasks (e.g. mounting filesystems,
initialising network interfaces, etc.) to modules/tasks.  This
  follows the Upstart terminology: a service is a job that doesn't
  usually terminate (e.g. a daemon), while a task is a job that does
  some work and then exits.

svn path=/nixos/branches/modular-nixos/; revision=15771
2009-05-28 15:03:05 +00:00

45 lines
897 B
Nix

{pkgs, config, ...}:
###### implementation
let
tempConf = "/var/run/mdadm.conf";
modprobe = config.system.sbin.modprobe;
inherit (pkgs) mdadm;
in
{
services = {
extraJobs = [{
name = "swraid";
job = ''
start on udev
#start on new-devices
script
# Load the necessary RAID personalities.
# !!! hm, doesn't the kernel load these automatically?
for mod in raid0 raid1 raid5; do
${modprobe}/sbin/modprobe $mod || true
done
# Scan /proc/partitions for RAID devices.
${mdadm}/sbin/mdadm --examine --brief --scan -c partitions > ${tempConf}
# Activate each device found.
${mdadm}/sbin/mdadm --assemble -c ${tempConf} --scan
initctl emit new-devices
end script
'';
}];
};
}