2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2009-10-12 18:36:19 +02:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2009-05-01 07:43:41 +02:00
|
|
|
|
|
|
|
let
|
2009-10-12 18:36:19 +02:00
|
|
|
|
|
|
|
cfg = config.services.autofs;
|
|
|
|
|
2009-12-25 07:39:43 +01:00
|
|
|
autoMaster = pkgs.writeText "auto.master" cfg.autoMaster;
|
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
2009-05-01 07:43:41 +02:00
|
|
|
|
|
|
|
options = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
services.autofs = {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "
|
2009-12-25 07:39:43 +01:00
|
|
|
Mount filesystems on demand. Unmount them automatically.
|
|
|
|
You may also be interested in afuese.
|
2009-10-12 18:36:19 +02:00
|
|
|
";
|
2009-05-01 07:43:41 +02:00
|
|
|
};
|
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
autoMaster = mkOption {
|
2016-01-17 19:34:55 +01:00
|
|
|
type = types.str;
|
2011-09-06 01:33:29 +02:00
|
|
|
example = literalExample ''
|
2016-01-17 19:34:55 +01:00
|
|
|
let
|
2009-10-12 18:36:19 +02:00
|
|
|
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
|
2009-12-25 07:39:43 +01:00
|
|
|
See man 5 auto.master and man 5 autofs.
|
2009-10-12 18:36:19 +02:00
|
|
|
";
|
|
|
|
};
|
2009-05-01 07:43:41 +02:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
timeout = mkOption {
|
|
|
|
default = 600;
|
|
|
|
description = "Set the global minimum timeout, in seconds, until directories are unmounted";
|
|
|
|
};
|
2009-05-01 07:43:41 +02:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
debug = mkOption {
|
|
|
|
default = false;
|
2009-12-25 07:39:43 +01:00
|
|
|
description = "
|
|
|
|
pass -d and -7 to automount and write log to /var/log/autofs
|
|
|
|
";
|
2009-10-12 18:36:19 +02:00
|
|
|
};
|
2009-12-25 07:39:43 +01:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
};
|
2009-05-01 07:43:41 +02:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
};
|
2009-05-01 07:43:41 +02:00
|
|
|
|
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
###### implementation
|
2009-05-01 07:43:41 +02:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
config = mkIf cfg.enable {
|
2009-05-01 07:43:41 +02:00
|
|
|
|
2012-03-17 18:26:17 +01:00
|
|
|
boot.kernelModules = [ "autofs4" ];
|
|
|
|
|
2015-11-11 14:18:38 +01:00
|
|
|
systemd.services.autofs =
|
2009-10-12 18:36:19 +02:00
|
|
|
{ description = "Filesystem automounter";
|
2015-11-11 14:18:38 +01:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
2009-05-01 07:43:41 +02:00
|
|
|
|
2015-11-11 14:18:38 +01:00
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pkgs.autofs5}/sbin/automount ${if cfg.debug then "-d" else ""} -f -t ${builtins.toString cfg.timeout} ${autoMaster} ${if cfg.debug then "-l7" else ""}";
|
|
|
|
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
|
|
|
|
};
|
2009-10-12 18:36:19 +02:00
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-05-01 07:43:41 +02:00
|
|
|
};
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-05-01 07:43:41 +02:00
|
|
|
}
|