2009-10-12 17:36:19 +01:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
2009-05-01 06:43:41 +01:00
|
|
|
|
|
|
|
let
|
2009-10-12 17:36:19 +01:00
|
|
|
|
|
|
|
cfg = config.services.autofs;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
2009-05-01 06:43:41 +01:00
|
|
|
|
|
|
|
options = {
|
2009-10-12 17:36:19 +01:00
|
|
|
|
|
|
|
services.autofs = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "
|
|
|
|
automatically mount and unmount filesystems
|
|
|
|
";
|
2009-05-01 06:43:41 +01:00
|
|
|
};
|
|
|
|
|
2009-10-12 17:36:19 +01: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 06:43:41 +01:00
|
|
|
|
2009-10-12 17:36:19 +01:00
|
|
|
timeout = mkOption {
|
|
|
|
default = 600;
|
|
|
|
description = "Set the global minimum timeout, in seconds, until directories are unmounted";
|
|
|
|
};
|
2009-05-01 06:43:41 +01:00
|
|
|
|
2009-10-12 17:36:19 +01:00
|
|
|
debug = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "pass -d to automount and write log to /var/log/autofs";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
2009-05-01 06:43:41 +01:00
|
|
|
|
2009-10-12 17:36:19 +01:00
|
|
|
};
|
2009-05-01 06:43:41 +01:00
|
|
|
|
|
|
|
|
2009-10-12 17:36:19 +01:00
|
|
|
###### implementation
|
2009-05-01 06:43:41 +01:00
|
|
|
|
2009-10-12 17:36:19 +01:00
|
|
|
config = mkIf cfg.enable {
|
2009-05-01 06:43:41 +01:00
|
|
|
|
2009-10-12 17:36:19 +01:00
|
|
|
environment.etc = singleton
|
|
|
|
{ target = "auto.master";
|
2009-05-01 06:43:41 +01:00
|
|
|
source = pkgs.writeText "auto.master" cfg.autoMaster;
|
2009-10-12 17:36:19 +01:00
|
|
|
};
|
2009-05-01 06:43:41 +01:00
|
|
|
|
2009-10-12 19:09:34 +01:00
|
|
|
jobs.autofs =
|
2009-10-12 17:36:19 +01:00
|
|
|
{ description = "Filesystem automounter";
|
2009-05-01 06:43:41 +01:00
|
|
|
|
2009-11-06 22:19:17 +00:00
|
|
|
startOn = "started network-interfaces";
|
|
|
|
stopOn = "stopping network-interfaces";
|
2009-05-01 06:43:41 +01:00
|
|
|
|
2009-10-12 17:36:19 +01:00
|
|
|
environment =
|
|
|
|
{ PATH = "${pkgs.nfsUtils}/sbin:${config.system.sbin.modprobe}/sbin";
|
|
|
|
};
|
2009-05-01 06:43:41 +01:00
|
|
|
|
2009-10-12 17:36:19 +01:00
|
|
|
preStart =
|
|
|
|
''
|
|
|
|
modprobe autofs4 || true
|
|
|
|
'';
|
2009-05-01 06:43:41 +01:00
|
|
|
|
2009-10-12 17:36:19 +01: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 06:43:41 +01:00
|
|
|
};
|
2009-10-12 17:36:19 +01:00
|
|
|
|
2009-05-01 06:43:41 +01:00
|
|
|
}
|