1{ config, lib, pkgs, ... }: 2with lib; 3let 4 cfg = config.services.kbfs; 5 6in { 7 8 ###### interface 9 10 options = { 11 12 services.kbfs = { 13 14 enable = mkOption { 15 type = types.bool; 16 default = false; 17 description = "Whether to mount the Keybase filesystem."; 18 }; 19 20 mountPoint = mkOption { 21 type = types.str; 22 default = "%h/keybase"; 23 example = "/keybase"; 24 description = "Mountpoint for the Keybase filesystem."; 25 }; 26 27 extraFlags = mkOption { 28 type = types.listOf types.str; 29 default = []; 30 example = [ 31 "-label kbfs" 32 "-mount-type normal" 33 ]; 34 description = '' 35 Additional flags to pass to the Keybase filesystem on launch. 36 ''; 37 }; 38 39 }; 40 }; 41 42 ###### implementation 43 44 config = mkIf cfg.enable { 45 46 systemd.user.services.kbfs = { 47 description = "Keybase File System"; 48 requires = [ "keybase.service" ]; 49 after = [ "keybase.service" ]; 50 path = [ "/run/wrappers" ]; 51 serviceConfig = { 52 ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p ${cfg.mountPoint}"; 53 ExecStart = "${pkgs.kbfs}/bin/kbfsfuse ${toString cfg.extraFlags} ${cfg.mountPoint}"; 54 ExecStopPost = "/run/wrappers/bin/fusermount -u ${cfg.mountPoint}"; 55 Restart = "on-failure"; 56 PrivateTmp = true; 57 }; 58 }; 59 60 services.keybase.enable = true; 61 }; 62}