How do you declare a bind mount in NixOS?

4

2

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?

kevlar1818

Posted 2017-11-25T16:22:01.533

Reputation: 319

Answers

5

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" ];
};

kevlar1818

Posted 2017-11-25T16:22:01.533

Reputation: 319