@@ -0,0 +1,97 @@
1+{ callPackage, stdenv, fetchurl, makeWrapper
2+, jq, xlibs, gtk, python, nodejs
3+, ...
4+} @ args:
5+
6+let
7+ electron = callPackage ../../../development/tools/electron/default.nix (args // rec {
8+ version = "0.35.6";
9+ sha256 = "1bwn14769nby04zkza9jphsya2p6fjnkm1k2y4h5y2l4gnqdvmx0";
10+ });
11+in
12+ stdenv.mkDerivation rec {
13+ name = "vscode-${version}";
14+ version = "0.10.10";
15+
16+ src = fetchurl {
17+ url = "https://github.com/Microsoft/vscode/archive/${version}.tar.gz";
18+ sha256 = "1mzkip6621111xwwksqjad1kgpbhna4dhpkf6cnj2r18dkk2jmcw";
19+ };
20+
21+ buildInputs = [ makeWrapper jq xlibs.libX11 xlibs.xproto gtk python nodejs electron ];
22+
23+ extensionGalleryJSON = ''
24+ {
25+ \"extensionsGallery\": {
26+ \"serviceUrl\": \"https://marketplace.visualstudio.com/_apis/public/gallery\",
27+ \"cacheUrl\": \"https://vscode.blob.core.windows.net/gallery/index\",
28+ \"itemUrl\": \"https://marketplace.visualstudio.com/items\"
29+ }
30+ }
31+ '';
32+
33+ configurePhase = ''
34+ # PATCH SCRIPT SHEBANGS
35+ echo "PATCH SCRIPT SHEBANGS"
36+ patchShebangs ./scripts
37+
38+ # ADD EXTENSION GALLERY URLS TO APPLICATION CONFIGURATION
39+ echo "AUGMENT APPLICATION CONFIGURATION"
40+ echo "$(cat ./product.json) ${extensionGalleryJSON}" | jq -s add > tmpFile && \
41+ mv tmpFile ./product.json
42+ '';
43+
44+ buildPhase = ''
45+ # INSTALL COMPILE- & RUN-TIME DEPENDENCIES
46+ echo "INSTALL COMPILE- & RUN-TIME DEPENDENCIES"
47+ mkdir -p ./tmp
48+ HOME=./tmp ./scripts/npm.sh install
49+
50+ # COMPILE SOURCES
51+ echo "COMPILE SOURCES"
52+ ./node_modules/.bin/gulp
53+ '';
54+
55+ doCheck = true;
56+ checkPhase = ''
57+ # CHECK APPLICATION
58+ echo "CHECK APPLICATION"
59+ ATOM_SHELL_INTERNAL_RUN_AS_NODE=1 ${electron}/bin/electron ./node_modules/.bin/_mocha
60+ '';
61+
62+ installPhase = ''
63+ # COPY FILES NEEDED FOR RUNNING APPLICATION TO OUT DIRECTORY
64+ echo "COPY FILES NEEDED FOR RUNNING APPLICATION TO OUT DIRECTORY"
65+ mkdir -p "$out"
66+ cp -R ./.vscode "$out"/.vscode
67+ cp -R ./extensions "$out"/extensions
68+ cp -R ./out "$out"/out
69+ cp -R ./node_modules "$out"/node_modules
70+ cp ./package.json "$out"/package.json
71+ cp ./product.json "$out"/product.json
72+ cp ./tslint.json "$out"/tslint.json
73+ # COPY LEGAL STUFF
74+ cp ./LICENSE.txt "$out"/LICENSE.txt
75+ cp ./OSSREADME.json "$out"/OSSREADME.json
76+ cp ./ThirdPartyNotices.txt "$out"/ThirdPartyNotices.txt
77+
78+ # CREATE RUNNER SCRIPT
79+ echo "CREATE RUNNER SCRIPT"
80+ mkdir -p "$out"/bin
81+ makeWrapper "${electron}/bin/electron" "$out/bin/vscode" \
82+ --set VSCODE_DEV 1 \
83+ --add-flags "$out"
84+ '';
85+
86+ meta = with stdenv.lib; {
87+ description = "Visual Studio Code is an open source source code editor developed by Microsoft for Windows, Linux and OS X.";
88+ longDescription = ''
89+ Visual Studio Code is an open source source code editor developed by Microsoft for Windows, Linux and OS X.
90+ It includes support for debugging, embedded Git control, syntax highlighting, intelligent code completion, snippets, and code refactoring.
91+ It is also customizable, so users can change the editor's theme, keyboard shortcuts, and preferences.
92+ '';
93+ homepage = http://code.visualstudio.com/;
94+ license = licenses.mit;
95+ platforms = [ "x86_64-linux" ];
96+ };
97+ }