mirror of
https://github.com/davegallant/nix-config
synced 2025-08-07 05:02:28 +00:00
Add vscode overlay that pins 1.52.1 so that liveshare works
This commit is contained in:
18
flake.lock
generated
18
flake.lock
generated
@@ -7,11 +7,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1612561117,
|
"lastModified": 1613153184,
|
||||||
"narHash": "sha256-UEB+5KCINGyaAfkgqWeUhUwyBxTrlTLO+FjbYCG4exk=",
|
"narHash": "sha256-9ZIBmZuEjcxWON6zeEzCUfobTf/WTVQVOdg3gyNfhTw=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "d4202875831a2d1b9dd3002d89b8c794af9e5a43",
|
"rev": "1ee1d01daa19b3a6d16b5fb680c31a2bc110ce24",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -22,11 +22,11 @@
|
|||||||
},
|
},
|
||||||
"nixos-hardware": {
|
"nixos-hardware": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1612300919,
|
"lastModified": 1612981022,
|
||||||
"narHash": "sha256-+R4qzU4y/pK7LAg+MSd6JxHxbEqCXOuk8Y3xhOWWmmE=",
|
"narHash": "sha256-NKw0ntMPQw0cfNj0KzjF6QIguREEk79r6h5FMz8xbRQ=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixos-hardware",
|
"repo": "nixos-hardware",
|
||||||
"rev": "d6a123118152f766cb87983ed60b9a0094fa4306",
|
"rev": "0cb5491af9da8d6f16540ffc4db24e2361852e46",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -38,11 +38,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1612369752,
|
"lastModified": 1612996220,
|
||||||
"narHash": "sha256-JtncDAt+qqUvdaIEpXmLXveu/AeXOPOYGDbpPoG2zgA=",
|
"narHash": "sha256-l2kzWXxL3vXr8VxUzRtORPJS0nFQ3E5kBPF/AYAK0wI=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "7cbec40a09533dd9c525d6ab94dddfe77768101a",
|
"rev": "758b29b5a28b818e311ad540637a5c1e40867489",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@@ -5,5 +5,6 @@ final: prev: {
|
|||||||
rfd = prev.callPackage ./rfd { };
|
rfd = prev.callPackage ./rfd { };
|
||||||
srv = prev.callPackage ./srv { };
|
srv = prev.callPackage ./srv { };
|
||||||
vpngate = prev.callPackage ./vpngate { };
|
vpngate = prev.callPackage ./vpngate { };
|
||||||
|
vscode = prev.callPackage ./vscode { };
|
||||||
|
|
||||||
}
|
}
|
||||||
|
61
overlays/vscode/default.nix
Normal file
61
overlays/vscode/default.nix
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
{ stdenv, lib, callPackage, fetchurl, isInsiders ? false }:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (stdenv.hostPlatform) system;
|
||||||
|
|
||||||
|
plat = {
|
||||||
|
x86_64-linux = "linux-x64";
|
||||||
|
x86_64-darwin = "darwin";
|
||||||
|
aarch64-linux = "linux-arm64";
|
||||||
|
armv7l-linux = "linux-armhf";
|
||||||
|
}.${system};
|
||||||
|
|
||||||
|
archive_fmt = if system == "x86_64-darwin" then "zip" else "tar.gz";
|
||||||
|
|
||||||
|
sha256 = {
|
||||||
|
x86_64-linux = "1kbjbqb03yapz7067q589gaa7d6cqaipj7hmp1l3nh0bmggzsc4c";
|
||||||
|
x86_64-darwin = "1qgadm52c5lzkvgvqrz0n8brm4qbjg8hf1dk6a2ynqhqjxcwbj4r";
|
||||||
|
aarch64-linux = "0i3yl9rx9h7qkl3k9qk6gg35nhz737qzzbvzvdwkqjaacsbpfgf8";
|
||||||
|
armv7l-linux = "19iz2bxcq6y8sklr6zcnbp47kki9l00x3nvr213lkk3kj08l0afv";
|
||||||
|
}.${system};
|
||||||
|
in callPackage ./generic.nix rec {
|
||||||
|
# The update script doesn't correctly change the hash for darwin, so please:
|
||||||
|
# nixpkgs-update: no auto update
|
||||||
|
|
||||||
|
# Please backport all compatible updates to the stable release.
|
||||||
|
# This is important for the extension ecosystem.
|
||||||
|
version = "1.52.1";
|
||||||
|
pname = "vscode";
|
||||||
|
|
||||||
|
executableName = "code" + lib.optionalString isInsiders "-insiders";
|
||||||
|
longName = "Visual Studio Code" + lib.optionalString isInsiders " - Insiders";
|
||||||
|
shortName = "Code" + lib.optionalString isInsiders " - Insiders";
|
||||||
|
|
||||||
|
src = fetchurl {
|
||||||
|
name = "VSCode_${version}_${plat}.${archive_fmt}";
|
||||||
|
url = "https://vscode-update.azurewebsites.net/${version}/${plat}/stable";
|
||||||
|
inherit sha256;
|
||||||
|
};
|
||||||
|
|
||||||
|
sourceRoot = "";
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = ''
|
||||||
|
Open source source code editor developed by Microsoft for Windows,
|
||||||
|
Linux and macOS
|
||||||
|
'';
|
||||||
|
longDescription = ''
|
||||||
|
Open source source code editor developed by Microsoft for Windows,
|
||||||
|
Linux and macOS. It includes support for debugging, embedded Git
|
||||||
|
control, syntax highlighting, intelligent code completion, snippets,
|
||||||
|
and code refactoring. It is also customizable, so users can change the
|
||||||
|
editor's theme, keyboard shortcuts, and preferences
|
||||||
|
'';
|
||||||
|
homepage = "https://code.visualstudio.com/";
|
||||||
|
downloadPage = "https://code.visualstudio.com/Updates";
|
||||||
|
license = licenses.unfree;
|
||||||
|
maintainers = with maintainers; [ eadwu synthetica ];
|
||||||
|
platforms =
|
||||||
|
[ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "armv7l-linux" ];
|
||||||
|
};
|
||||||
|
}
|
95
overlays/vscode/generic.nix
Normal file
95
overlays/vscode/generic.nix
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
{ stdenv, lib, makeDesktopItem, unzip, libsecret, libXScrnSaver, wrapGAppsHook
|
||||||
|
, gtk2, atomEnv, at-spi2-atk, autoPatchelfHook, systemd, fontconfig, libdbusmenu
|
||||||
|
|
||||||
|
# Populate passthru.tests
|
||||||
|
, tests
|
||||||
|
|
||||||
|
# Attributes inherit from specific versions
|
||||||
|
, version, src, meta, sourceRoot, executableName, longName, shortName, pname }:
|
||||||
|
|
||||||
|
let inherit (stdenv.hostPlatform) system;
|
||||||
|
in stdenv.mkDerivation {
|
||||||
|
|
||||||
|
inherit pname version src sourceRoot;
|
||||||
|
|
||||||
|
passthru = { inherit executableName tests; };
|
||||||
|
|
||||||
|
desktopItem = makeDesktopItem {
|
||||||
|
name = executableName;
|
||||||
|
desktopName = longName;
|
||||||
|
comment = "Code Editing. Redefined.";
|
||||||
|
genericName = "Text Editor";
|
||||||
|
exec = "${executableName} %F";
|
||||||
|
icon = "code";
|
||||||
|
startupNotify = "true";
|
||||||
|
categories = "Utility;TextEditor;Development;IDE;";
|
||||||
|
mimeType = "text/plain;inode/directory;";
|
||||||
|
extraEntries = ''
|
||||||
|
StartupWMClass=${shortName}
|
||||||
|
Actions=new-empty-window;
|
||||||
|
Keywords=vscode;
|
||||||
|
|
||||||
|
[Desktop Action new-empty-window]
|
||||||
|
Name=New Empty Window
|
||||||
|
Exec=${executableName} --new-window %F
|
||||||
|
Icon=code
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
urlHandlerDesktopItem = makeDesktopItem {
|
||||||
|
name = executableName + "-url-handler";
|
||||||
|
desktopName = longName + " - URL Handler";
|
||||||
|
comment = "Code Editing. Redefined.";
|
||||||
|
genericName = "Text Editor";
|
||||||
|
exec = executableName + " --open-url %U";
|
||||||
|
icon = "code";
|
||||||
|
startupNotify = "true";
|
||||||
|
categories = "Utility;TextEditor;Development;IDE;";
|
||||||
|
mimeType = "x-scheme-handler/vscode;";
|
||||||
|
extraEntries = ''
|
||||||
|
NoDisplay=true
|
||||||
|
Keywords=vscode;
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
buildInputs = (if stdenv.isDarwin then
|
||||||
|
[ unzip ]
|
||||||
|
else
|
||||||
|
[ gtk2 at-spi2-atk wrapGAppsHook ] ++ atomEnv.packages)
|
||||||
|
++ [ libsecret libXScrnSaver ];
|
||||||
|
|
||||||
|
runtimeDependencies = lib.optional (stdenv.isLinux) [
|
||||||
|
(lib.getLib systemd)
|
||||||
|
fontconfig.lib
|
||||||
|
libdbusmenu
|
||||||
|
];
|
||||||
|
|
||||||
|
nativeBuildInputs = lib.optional (!stdenv.isDarwin) autoPatchelfHook;
|
||||||
|
|
||||||
|
dontBuild = true;
|
||||||
|
dontConfigure = true;
|
||||||
|
|
||||||
|
installPhase = if system == "x86_64-darwin" then ''
|
||||||
|
mkdir -p "$out/Applications/${longName}.app" $out/bin
|
||||||
|
cp -r ./* "$out/Applications/${longName}.app"
|
||||||
|
ln -s "$out/Applications/${longName}.app/Contents/Resources/app/bin/code" $out/bin/${executableName}
|
||||||
|
'' else ''
|
||||||
|
mkdir -p $out/lib/vscode $out/bin
|
||||||
|
cp -r ./* $out/lib/vscode
|
||||||
|
|
||||||
|
ln -s $out/lib/vscode/bin/${executableName} $out/bin
|
||||||
|
|
||||||
|
mkdir -p $out/share/applications
|
||||||
|
ln -s $desktopItem/share/applications/${executableName}.desktop $out/share/applications/${executableName}.desktop
|
||||||
|
ln -s $urlHandlerDesktopItem/share/applications/${executableName}-url-handler.desktop $out/share/applications/${executableName}-url-handler.desktop
|
||||||
|
|
||||||
|
mkdir -p $out/share/pixmaps
|
||||||
|
cp $out/lib/vscode/resources/app/resources/linux/code.png $out/share/pixmaps/code.png
|
||||||
|
|
||||||
|
# Override the previously determined VSCODE_PATH with the one we know to be correct
|
||||||
|
sed -i "/ELECTRON=/iVSCODE_PATH='$out/lib/vscode'" $out/bin/${executableName}
|
||||||
|
grep -q "VSCODE_PATH='$out/lib/vscode'" $out/bin/${executableName} # check if sed succeeded
|
||||||
|
'';
|
||||||
|
|
||||||
|
inherit meta;
|
||||||
|
}
|
36
overlays/vscode/update-vscode.sh
Executable file
36
overlays/vscode/update-vscode.sh
Executable file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env nix-shell
|
||||||
|
#!nix-shell -i bash -p curl jq gnused
|
||||||
|
|
||||||
|
# Update script for the vscode versions and hashes.
|
||||||
|
# Usually doesn't need to be called by hand,
|
||||||
|
# but is called by a bot: https://github.com/samuela/nixpkgs-upkeep/actions
|
||||||
|
# Call it by hand if the bot fails to automatically update the versions.
|
||||||
|
|
||||||
|
set -eou pipefail
|
||||||
|
|
||||||
|
ROOT="$(dirname "$(readlink -f "$0")")"
|
||||||
|
if [ ! -f "$ROOT/vscode.nix" ]; then
|
||||||
|
echo "ERROR: cannot find vscode.nix in $ROOT"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# VSCode
|
||||||
|
|
||||||
|
VSCODE_VER=$(curl --fail --silent https://api.github.com/repos/Microsoft/vscode/releases/latest | jq --raw-output .tag_name)
|
||||||
|
sed -i "s/version = \".*\"/version = \"${VSCODE_VER}\"/" "$ROOT/vscode.nix"
|
||||||
|
|
||||||
|
VSCODE_LINUX_URL="https://vscode-update.azurewebsites.net/${VSCODE_VER}/linux-x64/stable"
|
||||||
|
VSCODE_LINUX_SHA256=$(nix-prefetch-url ${VSCODE_LINUX_URL})
|
||||||
|
sed -i "s/x86_64-linux = \".\{52\}\"/x86_64-linux = \"${VSCODE_LINUX_SHA256}\"/" "$ROOT/vscode.nix"
|
||||||
|
|
||||||
|
VSCODE_DARWIN_URL="https://vscode-update.azurewebsites.net/${VSCODE_VER}/darwin/stable"
|
||||||
|
VSCODE_DARWIN_SHA256=$(nix-prefetch-url ${VSCODE_DARWIN_URL})
|
||||||
|
sed -i "s/x86_64-darwin = \".\{52\}\"/x86_64-darwin = \"${VSCODE_DARWIN_SHA256}\"/" "$ROOT/vscode.nix"
|
||||||
|
|
||||||
|
VSCODE_LINUX_AARCH64_URL="https://vscode-update.azurewebsites.net/${VSCODE_VER}/linux-arm64/stable"
|
||||||
|
VSCODE_LINUX_AARCH64_SHA256=$(nix-prefetch-url ${VSCODE_LINUX_AARCH64_URL})
|
||||||
|
sed -i "s/aarch64-linux = \".\{52\}\"/aarch64-linux = \"${VSCODE_LINUX_AARCH64_SHA256}\"/" "$ROOT/vscode.nix"
|
||||||
|
|
||||||
|
VSCODE_LINUX_ARMV7L_URL="https://vscode-update.azurewebsites.net/${VSCODE_VER}/linux-armhf/stable"
|
||||||
|
VSCODE_LINUX_ARMV7L_SHA256=$(nix-prefetch-url ${VSCODE_LINUX_ARMV7L_URL})
|
||||||
|
sed -i "s/armv7l-linux = \".\{52\}\"/armv7l-linux = \"${VSCODE_LINUX_ARMV7L_SHA256}\"/" "$ROOT/vscode.nix"
|
73
overlays/vscode/with-extensions.nix
Normal file
73
overlays/vscode/with-extensions.nix
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
{ lib, runCommand, buildEnv, vscode, makeWrapper, vscodeExtensions ? [ ] }:
|
||||||
|
|
||||||
|
/* `vscodeExtensions`
|
||||||
|
: A set of vscode extensions to be installed alongside the editor. Here's a an
|
||||||
|
example:
|
||||||
|
|
||||||
|
~~~
|
||||||
|
vscode-with-extensions.override {
|
||||||
|
|
||||||
|
# When the extension is already available in the default extensions set.
|
||||||
|
vscodeExtensions = with vscode-extensions; [
|
||||||
|
bbenoist.Nix
|
||||||
|
]
|
||||||
|
|
||||||
|
# Concise version from the vscode market place when not available in the default set.
|
||||||
|
++ vscode-utils.extensionsFromVscodeMarketplace [
|
||||||
|
{
|
||||||
|
name = "code-runner";
|
||||||
|
publisher = "formulahendry";
|
||||||
|
version = "0.6.33";
|
||||||
|
sha256 = "166ia73vrcl5c9hm4q1a73qdn56m0jc7flfsk5p5q41na9f10lb0";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
~~~
|
||||||
|
|
||||||
|
This expression should fetch
|
||||||
|
- the *nix* vscode extension from whatever source defined in the
|
||||||
|
default nixpkgs extensions set `vscodeExtensions`.
|
||||||
|
|
||||||
|
- the *code-runner* vscode extension from the marketplace using the
|
||||||
|
following url:
|
||||||
|
|
||||||
|
~~~
|
||||||
|
https://bbenoist.gallery.vsassets.io/_apis/public/gallery/publisher/bbenoist/extension/nix/1.0.1/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage
|
||||||
|
~~~
|
||||||
|
|
||||||
|
The original `code` executable will be wrapped so that it uses the set of pre-installed / unpacked
|
||||||
|
extensions as its `--extensions-dir`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
inherit (vscode) executableName;
|
||||||
|
wrappedPkgVersion = lib.getVersion vscode;
|
||||||
|
wrappedPkgName = lib.removeSuffix "-${wrappedPkgVersion}" vscode.name;
|
||||||
|
|
||||||
|
combinedExtensionsDrv = buildEnv {
|
||||||
|
name = "vscode-extensions";
|
||||||
|
paths = vscodeExtensions;
|
||||||
|
};
|
||||||
|
|
||||||
|
# When no extensions are requested, we simply redirect to the original
|
||||||
|
# non-wrapped vscode executable.
|
||||||
|
in runCommand "${wrappedPkgName}-with-extensions-${wrappedPkgVersion}" {
|
||||||
|
buildInputs = [ vscode makeWrapper ];
|
||||||
|
dontPatchELF = true;
|
||||||
|
dontStrip = true;
|
||||||
|
meta = vscode.meta;
|
||||||
|
} ''
|
||||||
|
mkdir -p "$out/bin"
|
||||||
|
mkdir -p "$out/share/applications"
|
||||||
|
mkdir -p "$out/share/pixmaps"
|
||||||
|
|
||||||
|
ln -sT "${vscode}/share/pixmaps/code.png" "$out/share/pixmaps/code.png"
|
||||||
|
ln -sT "${vscode}/share/applications/${executableName}.desktop" "$out/share/applications/${executableName}.desktop"
|
||||||
|
ln -sT "${vscode}/share/applications/${executableName}-url-handler.desktop" "$out/share/applications/${executableName}-url-handler.desktop"
|
||||||
|
makeWrapper "${vscode}/bin/${executableName}" "$out/bin/${executableName}" ${
|
||||||
|
lib.optionalString (vscodeExtensions != [ ]) ''
|
||||||
|
--add-flags "--extensions-dir ${combinedExtensionsDrv}/share/vscode/extensions"
|
||||||
|
''
|
||||||
|
}
|
||||||
|
''
|
Reference in New Issue
Block a user