1 { config, lib, pkgs, ... }:
4 cfg = config.services.autofs;
6 autoMaster = pkgs.writeText "auto.master" cfg.autoMaster;
18 enable = lib.mkOption {
19 type = lib.types.bool;
22 Mount filesystems on demand. Unmount them automatically.
23 You may also be interested in afuse.
27 autoMaster = lib.mkOption {
29 example = lib.literalExpression ''
31 mapConf = pkgs.writeText "auto" '''
32 kernel -ro,soft,intr ftp.kernel.org:/pub/linux
33 boot -fstype=ext2 :/dev/hda1
34 windoze -fstype=smbfs ://windoze/c
35 removable -fstype=ext2 :/dev/hdd
36 cd -fstype=iso9660,ro :/dev/hdc
37 floppy -fstype=auto :/dev/fd0
38 server -rw,hard,intr / -ro myserver.me.org:/ \
39 /usr myserver.me.org:/usr \
40 /home myserver.me.org:/home
43 /auto file:''${mapConf}
47 Contents of `/etc/auto.master` file. See {command}`auto.master(5)` and {command}`autofs(5)`.
51 timeout = lib.mkOption {
54 description = "Set the global minimum timeout, in seconds, until directories are unmounted";
57 debug = lib.mkOption {
58 type = lib.types.bool;
61 Pass -d and -7 to automount and write log to the system journal.
72 config = lib.mkIf cfg.enable {
74 boot.kernelModules = [ "autofs" ];
76 systemd.services.autofs =
77 { description = "Automounts filesystems on demand";
78 after = [ "network.target" "ypbind.service" "sssd.service" "network-online.target" ];
79 wants = [ "network-online.target" ];
80 wantedBy = [ "multi-user.target" ];
83 # There should be only one autofs service managed by systemd, so this should be safe.
84 rm -f /tmp/autofs-running
89 PIDFile = "/run/autofs.pid";
90 ExecStart = "${pkgs.autofs5}/bin/automount ${lib.optionalString cfg.debug "-d"} -p /run/autofs.pid -t ${builtins.toString cfg.timeout} ${autoMaster}";
91 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";