10

I'm trying to declare a bind mount in my NixOS configuration. I'm trying the configuration snippet below, but it sends the OS into recovery mode when I test it out (using nixos-rebuild test). To be clear, I'd like /data to be reachable at /srv/nfs as well.

# 
# /etc/nixos/configuration.nix
#
fileSystems."/data" = {
  device = "/dev/disk/by-uuid/bobloblaw";
  fsType = "btrfs";
};

fileSystems."/srv/nfs" = {
  device = "/data";
  fsType = "bindfs";
};

Any advice?

1 Answer 1

13

Of course, right after posting this question I find this NixOS wiki article about NFS and bind mount examples:

https://nixos.wiki/wiki/NFS

TL;DR: Instead of fsType, I should have used options. At the time of writing this, the wiki is slightly out of date; options must be a list of strings.

This code snippet seems to work as expected:

# 
# /etc/nixos/configuration.nix
#
fileSystems."/data" = {
  device = "/dev/disk/by-uuid/bobloblaw";
  fsType = "btrfs";
};

fileSystems."/srv/nfs" = {
  device = "/data";
  options = [ "bind" ];
};

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .