2023-03-18 15:34:10 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, git
|
2024-04-21 20:11:14 +00:00
|
|
|
, git-lfs
|
2023-03-18 15:34:10 +00:00
|
|
|
, fetchurl
|
2024-04-26 20:24:03 +00:00
|
|
|
, wrapGAppsHook3
|
2023-10-03 00:34:02 +00:00
|
|
|
, alsa-lib
|
|
|
|
, at-spi2-atk
|
|
|
|
, cairo
|
2024-09-24 21:48:07 +00:00
|
|
|
, coreutils
|
2023-10-03 00:34:02 +00:00
|
|
|
, cups
|
|
|
|
, dbus
|
|
|
|
, expat
|
|
|
|
, gdk-pixbuf
|
2023-03-18 15:34:10 +00:00
|
|
|
, glib
|
|
|
|
, gtk3
|
2023-10-03 00:34:02 +00:00
|
|
|
, mesa
|
|
|
|
, nss
|
|
|
|
, nspr
|
2023-03-18 15:34:10 +00:00
|
|
|
, xorg
|
2023-10-03 00:34:02 +00:00
|
|
|
, libdrm
|
|
|
|
, libsecret
|
2023-03-18 15:34:10 +00:00
|
|
|
, libxkbcommon
|
2023-10-03 00:34:02 +00:00
|
|
|
, pango
|
|
|
|
, systemd
|
2023-03-18 15:34:10 +00:00
|
|
|
, hunspellDicts
|
|
|
|
, useHunspell ? true
|
|
|
|
, languages ? [ "en_US" ]
|
|
|
|
, withNemoAction ? true
|
|
|
|
, makeDesktopItem
|
|
|
|
, copyDesktopItems
|
2023-08-27 02:56:59 +00:00
|
|
|
, asar
|
2023-04-17 09:59:28 +00:00
|
|
|
, python3
|
2023-03-18 15:34:10 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2023-04-17 09:59:28 +00:00
|
|
|
pname = "pulsar";
|
2024-09-24 21:48:07 +00:00
|
|
|
version = "1.121.0";
|
2023-03-18 15:34:10 +00:00
|
|
|
|
|
|
|
sourcesPath = {
|
|
|
|
x86_64-linux.tarname = "Linux.${pname}-${version}.tar.gz";
|
2024-09-24 21:48:07 +00:00
|
|
|
x86_64-linux.hash = "sha256-xouxKl4GTNZkT5wn8qbG2W2PbVAbsK9povmIL/Mikk4=";
|
2023-03-18 15:34:10 +00:00
|
|
|
aarch64-linux.tarname = "ARM.Linux.${pname}-${version}-arm64.tar.gz";
|
2024-09-24 21:48:07 +00:00
|
|
|
aarch64-linux.hash = "sha256-qRBX8jO5xDXkZ/6TWkgNa1NS3l+z8K/JyJDAa/3me5Q=";
|
2023-03-18 15:34:10 +00:00
|
|
|
}.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
|
|
|
|
|
2023-10-03 00:34:02 +00:00
|
|
|
newLibpath = lib.makeLibraryPath [
|
|
|
|
alsa-lib
|
|
|
|
at-spi2-atk
|
|
|
|
cairo
|
|
|
|
cups
|
|
|
|
dbus
|
|
|
|
expat
|
|
|
|
gdk-pixbuf
|
|
|
|
glib
|
|
|
|
gtk3
|
|
|
|
libsecret
|
|
|
|
mesa
|
|
|
|
nss
|
|
|
|
nspr
|
|
|
|
libdrm
|
|
|
|
xorg.libX11
|
|
|
|
xorg.libxcb
|
|
|
|
xorg.libXcomposite
|
|
|
|
xorg.libXdamage
|
|
|
|
xorg.libXext
|
|
|
|
xorg.libXfixes
|
|
|
|
xorg.libXrandr
|
2023-03-18 15:34:10 +00:00
|
|
|
xorg.libxshmfence
|
|
|
|
libxkbcommon
|
|
|
|
xorg.libxkbfile
|
2023-10-03 00:34:02 +00:00
|
|
|
pango
|
2023-04-17 09:59:28 +00:00
|
|
|
stdenv.cc.cc.lib
|
2023-10-03 00:34:02 +00:00
|
|
|
systemd
|
2023-03-18 15:34:10 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
# Hunspell
|
|
|
|
hunspellDirs = builtins.map (lang: "${hunspellDicts.${lang}}/share/hunspell") languages;
|
|
|
|
hunspellTargetDirs = "$out/opt/Pulsar/resources/app.asar.unpacked/node_modules/spellchecker/vendor/hunspell_dictionaries";
|
|
|
|
hunspellCopyCommands = lib.concatMapStringsSep "\n" (lang: "cp -r ${lang}/* ${hunspellTargetDirs};") hunspellDirs;
|
|
|
|
in
|
2024-07-20 14:03:18 +00:00
|
|
|
stdenv.mkDerivation {
|
2023-03-18 15:34:10 +00:00
|
|
|
inherit pname version;
|
|
|
|
|
|
|
|
src = with sourcesPath; fetchurl {
|
|
|
|
url = "https://github.com/pulsar-edit/pulsar/releases/download/v${version}/${tarname}";
|
|
|
|
inherit hash;
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2024-04-26 20:24:03 +00:00
|
|
|
wrapGAppsHook3
|
2023-03-18 15:34:10 +00:00
|
|
|
copyDesktopItems
|
2023-08-27 02:56:59 +00:00
|
|
|
asar
|
2023-03-18 15:34:10 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
gtk3
|
|
|
|
xorg.libxkbfile
|
|
|
|
];
|
|
|
|
|
|
|
|
dontBuild = true;
|
|
|
|
dontConfigure = true;
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
mkdir -p $out/opt/Pulsar
|
|
|
|
mv * $out/opt/Pulsar
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
preFixup = ''
|
|
|
|
gappsWrapperArgs+=(
|
|
|
|
# needed for gio executable to be able to delete files
|
|
|
|
--prefix "PATH" : "${lib.makeBinPath [ glib ]}"
|
|
|
|
)
|
|
|
|
'' + lib.optionalString useHunspell ''
|
|
|
|
# On all platforms, we must inject our dictionnaries
|
|
|
|
${hunspellCopyCommands}
|
|
|
|
'';
|
|
|
|
|
|
|
|
postFixup = ''
|
|
|
|
opt=$out/opt/Pulsar
|
|
|
|
# Patch the prebuilt binaries
|
|
|
|
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
|
|
|
--set-rpath "${newLibpath}:$opt" \
|
|
|
|
--add-needed libffmpeg.so \
|
|
|
|
--add-needed libxshmfence.so.1 \
|
|
|
|
--add-needed libxkbcommon.so.0 \
|
|
|
|
--add-needed libxkbfile.so.1 \
|
|
|
|
--add-needed libsecret-1.so.0 \
|
|
|
|
$opt/pulsar
|
|
|
|
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
|
|
|
--set-rpath "${newLibpath}" \
|
|
|
|
$opt/resources/app/ppm/bin/node
|
|
|
|
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
2024-03-11 14:42:11 +00:00
|
|
|
$opt/resources/app.asar.unpacked/node_modules/symbol-provider-ctags/vendor/ctags-linux
|
2023-03-18 15:34:10 +00:00
|
|
|
|
|
|
|
# Replace the bundled git with the one from nixpkgs
|
|
|
|
dugite=$opt/resources/app.asar.unpacked/node_modules/dugite
|
|
|
|
rm -f $dugite/git/bin/git
|
|
|
|
ln -s ${git}/bin/git $dugite/git/bin/git
|
2023-04-17 09:59:28 +00:00
|
|
|
|
2024-04-21 20:11:14 +00:00
|
|
|
# Not only do we need to replace the git binary itself, we also need to replace
|
|
|
|
# all the symlinks in dugite/git/libexec/git-core.
|
|
|
|
for file in "$dugite/git/libexec/git-core"/*; do
|
|
|
|
if [ -x "$file" ] && file "$file" | grep -q "ELF"; then
|
|
|
|
# Remove ELF executable
|
|
|
|
rm "$file"
|
|
|
|
|
|
|
|
# Get the corresponding filename in nixpkgs's git
|
|
|
|
filename=$(basename "$file")
|
|
|
|
git_executable="${git}/libexec/git-core/$filename"
|
|
|
|
|
|
|
|
# Create symlink to $git_executable
|
|
|
|
ln -s "$git_executable" "$file"
|
|
|
|
|
|
|
|
echo "Replaced $file with symlink to $git_executable"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Was symlinked in previous loop, but actually, nixpkgs has a separate package for git-lfs
|
|
|
|
# Unlink to avoid a "File exists" error and relink correctly
|
|
|
|
unlink $dugite/git/libexec/git-core/git-lfs
|
|
|
|
ln -s ${git-lfs}/bin/git-lfs $dugite/git/libexec/git-core/git-lfs
|
|
|
|
'' + lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux") ''
|
2023-04-17 09:59:28 +00:00
|
|
|
# We have to patch a prebuilt binary in the asar archive
|
|
|
|
# But asar complains because the node_gyp unpacked dependency uses a prebuilt Python3 itself
|
|
|
|
|
|
|
|
rm $opt/resources/app.asar.unpacked/node_modules/tree-sitter-bash/build/node_gyp_bins/python3
|
2023-05-16 09:19:47 +00:00
|
|
|
ln -s ${python3.interpreter} $opt/resources/app.asar.unpacked/node_modules/tree-sitter-bash/build/node_gyp_bins/python3
|
2023-03-18 15:34:10 +00:00
|
|
|
'' + ''
|
|
|
|
# Patch the bundled node executables
|
|
|
|
find $opt -name "*.node" -exec patchelf --set-rpath "${newLibpath}:$opt" {} \;
|
|
|
|
# Also patch the node executable for apm
|
|
|
|
patchelf --set-rpath "${newLibpath}:$opt" $opt/resources/app/ppm/bin/node
|
|
|
|
|
2023-04-17 09:59:28 +00:00
|
|
|
# The pre-packaged ASAR bundle comes with prebuild binaries, expecting libstdc++.so.6
|
|
|
|
asarBundle=$TMPDIR/asarbundle
|
|
|
|
asar e $opt/resources/app.asar $asarBundle
|
|
|
|
find $asarBundle -name "*.node" -exec patchelf --set-rpath "${newLibpath}:$opt" --add-needed libstdc++.so.6 {} \;
|
|
|
|
unlink $asarBundle/node_modules/document-register-element/dre # Self referencing symlink, breaking asar rebundling
|
|
|
|
asar p $asarBundle $opt/resources/app.asar
|
|
|
|
rm -rf $asarBundle
|
|
|
|
|
2024-09-24 21:48:07 +00:00
|
|
|
# Pulsar uses `PULSAR_PATH` to know where it is intalled
|
2023-03-18 15:34:10 +00:00
|
|
|
mkdir -p $out/bin
|
|
|
|
wrapProgram $opt/resources/pulsar.sh \
|
2024-09-24 21:48:07 +00:00
|
|
|
--suffix "PATH" : "${lib.makeBinPath [ coreutils ]}" \
|
|
|
|
--set "PULSAR_PATH" "$opt"
|
2023-03-18 15:34:10 +00:00
|
|
|
ln -s $opt/resources/pulsar.sh $out/bin/pulsar
|
|
|
|
ln -s $opt/resources/app/ppm/bin/apm $out/bin/ppm
|
|
|
|
|
|
|
|
# Copy the icons
|
|
|
|
mkdir -p $out/share/icons/hicolor/scalable/apps $out/share/icons/hicolor/1024x1024/apps
|
|
|
|
cp $opt/resources/pulsar.svg $out/share/icons/hicolor/scalable/apps/pulsar.svg
|
|
|
|
cp $opt/resources/pulsar.png $out/share/icons/hicolor/1024x1024/apps/pulsar.png
|
|
|
|
'' + lib.optionalString withNemoAction ''
|
|
|
|
# Copy the nemo action file
|
|
|
|
mkdir -p $out/share/nemo/actions
|
|
|
|
cp ${./pulsar.nemo_action} $out/share/nemo/actions/pulsar.nemo_action
|
|
|
|
'';
|
|
|
|
|
|
|
|
desktopItems = [
|
|
|
|
(makeDesktopItem {
|
|
|
|
name = "Pulsar";
|
|
|
|
desktopName = "Pulsar";
|
|
|
|
exec = "pulsar";
|
|
|
|
icon = "pulsar";
|
|
|
|
comment = "A Community-led Hyper-Hackable Text Editor";
|
|
|
|
genericName = "Text Editor";
|
|
|
|
categories = [ "Development" "TextEditor" "Utility" ];
|
|
|
|
mimeTypes = [ "text/plain" ];
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
passthru.updateScript = ./update.mjs;
|
|
|
|
|
2024-05-18 18:40:59 +00:00
|
|
|
meta = {
|
2023-03-18 15:34:10 +00:00
|
|
|
description = "Community-led Hyper-Hackable Text Editor";
|
|
|
|
longDescription = ''
|
|
|
|
A Community-led Hyper-Hackable Text Editor, Forked from Atom, built on Electron.
|
|
|
|
Designed to be deeply customizable, but still approachable using the default configuration.
|
|
|
|
'';
|
|
|
|
homepage = "https://github.com/pulsar-edit/pulsar";
|
2024-07-20 14:03:18 +00:00
|
|
|
changelog = "https://github.com/pulsar-edit/pulsar/blob/v${version}/CHANGELOG.md";
|
2024-05-18 18:40:59 +00:00
|
|
|
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
|
|
|
license = lib.licenses.mit;
|
|
|
|
platforms = lib.platforms.linux;
|
2024-09-24 23:01:24 +00:00
|
|
|
maintainers = with lib.maintainers; [ bryango pbsds ];
|
2023-10-20 20:35:57 +00:00
|
|
|
knownVulnerabilities = [
|
2024-08-18 21:53:34 +00:00
|
|
|
# electron 12.2.3, efforts are in place to bump it
|
2023-10-20 20:35:57 +00:00
|
|
|
"CVE-2023-5217"
|
|
|
|
"CVE-2022-21718"
|
|
|
|
"CVE-2022-29247"
|
|
|
|
"CVE-2022-29257"
|
|
|
|
"CVE-2022-36077"
|
|
|
|
"CVE-2023-29198"
|
|
|
|
"CVE-2023-39956"
|
|
|
|
];
|
2023-03-18 15:34:10 +00:00
|
|
|
};
|
|
|
|
}
|