blob: e8ffe9f3b87786a64e46d5a7f05ba08079335de8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
{ stdenv
, fetchurl
, lib
, makeWrapper
, electron
, makeDesktopItem
, imagemagick
, writeScript
, undmg
, unzip
, commandLineArgs ? ""
}:
let
pname = "obsidian";
version = "1.6.7";
appname = "Obsidian";
meta = with lib; {
description = "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";
mainProgram = "obsidian";
license = licenses.obsidian;
maintainers = with maintainers; [ atila conradmearns zaninime qbit kashw2 w-lfchen ];
};
filename = if stdenv.hostPlatform.isDarwin then "Obsidian-${version}.dmg" else "obsidian-${version}.tar.gz";
src = fetchurl {
url = "https://github.com/obsidianmd/obsidian-releases/releases/download/v${version}/${filename}";
hash = if stdenv.hostPlatform.isDarwin then "sha256-rFXmhlxXlVz5nCrXMmfYGaxe4/wnBRdFxsfiwiIDHgw=" else "sha256-ok1fedN8+OXBisFpVXbKRW2OhE4o9MC9lJmtMMST6V8=";
};
icon = fetchurl {
url = "https://obsidian.md/images/obsidian-logo-gradient.svg";
hash = "sha256-EZsBuWyZ9zYJh0LDKfRAMTtnY70q6iLK/ggXlplDEoA=";
};
desktopItem = makeDesktopItem {
name = "obsidian";
desktopName = "Obsidian";
comment = "Knowledge base";
icon = "obsidian";
exec = "obsidian %u";
categories = [ "Office" ];
mimeTypes = [ "x-scheme-handler/obsidian" ];
};
linux = stdenv.mkDerivation {
inherit pname version src desktopItem icon;
meta = meta // { platforms = [ "x86_64-linux" "aarch64-linux" ]; };
nativeBuildInputs = [ makeWrapper imagemagick ];
installPhase = ''
runHook preInstall
mkdir -p $out/bin
makeWrapper ${electron}/bin/electron $out/bin/obsidian \
--add-flags $out/share/obsidian/app.asar \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform=wayland}}" \
--add-flags ${lib.escapeShellArg commandLineArgs}
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
convert -background none -resize "$size"x"$size" ${icon} $out/share/icons/hicolor/"$size"x"$size"/apps/obsidian.png
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"
'';
};
darwin = stdenv.mkDerivation {
inherit pname version src appname;
meta = meta // { platforms = [ "x86_64-darwin" "aarch64-darwin" ]; };
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
'';
};
in
if stdenv.hostPlatform.isDarwin then darwin else linux
|