9 cfg = config.services.autofs;
11 autoMaster = pkgs.writeText "auto.master" cfg.autoMaster;
23 enable = lib.mkOption {
24 type = lib.types.bool;
27 Mount filesystems on demand. Unmount them automatically.
28 You may also be interested in afuse.
32 autoMaster = lib.mkOption {
34 example = lib.literalExpression ''
36 mapConf = pkgs.writeText "auto" '''
37 kernel -ro,soft,intr ftp.kernel.org:/pub/linux
38 boot -fstype=ext2 :/dev/hda1
39 windoze -fstype=smbfs ://windoze/c
40 removable -fstype=ext2 :/dev/hdd
41 cd -fstype=iso9660,ro :/dev/hdc
42 floppy -fstype=auto :/dev/fd0
43 server -rw,hard,intr / -ro myserver.me.org:/ \
44 /usr myserver.me.org:/usr \
45 /home myserver.me.org:/home
48 /auto file:''${mapConf}
52 Contents of `/etc/auto.master` file. See {command}`auto.master(5)` and {command}`autofs(5)`.
56 timeout = lib.mkOption {
59 description = "Set the global minimum timeout, in seconds, until directories are unmounted";
62 debug = lib.mkOption {
63 type = lib.types.bool;
66 Pass -d and -7 to automount and write log to the system journal.
76 config = lib.mkIf cfg.enable {
78 boot.kernelModules = [ "autofs" ];
80 systemd.services.autofs = {
81 description = "Automounts filesystems on demand";
86 "network-online.target"
88 wants = [ "network-online.target" ];
89 wantedBy = [ "multi-user.target" ];
92 # There should be only one autofs service managed by systemd, so this should be safe.
93 rm -f /tmp/autofs-running
98 PIDFile = "/run/autofs.pid";
99 ExecStart = "${pkgs.autofs5}/bin/automount ${lib.optionalString cfg.debug "-d"} -p /run/autofs.pid -t ${builtins.toString cfg.timeout} ${autoMaster}";
100 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";