2022-03-30 09:31:56 +00:00
|
|
|
{ stdenv
|
|
|
|
, fetchurl
|
|
|
|
, lib
|
|
|
|
, makeWrapper
|
2023-02-09 11:40:11 +00:00
|
|
|
, electron
|
2022-03-30 09:31:56 +00:00
|
|
|
, makeDesktopItem
|
2023-07-15 17:15:38 +00:00
|
|
|
, imagemagick
|
2022-03-30 09:31:56 +00:00
|
|
|
, writeScript
|
|
|
|
, undmg
|
|
|
|
, unzip
|
|
|
|
}:
|
2020-07-18 16:06:22 +00:00
|
|
|
let
|
2022-03-30 09:31:56 +00:00
|
|
|
inherit (stdenv.hostPlatform) system;
|
2020-09-25 04:45:31 +00:00
|
|
|
pname = "obsidian";
|
2024-01-02 11:29:13 +00:00
|
|
|
version = "1.5.3";
|
2022-04-15 01:41:22 +00:00
|
|
|
appname = "Obsidian";
|
2022-03-30 09:31:56 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "A powerful knowledge base that works on top of a local folder of plain text Markdown files";
|
|
|
|
homepage = "https://obsidian.md";
|
|
|
|
downloadPage = "https://github.com/obsidianmd/obsidian-releases/releases";
|
|
|
|
license = licenses.obsidian;
|
2023-10-09 19:29:22 +00:00
|
|
|
maintainers = with maintainers; [ atila conradmearns zaninime qbit kashw2 ];
|
2022-03-30 09:31:56 +00:00
|
|
|
};
|
2020-07-18 16:06:22 +00:00
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
filename = if stdenv.isDarwin then "Obsidian-${version}-universal.dmg" else "obsidian-${version}.tar.gz";
|
2020-07-18 16:06:22 +00:00
|
|
|
src = fetchurl {
|
2022-03-30 09:31:56 +00:00
|
|
|
url = "https://github.com/obsidianmd/obsidian-releases/releases/download/v${version}/${filename}";
|
2024-01-02 11:29:13 +00:00
|
|
|
hash = if stdenv.isDarwin then "sha256-AXjzQwZxyRaI8mMU2EsNK0fRcXS7UNNBWPXeJzgomlY=" else "sha256-F7nqWOeBGGSmSVNTpcx3lHRejSjNeM2BBqS9tsasTvg=";
|
2020-07-18 16:06:22 +00:00
|
|
|
};
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
icon = fetchurl {
|
2023-07-15 17:15:38 +00:00
|
|
|
url = "https://obsidian.md/images/obsidian-logo-gradient.svg";
|
2023-10-09 19:29:22 +00:00
|
|
|
hash = "sha256-EZsBuWyZ9zYJh0LDKfRAMTtnY70q6iLK/ggXlplDEoA=";
|
2022-04-15 01:41:22 +00:00
|
|
|
};
|
2022-03-30 09:31:56 +00:00
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
desktopItem = makeDesktopItem {
|
|
|
|
name = "obsidian";
|
|
|
|
desktopName = "Obsidian";
|
|
|
|
comment = "Knowledge base";
|
|
|
|
icon = "obsidian";
|
|
|
|
exec = "obsidian %u";
|
|
|
|
categories = [ "Office" ];
|
|
|
|
mimeTypes = [ "x-scheme-handler/obsidian" ];
|
|
|
|
};
|
2022-03-30 09:31:56 +00:00
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
linux = stdenv.mkDerivation {
|
|
|
|
inherit pname version src desktopItem icon;
|
|
|
|
meta = meta // { platforms = [ "x86_64-linux" "aarch64-linux" ]; };
|
2023-07-15 17:15:38 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper imagemagick ];
|
2022-03-30 09:31:56 +00:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
mkdir -p $out/bin
|
2023-02-09 11:40:11 +00:00
|
|
|
makeWrapper ${electron}/bin/electron $out/bin/obsidian \
|
2022-12-17 10:02:37 +00:00
|
|
|
--add-flags $out/share/obsidian/app.asar \
|
|
|
|
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform=wayland}}"
|
2022-03-30 09:31:56 +00:00
|
|
|
install -m 444 -D resources/app.asar $out/share/obsidian/app.asar
|
|
|
|
install -m 444 -D resources/obsidian.asar $out/share/obsidian/obsidian.asar
|
|
|
|
install -m 444 -D "${desktopItem}/share/applications/"* \
|
|
|
|
-t $out/share/applications/
|
|
|
|
for size in 16 24 32 48 64 128 256 512; do
|
|
|
|
mkdir -p $out/share/icons/hicolor/"$size"x"$size"/apps
|
2023-07-15 17:15:38 +00:00
|
|
|
convert -background none -resize "$size"x"$size" ${icon} $out/share/icons/hicolor/"$size"x"$size"/apps/obsidian.png
|
2022-03-30 09:31:56 +00:00
|
|
|
done
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
passthru.updateScript = writeScript "updater" ''
|
|
|
|
#!/usr/bin/env nix-shell
|
|
|
|
#!nix-shell -i bash -p curl jq common-updater-scripts
|
|
|
|
set -eu -o pipefail
|
|
|
|
latestVersion="$(curl -sS https://raw.githubusercontent.com/obsidianmd/obsidian-releases/master/desktop-releases.json | jq -r '.latestVersion')"
|
|
|
|
update-source-version obsidian "$latestVersion"
|
|
|
|
'';
|
|
|
|
};
|
2020-07-18 16:06:22 +00:00
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
darwin = stdenv.mkDerivation {
|
|
|
|
inherit pname version src appname;
|
|
|
|
meta = meta // { platforms = [ "x86_64-darwin" "aarch64-darwin" ]; };
|
2022-03-30 09:31:56 +00:00
|
|
|
sourceRoot = "${appname}.app";
|
|
|
|
nativeBuildInputs = [ makeWrapper undmg unzip ];
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
mkdir -p $out/{Applications/${appname}.app,bin}
|
|
|
|
cp -R . $out/Applications/${appname}.app
|
|
|
|
makeWrapper $out/Applications/${appname}.app/Contents/MacOS/${appname} $out/bin/${pname}
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
2020-07-18 16:06:22 +00:00
|
|
|
};
|
2022-03-30 09:31:56 +00:00
|
|
|
in
|
|
|
|
if stdenv.isDarwin then darwin else linux
|