about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRaymond Gauthier <jraygauthier@gmail.com>2017-10-18 21:32:15 -0400
committerRaymond Gauthier <jraygauthier@gmail.com>2017-11-26 22:09:16 -0500
commitfaf13b67949362804946a8efae38435a8e48f713 (patch)
treedf0d46f39f0644c62f08afa7ab26a6abb9730eca
parentf557844c082fd1b590be3eebec2a3a84acf6973c (diff)
downloadnixlib-faf13b67949362804946a8efae38435a8e48f713.tar
nixlib-faf13b67949362804946a8efae38435a8e48f713.tar.gz
nixlib-faf13b67949362804946a8efae38435a8e48f713.tar.bz2
nixlib-faf13b67949362804946a8efae38435a8e48f713.tar.lz
nixlib-faf13b67949362804946a8efae38435a8e48f713.tar.xz
nixlib-faf13b67949362804946a8efae38435a8e48f713.tar.zst
nixlib-faf13b67949362804946a8efae38435a8e48f713.zip
vscode-extension-ms-python-python: Init at 0.8.0
-rw-r--r--pkgs/misc/vscode-extensions/default.nix5
-rw-r--r--pkgs/misc/vscode-extensions/python/default.nix41
-rw-r--r--pkgs/misc/vscode-extensions/vscode-utils.nix6
3 files changed, 49 insertions, 3 deletions
diff --git a/pkgs/misc/vscode-extensions/default.nix b/pkgs/misc/vscode-extensions/default.nix
index 8047e29ad558..16ddb8fd4052 100644
--- a/pkgs/misc/vscode-extensions/default.nix
+++ b/pkgs/misc/vscode-extensions/default.nix
@@ -1,7 +1,8 @@
 { stdenv, lib, fetchurl, callPackage, vscode-utils }:
 
 let
-  inherit (vscode-utils) buildVscodeExtension buildVscodeMarketplaceExtension;
+  inherit (vscode-utils) buildVscodeExtension buildVscodeMarketplaceExtension
+      extensionFromVscodeMarketplace;
 in
 #
 # Unless there is a good reason not to, we attemp to use the same name as the 
@@ -24,4 +25,6 @@ rec {
   };
 
   ms-vscode.cpptools = callPackage ./cpptools {};
+  
+  ms-python.python = callPackage ./python {};
 }
\ No newline at end of file
diff --git a/pkgs/misc/vscode-extensions/python/default.nix b/pkgs/misc/vscode-extensions/python/default.nix
new file mode 100644
index 000000000000..4e28de871b84
--- /dev/null
+++ b/pkgs/misc/vscode-extensions/python/default.nix
@@ -0,0 +1,41 @@
+{ stdenv, lib, vscode-utils
+
+, pythonUseFixed ? false, python  # When `true`, the python default setting will be fixed to specified. 
+                                  # Use version from `PATH` for default setting otherwise.
+                                  # Defaults to `false` as we expect it to be project specific most of the time.
+, ctagsUseFixed ? true, ctags     # When `true`, the ctags default setting will be fixed to specified. 
+                                  # Use version from `PATH` for default setting otherwise.
+                                  # Defaults to `true` as usually not defined on a per projet basis.
+}:
+
+assert pythonUseFixed -> null != python;
+assert ctagsUseFixed -> null != ctags;
+
+let
+  pythonDefaultsTo = if pythonUseFixed then "${python}/bin/python" else "python";
+  ctagsDefaultsTo = if ctagsUseFixed then "${ctags}/bin/ctags" else "ctags";
+in
+
+vscode-utils.buildVscodeMarketplaceExtension {
+  mktplcRef = {
+    name = "python";
+    publisher = "ms-python";
+    version = "0.8.0";
+    sha256 = "0i7s93l5g5lyi6vn77zh3ipj0p267y17fayv6vjrxc2igrs27ik6";
+  };
+
+  postPatch = ''
+    # Patch `packages.json` so that nix's *python* is used as default value for `python.pythonPath`.
+    substituteInPlace "./package.json" \
+      --replace "\"default\": \"python\"" "\"default\": \"${pythonDefaultsTo}\""
+
+    # Patch `packages.json` so that nix's *ctags* is used as default value for `python.workspaceSymbols.ctagsPath`.
+    substituteInPlace "./package.json" \
+      --replace "\"default\": \"ctags\"" "\"default\": \"${ctagsDefaultsTo}\""
+  '';
+
+    meta = with lib; {
+      license = licenses.mit;
+      maintainer = [ maintainers.jraygauthier ];
+    };
+}
\ No newline at end of file
diff --git a/pkgs/misc/vscode-extensions/vscode-utils.nix b/pkgs/misc/vscode-extensions/vscode-utils.nix
index f6e906ab575b..83cb559dca12 100644
--- a/pkgs/misc/vscode-extensions/vscode-utils.nix
+++ b/pkgs/misc/vscode-extensions/vscode-utils.nix
@@ -70,12 +70,14 @@ let
       mktplcRef = ext; 
     }); 
 
+  extensionFromVscodeMarketplace = mktplcExtRefToExtDrv;
   extensionsFromVscodeMarketplace = mktplcExtRefList:
-    builtins.map mktplcExtRefToExtDrv mktplcExtRefList;
+    builtins.map extensionFromVscodeMarketplace mktplcExtRefList;
 
 in
 
 {
   inherit fetchVsixFromVscodeMarketplace buildVscodeExtension 
-          buildVscodeMarketplaceExtension extensionsFromVscodeMarketplace;
+          buildVscodeMarketplaceExtension extensionFromVscodeMarketplace
+          extensionsFromVscodeMarketplace;
 }
\ No newline at end of file