2009-10-12 16:36:19 +00:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
2009-05-01 05:43:41 +00:00
|
|
|
|
|
|
|
let
|
2009-10-12 16:36:19 +00:00
|
|
|
|
|
|
|
cfg = config.services.autofs;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
2009-05-01 05:43:41 +00:00
|
|
|
|
|
|
|
options = {
|
2009-10-12 16:36:19 +00:00
|
|
|
|
|
|
|
services.autofs = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "
|
|
|
|
automatically mount and unmount filesystems
|
|
|
|
";
|
2009-05-01 05:43:41 +00:00
|
|
|
};
|
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
autoMaster = mkOption {
|
|
|
|
example = ''
|
|
|
|
autoMaster = let
|
|
|
|
mapConf = pkgs.writeText "auto" '''
|
|
|
|
kernel -ro,soft,intr ftp.kernel.org:/pub/linux
|
|
|
|
boot -fstype=ext2 :/dev/hda1
|
|
|
|
windoze -fstype=smbfs ://windoze/c
|
|
|
|
removable -fstype=ext2 :/dev/hdd
|
|
|
|
cd -fstype=iso9660,ro :/dev/hdc
|
|
|
|
floppy -fstype=auto :/dev/fd0
|
|
|
|
server -rw,hard,intr / -ro myserver.me.org:/ \
|
|
|
|
/usr myserver.me.org:/usr \
|
|
|
|
/home myserver.me.org:/home
|
|
|
|
''';
|
|
|
|
in '''
|
|
|
|
/auto file:''${mapConf}
|
|
|
|
'''
|
|
|
|
'';
|
|
|
|
description = "
|
|
|
|
file contents of /etc/auto.master. See man auto.master
|
|
|
|
see
|
|
|
|
man auto.master and man 5 autofs
|
|
|
|
";
|
|
|
|
};
|
2009-05-01 05:43:41 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
timeout = mkOption {
|
|
|
|
default = 600;
|
|
|
|
description = "Set the global minimum timeout, in seconds, until directories are unmounted";
|
|
|
|
};
|
2009-05-01 05:43:41 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
debug = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "pass -d to automount and write log to /var/log/autofs";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
2009-05-01 05:43:41 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
};
|
2009-05-01 05:43:41 +00:00
|
|
|
|
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
###### implementation
|
2009-05-01 05:43:41 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
config = mkIf cfg.enable {
|
2009-05-01 05:43:41 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
environment.etc = singleton
|
|
|
|
{ target = "auto.master";
|
2009-05-01 05:43:41 +00:00
|
|
|
source = pkgs.writeText "auto.master" cfg.autoMaster;
|
2009-10-12 16:36:19 +00:00
|
|
|
};
|
2009-05-01 05:43:41 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
jobAttrs.autofs =
|
|
|
|
{ description = "Filesystem automounter";
|
2009-05-01 05:43:41 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
startOn = "network-interfaces/started";
|
|
|
|
stopOn = "network-interfaces/stop";
|
2009-05-01 05:43:41 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
environment =
|
|
|
|
{ PATH = "${pkgs.nfsUtils}/sbin:${config.system.sbin.modprobe}/sbin";
|
|
|
|
};
|
2009-05-01 05:43:41 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
preStart =
|
|
|
|
''
|
|
|
|
modprobe autofs4 || true
|
|
|
|
'';
|
2009-05-01 05:43:41 +00:00
|
|
|
|
2009-10-12 16:36:19 +00:00
|
|
|
script =
|
|
|
|
''
|
|
|
|
${if cfg.debug then "exec &> /var/log/autofs" else ""}
|
|
|
|
${pkgs.autofs5}/sbin/automount -f -t ${builtins.toString cfg.timeout} ${if cfg.debug then "-d" else ""} "${pkgs.writeText "auto.master" cfg.autoMaster}"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2009-05-01 05:43:41 +00:00
|
|
|
};
|
2009-10-12 16:36:19 +00:00
|
|
|
|
2009-05-01 05:43:41 +00:00
|
|
|
}
|