How can I stop nixos-generate-config from adding autofs/nfs/cifs?

When I run nixos-generate-config and I have autofs/nfs/cifs network filesystems attached they appear in my hardware-configuration.nix:

+  fileSystems."/mnt/melchior" =
+    { device = "/nix/store/gimisssyy7pdmmhl4vv6z1m9xmgm3pdf-melchior";
+      fsType = "autofs";
+    };
+

But this means that if the network filesystem isn’t available at boot it takes ages to finish booting.

How can I prevent it from doing that?

  1. Remove manually
  2. Unmount before running nixos-generate-config

Though indeed, nixos-generate-config should ignore /mnt or /var/run, as those are usually for ephemeral mounts only.

1 Like

I see. So there isn’t a ignoreFilesystemTypes option or anything like that for nixos-generate-config that I thought I was missing. Thanks.

Generally I would add an option so the filesystem times out quickly, or use an option so the filesystem only mounts when actually needed.

From what you said this may not help, though. When you regenerate your hardware configuration most options like this aren’t preserved. I assume you’re automatically regenerating your hardware configuration file - why? Depending on why you could add the above mentioned options to configuration.nix.

What do you mean “why?”? Because I want to update drives I mounted. If I add a ZFS filesystem to my setup I run nixos-generate-config to add it to the hardware-configuration.nix. But pretty much always I have some nfs/cifs filesystem mount, because for example I’m playing music from one, so it’s almost always mounted.

And autofs is always mounted, even when no specific filesystems managed by autofs is mounted:

 > sudo mount | grep nfs   

 > sudo mount | grep autofs
/nix/store/gimisssyy7pdmmhl4vv6z1m9xmgm3pdf-melchior on /mnt/melchior type autofs (rw,relatime,fd=6,pgrp=4760,timeout=600,minproto=5,maxproto=5,indirect)

So I don’t think setting a “time out” for that is even doable in the first place.

I assume that to be a fairly rare situation. Since you have to manually provision & format the disk itself it doesn’t seem like much of a stretch to manually add the disk to hardware-configuration.nix. That is what I do on those rare occasions :man_shrugging:

Did you try using any options like x-systemd.automount, x-systemd.idle-timeout=?, x-systemd.device-timeout=?, x-systemd.mount-timeout=?, and specifying timeout values that work for you?

No, you’re right, it doesn’t happen very often. I was just wondering if there’s something I’m missing.