From 6d31311eaa4181b7de82e8a28837c53346c48c86 Mon Sep 17 00:00:00 2001 From: Oren Rozen Date: Sat, 28 Dec 2019 16:43:41 -0500 Subject: [PATCH] vscode-utils/vscodeEnv: split to 2 functions vscodeWithConfiguration, vscodeExts2nix, vscodeEnv change usage of toPath with toString --- pkgs/misc/vscode-extensions/vscode-utils.nix | 25 ++++++------- pkgs/misc/vscode-extensions/vscodeEnv.nix | 35 +++++++++++-------- .../misc/vscode-extensions/vscodeExts2nix.nix | 14 ++++---- .../vscodeWithConfiguration.nix | 21 ++++++----- 4 files changed, 50 insertions(+), 45 deletions(-) diff --git a/pkgs/misc/vscode-extensions/vscode-utils.nix b/pkgs/misc/vscode-extensions/vscode-utils.nix index 448bc81c917c..3e2378254954 100644 --- a/pkgs/misc/vscode-extensions/vscode-utils.nix +++ b/pkgs/misc/vscode-extensions/vscode-utils.nix @@ -1,4 +1,4 @@ -{ stdenv, lib, writeShellScriptBin, fetchurl, vscode, unzip }: +{ stdenv, lib, buildEnv, writeShellScriptBin, fetchurl, vscode, unzip }: let @@ -72,21 +72,22 @@ let extensionsFromVscodeMarketplace = mktplcExtRefList: builtins.map extensionFromVscodeMarketplace mktplcExtRefList; - vscodeWithConfiguration = (userParams : import ./vscodeWithConfiguration.nix { - inherit lib vscode extensionsFromVscodeMarketplace writeShellScriptBin; - } // userParams); + vscodeWithConfiguration = import ./vscodeWithConfiguration.nix { + inherit lib extensionsFromVscodeMarketplace writeShellScriptBin; + vscodeDefault = vscode; + }; - vscodeExts2nix = (userParams : import ./vscodeExts2nix.nix { - inherit lib vscode; - } // userParams); - - vscodeEnv = (userParams : import ./vscodeEnv.nix { - inherit lib writeShellScriptBin extensionsFromVscodeMarketplace vscode; - } // userParams ); + vscodeExts2nix = import ./vscodeExts2nix.nix { + inherit lib writeShellScriptBin; + vscodeDefault = vscode; + }; + vscodeEnv = import ./vscodeEnv.nix { + inherit lib buildEnv writeShellScriptBin extensionsFromVscodeMarketplace; + vscodeDefault = vscode; + }; in - { inherit fetchVsixFromVscodeMarketplace buildVscodeExtension buildVscodeMarketplaceExtension extensionFromVscodeMarketplace diff --git a/pkgs/misc/vscode-extensions/vscodeEnv.nix b/pkgs/misc/vscode-extensions/vscodeEnv.nix index 7c1bb255b850..395e5307bc17 100644 --- a/pkgs/misc/vscode-extensions/vscodeEnv.nix +++ b/pkgs/misc/vscode-extensions/vscodeEnv.nix @@ -1,32 +1,37 @@ #use vscodeWithConfiguration and vscodeExts2nix to create vscode exetuable that when exits(vscode) will update the mutable extension file, which is imported when getting evaluated by nix. -{ pkgs ? import {} -, lib ? pkgs.lib -, writeShellScriptBin ? pkgs.writeShellScriptBin -, extensionsFromVscodeMarketplace ? pkgs.vscode-utils.extensionsFromVscodeMarketplace - +{ lib +, buildEnv +, writeShellScriptBin +, extensionsFromVscodeMarketplace +, vscodeDefault +}: ##User input - -, nixExtensions ? [] +{ vscode ? vscodeDefault +, nixExtensions ? [] +, vscodeExtsFolderName ? ".vscode-exts" # if file exists will use it and import the extensions in it into this dervation else will use empty extensions list # this file will be created/updated by vscodeExts2nix when vscode exists -, mutableExtensionsFile ? ./extensions.nix -, vscodeExtsFolderName ? ".vscode-exts" -, vscode ? pkgs.vscode +, mutableExtensionsFile }: let - mutableExtensionsFilePath = builtins.toPath mutableExtensionsFile; + mutableExtensionsFilePath = toString mutableExtensionsFile; mutableExtensions = if builtins.pathExists mutableExtensionsFile then import mutableExtensionsFilePath else []; vscodeWithConfiguration = import ./vscodeWithConfiguration.nix { - inherit lib writeShellScriptBin vscode extensionsFromVscodeMarketplace - nixExtensions mutableExtensions vscodeExtsFolderName; + inherit lib writeShellScriptBin extensionsFromVscodeMarketplace; + vscodeDefault = vscode; + } + { + inherit nixExtensions mutableExtensions vscodeExtsFolderName; }; vscodeExts2nix = import ./vscodeExts2nix.nix { inherit lib writeShellScriptBin; + vscodeDefault = vscodeWithConfiguration; + } + { extensionsToIgnore = nixExtensions; extensions = mutableExtensions; - vscode = vscodeWithConfiguration; }; code = writeShellScriptBin "code" '' ${vscodeWithConfiguration}/bin/code --wait "$@" @@ -34,7 +39,7 @@ let ${vscodeExts2nix}/bin/vscodeExts2nix > ${mutableExtensionsFilePath} ''; in -pkgs.buildEnv { +buildEnv { name = "vscodeEnv"; paths = [ code vscodeExts2nix ]; } diff --git a/pkgs/misc/vscode-extensions/vscodeExts2nix.nix b/pkgs/misc/vscode-extensions/vscodeExts2nix.nix index 12fe09a2425c..afd176b4c5e4 100644 --- a/pkgs/misc/vscode-extensions/vscodeExts2nix.nix +++ b/pkgs/misc/vscode-extensions/vscodeExts2nix.nix @@ -1,14 +1,14 @@ # based on the passed vscode will stdout a nix expression with the installed vscode extensions -{ pkgs ? import {} -, lib ? pkgs.lib -, vscode ? pkgs.vscode -, writeShellScriptBin ? pkgs.writeShellScriptBin +{ lib +, vscodeDefault +, writeShellScriptBin +}: ##User input - -, extensionsToIgnore ? [] +{ vscode ? vscodeDefault +, extensionsToIgnore ? [] # will use those extensions to get sha256 if still exists when executed. -, extensions ? [] +, extensions ? [] }: let mktplcExtRefToFetchArgs = import ./mktplcExtRefToFetchArgs.nix; diff --git a/pkgs/misc/vscode-extensions/vscodeWithConfiguration.nix b/pkgs/misc/vscode-extensions/vscodeWithConfiguration.nix index 11282865c7c5..0ad323921928 100644 --- a/pkgs/misc/vscode-extensions/vscodeWithConfiguration.nix +++ b/pkgs/misc/vscode-extensions/vscodeWithConfiguration.nix @@ -1,17 +1,16 @@ # wrapper over vscode to control extensions per project (extensions folder will be created in execution path) -{ pkgs ? import {} -, lib ? pkgs.lib -, writeShellScriptBin ? pkgs.writeShellScriptBin -, extensionsFromVscodeMarketplace ? pkgs.vscode-utils.extensionsFromVscodeMarketplace - -##User input - -, vscode ? pkgs.vscode +{ lib +, writeShellScriptBin +, extensionsFromVscodeMarketplace +, vscodeDefault +}: +## User input +{ vscode ? vscodeDefault # extensions to be symlinked into the project's extensions folder -, nixExtensions ? [] +, nixExtensions ? [] # extensions to be copied into the project's extensions folder -, mutableExtensions ? [] -, vscodeExtsFolderName ? ".vscode-exts" +, mutableExtensions ? [] +, vscodeExtsFolderName ? ".vscode-exts" }: let nixExtsDrvs = extensionsFromVscodeMarketplace nixExtensions;