dotfiles/nix/hm-sublime-text.nix
2026-07-29 19:19:53 -04:00

223 lines
8.6 KiB
Nix

{ config, pkgs, identity, dotfilesPath, ...}:
let
# === SUBLIME PACKAGES ===
# Recent supply chain attacks have made me very very skeptical of auto-updating package systems
# Normally these are installed in Sublime with [Package Control](https://packagecontrol.io). But
# that recently changed hands (to SublimeHQ?) but is still maybe under the control of wbond who
# left the community (according to the Sublime Text discord logs). It seems complicated.
# [Package Control R](https://packages.sublimetext.io/), another community package manager now
# also exists.
# But ultimately I wanted something I could reason about
# ...so
# I stripped down my package list and am now using Nix to manage my plugin manager
#
#
# The package process is pretty simple:
# * Find the package git repository
# * Clone the package repository to [`/home/xxx/.config/sublime-text/Packages`](https://www.sublimetext.com/docs/packages.html#locations) which is where "loose" packages are to be stored
# * Install the Python dependencies of each package noted in their `dependencies.json` into `/home/xxx/.config/lib/python3x/...` (learned from the Discord Sublime server)
# and that's it!
#
# == Language packages, completely no Python, .tmLanguage + others only ==
stJQSyntax = pkgs.fetchFromGitHub {
owner = "zogwarg";
repo = "SublimeJQ";
rev = "84770c52bd0d6cea73bd41299a2770ee931320bc";
hash = "sha256-LExsNmYhCoad8nL4bb+c3/vg4OhP87kiQBNYKxR7HQE=";
};
stDockerSyntax = pkgs.fetchFromGitHub {
owner = "asbjornenge";
repo = "Docker.tmbundle";
tag = "v1.6.5";
hash = "sha256-iLtCyBgf2Zr6jAyEzH/zprXABBK38biNBB1XhnCV0xs=";
};
stGraphQLSyntax = pkgs.fetchFromGitHub {
owner = "dncrews";
repo = "GraphQL-SublimeText3";
rev = "acc1dfe30dde5091069afd6070b79a68eb1c229a";
hash = "sha256-cpFcG5XNuGmSyTVr7kjkVGg514UZAFCUeJL7aWx8Xeo=";
};
stShaderSyntax = pkgs.fetchFromGitHub {
owner = "noct";
repo = "sublime-shaders";
tag = "1.0.3";
hash = "sha256-+mDQn0/N9fhDHi8b1f9qULlxeLeLaFHGX6YXjAXZhM0=";
};
stNixSyntax = pkgs.fetchFromGitHub {
owner = "wmertens";
repo = "sublime-nix";
tag = "V2.4.0";
hash = "sha256-gZFUFSiY2MxiEiiPDekiyYfQlY8+zUhXb0Y98xCpqrs=";
};
stTOMLSyntax = pkgs.fetchFromGitHub {
owner = "jasonwilliams";
repo = "sublime_toml_highlighting";
tag = "v2.7.0";
hash = "sha256-FB6PUjYJz51/VAhfM6dp2iRWLOhZATzw4pUDTZF4uvc=";
};
# == Language package that have some Python (from least to most) ==
# Has some trivial python for building something?
stBabelSyntax = pkgs.fetchFromGitHub {
owner = "babel";
repo = "babel-sublime";
tag = "v11.2.0";
hash = "sha256-YL2XVK9RQrxRN4UAd/FHGyXzzBO4ytIO2L2E/4I9Gqs=";
};
# Has some very small Windows-only Python (dunno if it's even used?)
stIniSyntax = pkgs.fetchFromGitHub {
owner = "jwortmann";
repo = "ini-syntax";
rev = "ebfb6d3618e2b3c3ba547e3dbbe01280f548af99";
hash = "sha256-CGMUUfQ0pxIpIsOnBlnx4ex6WcrjNZk1VsPaMzD9tRU=";
};
# Has Python completions
stSassSCSS = pkgs.fetchFromGitHub {
owner = "SublimeText";
repo = "Sass";
tag = "4.0.2";
hash = "sha256-2VgrnIgPjfCk4t6pMja4VwO9wm8cLFdfJaqu+ztNVFw=";
};
# == Python/non-trivial packages ==
# Small Python package
stSyncViewScroll = pkgs.fetchFromGitHub {
owner = "zzjin";
repo = "syncViewScroll";
rev = "6f0e084aa1f73bde106a543e72c84754c861cddc";
hash = "sha256-CGMUUfQ0pxIpIsOnBlnx4ex6WcrjNZk1VsPaMzD9tRU=";
};
# Python, deps are vendored, 4+ years old, uses the jsbeautify lib I contributed to so looks legit
stJsFormat = pkgs.fetchFromGitHub {
owner = "jdavisclark";
repo = "JsFormat";
rev = "7e1266c6fd68f61a94676aae7228863f0aa42649";
hash = "sha256-hqTJ/vpfgg9v5Kyf7dAy8a44WXv1HC8EEjmDnbQoRvw=";
};
stLSP = pkgs.fetchFromGitHub {
owner = "sublimelsp";
repo = "LSP";
tag = "4070-2.13.0";
hash = "sha256-jzOb4/G/4ZngoTEh0G3tYvAkFPhwpiQS5g91InQkQzk=";
};
stLSPTypescript = pkgs.fetchFromGitHub {
owner = "sublimelsp";
repo = "LSP-typescript";
tag = "3.2.0";
hash = "sha256-MaxcViJ6SPzeSfTd1tct+KhIBEaJSKAqNh56lxKvwFg=";
};
# TODO: old/re-add?
# SFTP - Paid, dont think it has a github repo? Does it even work? Last time I tried to use it was broken
# LSPs seem to require a lot of the default installed Package Control libraries
# These are from the packages dependencies.json (LSP for example):
# https://github.com/sublimelsp/LSP/blob/fc5a7c75c8cec2e6765e218f7df980315c5c9ff3/dependencies.json
# And then correlated with the Package Control defaults from the v4 channel:
# https://packagecontrol.github.io/channel/channel_v4.json
pyTypingExtensions = pkgs.fetchPypi { # 3.8
pname = "typing_extensions";
version = "4.13.2";
format = "wheel";
python = "py3"; # the default, py2.py3 does not exist
dist = "py3";
hash = "sha256-pDnnwEtJ/sPl0+K+qiF1XK273DkWlOKMzdNspKFAj4w=";
};
pyBraceX = pkgs.fetchPypi { # 3.8
pname = "bracex";
version = "2.5";
format = "wheel";
python = "py3";
dist = "py3";
hash = "sha256-0vz0tgaoKsMlRxr/4XBt2buqNTbJHvhqMfa3ZvPa0dA=";
};
pyWCMatch = pkgs.fetchPypi { # 3.8
pname = "wcmatch";
version = "10.0";
format = "wheel";
python = "py3";
dist = "py3";
hash = "sha256-DdknBy0DwKZSeiDS5q1bqNA4DmCHDDg7xTO3F0Tfe3o=";
};
pyMDPopups = pkgs.fetchurl { # 3.3, 3.8
url = "https://github.com/facelessuser/sublime-markdown-popups/releases/download/st3-4.3.5/mdpopups-4.3.5-py3-none-any.whl";
hash = "sha256-oohYhC91jxuD9RnFie4NXYWVgb5KzJgxetVmEHk8qSc=";
};
pyLSPUtils = pkgs.fetchurl { # 3.8, 3.13, 3.14
url = "https://github.com/sublimelsp/lsp_utils/releases/download/v3.7.6/lsp_utils-3.7.6-py3-none-any.whl";
hash = "sha256-9QLdEDOSWflFINo6eQe/6I++huuJ3KWFyju54t5euVI=";
};
pySublimeLib = pkgs.fetchurl { #3.8, 3.13, 3.14
url = "https://github.com/SublimeText/sublime_lib/releases/download/v2.1.0/sublime_lib-2.1.0-py3-none-any.whl";
hash = "sha256-DnQZeTpxBNYau4Qp0QlSBGO3aI7Osyjig723WaSksZU=";
};
sublimePythonLibs = pkgs.stdenv.mkDerivation {
name = "sublime-text-python38-libs";
srcs = [
pyTypingExtensions
pyBraceX
pyWCMatch
pyMDPopups
pyLSPUtils
pySublimeLib
];
nativeBuildInputs = [ pkgs.unzip ];
unpackPhase = ''
mkdir -p $out
for src in $srcs; do
unzip "$src" -d $out
done
'';
dontBuild = true;
dontInstall = true;
};
in {
# TODO:
# Sublime pulls a binary and augments it :pensive:
# I tried switching to micro but the LSP and file tree were too fucked for it to be my daily driver right now
#
# * sublime is _subline text 2_, do not use
# * Requires unfree packages
# * In nixpkgs-26.05 - It requires openssl1_1 which is unsupported and requires a special flag to install (I couldn't get it to work)
# * In nixpkgs-unstable - openssl1_1 was removed and the package host fails, so no packages can be used. sublime4 was marked broken
#
# tracking
# https://github.com/sublimehq/sublime_text/issues/5984
# https://github.com/NixOS/nixpkgs/pull/531298
#
# home.packages = with pkgs; [
# sublime4
# ];
#
# For now, this has to be _manually installed_ on the underlying system (I installed the .deb)
programs.home-manager.enable = true;
# Config
home.file.".config/sublime-text/Packages/User".source = config.lib.file.mkOutOfStoreSymlink "${dotfilesPath}/.config/sublime-text/Packages/User";
# Packages
home.file.".config/sublime-text/Packages/JQ Syntax".source = stJQSyntax;
home.file.".config/sublime-text/Packages/Dockerfile Syntax Highlighting".source = stDockerSyntax;
home.file.".config/sublime-text/Packages/GraphQL".source = stGraphQLSyntax;
home.file.".config/sublime-text/Packages/Shader Syntax (GLSL HLSL Cg)".source = stShaderSyntax;
home.file.".config/sublime-text/Packages/Nix".source = stNixSyntax;
home.file.".config/sublime-text/Packages/TOML".source = stTOMLSyntax;
home.file.".config/sublime-text/Packages/Babel".source = stBabelSyntax;
home.file.".config/sublime-text/Packages/INI".source = stIniSyntax;
home.file.".config/sublime-text/Packages/Sass".source = stSassSCSS;
home.file.".config/sublime-text/Packages/Sync View Scroll".source = stSyncViewScroll;
home.file.".config/sublime-text/Packages/JsFormat".source = stJsFormat;
home.file.".config/sublime-text/Packages/LSP".source = stLSP;
home.file.".config/sublime-text/Packages/LSP-typescript".source = stLSPTypescript;
# Libs
# home.file.".config/sublime-text/Lib/python38/typing_extensions".source = pyTypingExtensions;
home.file.".config/sublime-text/Lib/python38".source = sublimePythonLibs;
}