git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #49716 from eadwu/vscode/insiders

vscode,vscode-insiders: fix insiders build

commitaa85911be5370a4a631f84c4a16849596e7579f9 authorDmitry Kalinkin <dmitry.kalinkin@gmail.com> dateTue 4 Dec 2018, 16:55 (8 years ago) parentb38dd07d41e868
2 files changed+26−33
pkgs/applications/editors/vscode/default.nix+19−13 pkgs/applications/editors/vscode/with-extensions.nix+7−20
pkgs/applications/editors/vscode/default.nix+19−13
@@ -1,9 +1,9 @@
11{ stdenv, lib, fetchurl, unzip, atomEnv, makeDesktopItem,
2− gtk2, wrapGAppsHook, libXScrnSaver, libxkbfile, libsecret }:
2+ gtk2, wrapGAppsHook, libXScrnSaver, libxkbfile, libsecret,
3+ isInsiders ? false }:
34
45let
5− version = "1.29.1";
6− channel = "stable";
6+ executableName = "code" + lib.optionalString isInsiders "-insiders";
77
88 plat = {
99 "i686-linux" = "linux-ia32";
@@ -31,19 +31,24 @@ let
3131in
3232 stdenv.mkDerivation rec {
3333 name = "vscode-${version}";
34+ version = "1.29.1";
3435
3536 src = fetchurl {
3637 name = "VSCode_${version}_${plat}.${archive_fmt}";
37− url = "https://vscode-update.azurewebsites.net/${version}/${plat}/${channel}";
38+ url = "https://vscode-update.azurewebsites.net/${version}/${plat}/stable";
3839 inherit sha256;
3940 };
4041
42+ passthru = {
43+ inherit executableName;
44+ };
45+
4146 desktopItem = makeDesktopItem {
42− name = "code";
43− exec = "code";
44− icon = "code";
47+ name = executableName;
48+ exec = executableName;
49+ icon = "@out@/share/pixmaps/code.png";
4550 comment = "Code editor redefined and optimized for building and debugging modern web and cloud applications";
46− desktopName = "Visual Studio Code";
51+ desktopName = "Visual Studio Code" + lib.optionalString isInsiders " Insiders";
4752 genericName = "Text Editor";
4853 categories = "GNOME;GTK;Utility;TextEditor;Development;";
4954 };
@@ -56,17 +61,18 @@ in
5661 if stdenv.hostPlatform.system == "x86_64-darwin" then ''
5762 mkdir -p $out/lib/vscode $out/bin
5863 cp -r ./* $out/lib/vscode
59− ln -s $out/lib/vscode/Contents/Resources/app/bin/code $out/bin
64+ ln -s $out/lib/vscode/Contents/Resources/app/bin/${executableName} $out/bin
6065 '' else ''
6166 mkdir -p $out/lib/vscode $out/bin
6267 cp -r ./* $out/lib/vscode
6368
64− substituteInPlace $out/lib/vscode/bin/code --replace '"$CLI" "$@"' '"$CLI" "--skip-getting-started" "$@"'
69+ substituteInPlace $out/lib/vscode/bin/${executableName} --replace '"$CLI" "$@"' '"$CLI" "--skip-getting-started" "$@"'
6570
66− ln -s $out/lib/vscode/bin/code $out/bin
71+ ln -s $out/lib/vscode/bin/${executableName} $out/bin
6772
6873 mkdir -p $out/share/applications
69− cp $desktopItem/share/applications/* $out/share/applications
74+ substitute $desktopItem/share/applications/${executableName}.desktop $out/share/applications/${executableName}.desktop \
75+ --subst-var out
7076
7177 mkdir -p $out/share/pixmaps
7278 cp $out/lib/vscode/resources/app/resources/linux/code.png $out/share/pixmaps/code.png
@@ -76,7 +82,7 @@ in
7682 patchelf \
7783 --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
7884 --set-rpath "${rpath}" \
79− $out/lib/vscode/code
85+ $out/lib/vscode/${executableName}
8086
8187 patchelf \
8288 --set-rpath "${rpath}" \
pkgs/applications/editors/vscode/with-extensions.nix+7−20
@@ -1,4 +1,4 @@
1−{ stdenv, lib, runCommand, buildEnv, vscode, which, writeScript
1+{ stdenv, lib, runCommand, buildEnv, vscode, makeWrapper
22, vscodeExtensions ? [] }:
33
44/*
@@ -43,6 +43,7 @@
4343
4444let
4545
46+ inherit (vscode) executableName;
4647 wrappedPkgVersion = lib.getVersion vscode;
4748 wrappedPkgName = lib.removeSuffix "-${wrappedPkgVersion}" vscode.name;
4849
@@ -51,22 +52,12 @@ let
5152 paths = vscodeExtensions;
5253 };
5354
54− wrappedExeName = "code";
55− exeName = wrappedExeName;
56−
57− wrapperExeFile = writeScript "${exeName}" ''
58− #!${stdenv.shell}
59− exec ${vscode}/bin/${wrappedExeName} \
60− --extensions-dir "${combinedExtensionsDrv}/share/${wrappedPkgName}/extensions" \
61− "$@"
62− '';
63−
6455in
6556
6657# When no extensions are requested, we simply redirect to the original
6758# non-wrapped vscode executable.
6859runCommand "${wrappedPkgName}-with-extensions-${wrappedPkgVersion}" {
69− buildInputs = [ vscode which ];
60+ buildInputs = [ vscode makeWrapper ];
7061 dontPatchELF = true;
7162 dontStrip = true;
7263 meta = vscode.meta;
@@ -75,13 +66,9 @@ runCommand "${wrappedPkgName}-with-extensions-${wrappedPkgVersion}" {
7566 mkdir -p "$out/share/applications"
7667 mkdir -p "$out/share/pixmaps"
7768
78− ln -sT "${vscode}/share/applications/code.desktop" "$out/share/applications/code.desktop"
7969 ln -sT "${vscode}/share/pixmaps/code.png" "$out/share/pixmaps/code.png"
80− ${if [] == vscodeExtensions
81− then ''
82− ln -sT "${vscode}/bin/${wrappedExeName}" "$out/bin/${exeName}"
83− ''
84− else ''
85− ln -sT "${wrapperExeFile}" "$out/bin/${exeName}"
86− ''}
70+ ln -sT "${vscode}/share/applications/${executableName}.desktop" "$out/share/applications/${executableName}.desktop"
71+ makeWrapper "${vscode}/bin/${executableName}" "$out/bin/${executableName}" \
72+ --add-flags \
73+ "--extensions-dir ${combinedExtensionsDrv}/share/${wrappedPkgName}/extensions"
8774''