How to automount KBFS on nixos?

Hello!

I am trying to automount KBFS on my machine i.e. just have kbfs mount to a desired location automatically when my machine starts.

So far with

  services.keybase.enable = true;
  services.kbfs.enable = true;

in my config I can mount kbfs manually doing kbfsfuse by hand but I want to automate this.

I have done this task on a non-Nix machine and (could be mixed up) but I did by having

[Unit]
Description=KBFS Mount
Before=local-fs.target

[Mount]
What=keybase://kbfs
Where=/keybase
Type=fuse
Options=allow_other

[Install]
WantedBy=multi-user.target

in /etc/systemd/system/kbfs.mount but in Nix I cannot directly edit /etc/systemd/system/kbfs.mount.

I stumbled across this post that talks about rclone automounts using systemd - Systemd.mounts.*. and systemd.automounts.*. - options causing an error - #7 by joko but I am not being able to co-opt what’s being done here?

Could someone share a minimal config of automouting? If not could you please point me in the right direction?

Looks like NixOS will automatically mount it under $HOME/keybase (check services.kbfs.mountPoint). All you need to do is to create that directory. You can change mountPoint, but have in mind that it is user service. Unless you want to use a redirector (services.kbfs.enableRedirector).

@morr

thanks for chiming in!

Could you help me understand what

but have in mind that it is user service

means?

I tried services.kbfs.mountPoint and was able to rebuild Nix without errors but that did not change kbfs’s behavior.

Systemd can use per-user services: Systemd/User Services - NixOS Wiki, you can see it here: nixpkgs/nixos/modules/services/network-filesystems/kbfs.nix at a1cc729dcbc31d9b0d11d86dc7436163548a9665 · NixOS/nixpkgs · GitHub You can list user services with systemctl list-units --user. You can check status with systemctl --user status kbfs.service. Being user services, it will use your UID for mounting, and unless you set up permissions, probably you won’t be able to mount it as /keybase. But service should have something in logs (or status).