fork/home-manager
git clone https://git.julia.blue/fork/home-manager
75790441
master
1{ config , lib , pkgs , ...} : 2 3with lib ; 4 5let 6 7cfg = config . services . kbfs ; 8 9in { 10options = { 11services . kbfs = { 12enable = mkEnableOption "Keybase File System" ; 13 14mountPoint = mkOption { 15type = types . str ; 16default = "keybase" ; 17description = '' 18Mount point for the Keybase filesystem, relative to 19{env}`HOME`. 20'' ; 21}; 22 23extraFlags = mkOption { 24type = types . listOf types . str ; 25default = [ ]; 26example = [ "-label kbfs" "-mount-type normal" ]; 27description = '' 28Additional flags to pass to the Keybase filesystem on launch. 29'' ; 30}; 31}; 32}; 33 34config = mkIf cfg . enable { 35assertions = [ 36( lib . hm . assertions . assertPlatform "services.kbfs" pkgs 37lib . platforms . linux ) 38]; 39 40systemd . user . services . kbfs = { 41Unit = { 42Description = "Keybase File System" ; 43Requires = [ "keybase.service" ]; 44After = [ "keybase.service" ]; 45}; 46 47Service = let mountPoint = ''"%h/ ${ cfg . mountPoint } "'' ; 48in { 49Environment = "PATH=/run/wrappers/bin KEYBASE_SYSTEMD=1" ; 50ExecStartPre = " ${ pkgs . coreutils } /bin/mkdir -p ${ mountPoint } " ; 51ExecStart = 52" ${ pkgs . kbfs } /bin/kbfsfuse ${ toString cfg . extraFlags } ${ mountPoint } " ; 53ExecStopPost = "/run/wrappers/bin/fusermount -u ${ mountPoint } " ; 54Restart = "on-failure" ; 55PrivateTmp = true ; 56}; 57 58Install . WantedBy = [ "default.target" ]; 59}; 60 61home . packages = [ pkgs . kbfs ]; 62services . keybase . enable = true ; 63}; 64}