1 { config, lib, pkgs, ... }:
7 cfg = config.services.autofs;
9 autoMaster = pkgs.writeText "auto.master" cfg.autoMaster;
24 description = lib.mdDoc ''
25 Mount filesystems on demand. Unmount them automatically.
26 You may also be interested in afuse.
30 autoMaster = mkOption {
32 example = literalExpression ''
34 mapConf = pkgs.writeText "auto" '''
35 kernel -ro,soft,intr ftp.kernel.org:/pub/linux
36 boot -fstype=ext2 :/dev/hda1
37 windoze -fstype=smbfs ://windoze/c
38 removable -fstype=ext2 :/dev/hdd
39 cd -fstype=iso9660,ro :/dev/hdc
40 floppy -fstype=auto :/dev/fd0
41 server -rw,hard,intr / -ro myserver.me.org:/ \
42 /usr myserver.me.org:/usr \
43 /home myserver.me.org:/home
46 /auto file:''${mapConf}
49 description = lib.mdDoc ''
50 Contents of `/etc/auto.master` file. See {command}`auto.master(5)` and {command}`autofs(5)`.
57 description = lib.mdDoc "Set the global minimum timeout, in seconds, until directories are unmounted";
63 description = lib.mdDoc ''
64 Pass -d and -7 to automount and write log to the system journal.
75 config = mkIf cfg.enable {
77 boot.kernelModules = [ "autofs4" ];
79 systemd.services.autofs =
80 { description = "Automounts filesystems on demand";
81 after = [ "network.target" "ypbind.service" "sssd.service" "network-online.target" ];
82 wants = [ "network-online.target" ];
83 wantedBy = [ "multi-user.target" ];
86 # There should be only one autofs service managed by systemd, so this should be safe.
87 rm -f /tmp/autofs-running
92 PIDFile = "/run/autofs.pid";
93 ExecStart = "${pkgs.autofs5}/bin/automount ${optionalString cfg.debug "-d"} -p /run/autofs.pid -t ${builtins.toString cfg.timeout} ${autoMaster}";
94 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";