summary refs log tree commit diff stats
path: root/user/modules
diff options
context:
space:
mode:
authorAlan Pearce2019-12-09 16:40:22 +0100
committerAlan Pearce2019-12-09 16:40:22 +0100
commit8d9f5216c8cf2a89488a9fa303e0a71557a6fdc4 (patch)
treeb2354e9cebf1031b7a67d86fe220523423dc5850 /user/modules
parentca4537a8e0f19baf3b83c0308bf444d71427906a (diff)
downloadnixfiles-8d9f5216c8cf2a89488a9fa303e0a71557a6fdc4.tar.lz
nixfiles-8d9f5216c8cf2a89488a9fa303e0a71557a6fdc4.tar.zst
nixfiles-8d9f5216c8cf2a89488a9fa303e0a71557a6fdc4.zip
tabnine: switch config directory by system type
Diffstat (limited to 'user/modules')
-rw-r--r--user/modules/tabnine.nix17
1 files changed, 13 insertions, 4 deletions
diff --git a/user/modules/tabnine.nix b/user/modules/tabnine.nix
index dd4d7108..7a207fa2 100644
--- a/user/modules/tabnine.nix
+++ b/user/modules/tabnine.nix
@@ -3,8 +3,9 @@
 with lib;
 
 let
+  inherit (pkgs) stdenv;
   cfg = config.programs.tabnine;
-  configFile = config:
+  lspConfigFile = config:
     pkgs.runCommand "TabNine.toml"
       {
          buildInputs = [ pkgs.remarshal ];
@@ -23,20 +24,28 @@ in
   options.programs.tabnine = {
     enable = mkEnableOption "TabNine, Smart Compose for code.";
 
+    configDir = mkOption {
+      type = types.str;
+      default = if stdenv.isDarwin then "Library/Preferences/TabNine" else "${config.xdg.configHome}/TabNine";
+      description = ''
+        Location of TabNine configuration directory relative to \$HOME
+      '';
+    };
+
     lspConfig = mkOption {
       type = types.attrs;
       default = {};
       description = ''
         LSP Server configuration written to
-        <filename>~/.config/TabNine/TabNine.toml</filename>.
+        <filename>\${configDir}/TabNine.toml</filename>
         </para><para>
       '';
     };
   };
 
   config = mkIf cfg.enable {
-    xdg.configFile."TabNine/TabNine.toml" = {
-      source = configFile cfg.lspConfig;
+    home.file."${cfg.configDir}/TabNine.toml" = {
+      source = lspConfigFile cfg.lspConfig;
     };
   };
 }